7

I am trying to define a query parameter in Swagger with comma-separated strings from a predefined set of items like ?fruits=Apples,Oranges,Bananas but I get the following error from the swagger editor

should NOT have additional properties additionalProperty: style, explode

What I am trying in the Swagger Editor is:

    - in: query
      name: fruits
      style: form
      explode: true
      required: false
      description: Filter by fruits
      type: array
      items:
        type: string
        enum:
          - Apples
          - Oranges
          - Bananas
georgeliatsos
  • 1,168
  • 3
  • 15
  • 34
  • Possible duplicate of [Swagger: take one or more values from enum](https://stackoverflow.com/questions/50538138/swagger-take-one-or-more-values-from-enum) – Helen May 17 '19 at 11:17

1 Answers1

4

style and explode are OpenAPI 3.0 keywords. But you seem to be using OpenAPI 2.0, which uses collectionFormat instead. In this case you need collectionFormat: csv (it's the default option and can be omitted).

Helen
  • 87,344
  • 17
  • 243
  • 314
  • 4
    For those using OpenAPI 3.0, the equivalent combination is `style: form` (default) and `explode: false` – josemmo Aug 11 '20 at 12:04