Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Query parameter with comma-separated strings in Swagger returns structural error

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
like image 509
georgeliatsos Avatar asked May 17 '19 11:05

georgeliatsos


People also ask

What is explode in swagger?

explode (true/false) specifies whether arrays and objects should generate separate parameters for each array item or object property.

How do you write a parameter query?

Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed. To append query params to the end of a URL, a '? ' Is added followed immediately by a query parameter.


1 Answers

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).

like image 186
Helen Avatar answered Sep 22 '22 09:09

Helen