How to define HashMap<String, List<Object>> property in swagger yml?

Viewed 5513

I am using swagger to generate classes in Java and Type script. I have problem defining map property with list of objects as value. I tried to define as follows:

DataMap
type: object
additionalProperties:
 #type: array -- This config does not work.
  $ref: '#/definitions/Data'

Above yml definition generated following code in java:

  class DataMap extends HashMap<String, Data> {
    }

How can I configure yml to generate key with list of data ? something like following class:

 class DataMap extends HashMap<String, List<Data>> {
        }

or

 class DataInfo {
     Map<String, List<Data>> dataMap;
   }

Is this possible with swagger 2.0? I am thinking of defining another DataList class which extends ArrayList then use this class as value to Map.

--------------UPDATE & ANSWER-----------

Thanks @nickb

I am using swagger-codegen-maven-plugin version 2.2.1 and yml definition to generate map as follows:

 DataInfo
    type: object
    properties:
    dataMap:
     type: object
     additionalProperties:
        type: array 
        items:
          $ref: '#/definitions/Data'
1 Answers
Related