swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

How to define a Map<String, List<String>> in Swagger 3.0.1

Open rgeorgievva opened this issue 3 years ago • 0 comments

Hi, is it possible to declare a map, which values are list of string. I have a project which uses open api 3.0.1 and swagger-codegen-generators 1.0.29 and I want to have an entity with field, which is Map<String, List<String>>. I try to declare it with:

ExampleEntity:
      type: object
      properties:
        tags:
          type: object
          additionalProperties:
            type: array
            items:
              type: string

This used to work until now while I used 1.0.26 version for swagger-codegen-generators, but after updating to 1.0.29 I get an error from the swagger codegen: at [Source: UNKNOWN; line: -1, column: -1] (through reference chain: io.swagger.v3.oas.models.media.ObjectSchema["additional_properties"])

I couldn't find an example in the specification, which shows how to declare map with string and list of strings. Tried also with additionalProperties: - $ref: '#/ArraySchema'

ArraySchema: type: array items: type: string

but this way the it generates Map<String, Object>.

rgeorgievva avatar Apr 29 '22 14:04 rgeorgievva