tnkh
tnkh

Reputation: 1839

How does open api 3.0 support a single query param key with multiple values?

For an api with this format: GET /resource?param=value1&param=value2&param=value3 In open Api 2.0, we can specify like this:

parameters:
    - in: query
      name: color
      type: array
      collectionFormat: multi
      items:
        type: string 

But in v3.0 attribute collectionFormat is not available. So while trying with collectionFormat, I received error saying should not have additional property: collectionFormat.

I have searched the documentation but can't find any answer. Does anyone have any idea what should be the new implementation to migrate from 2.0 to 3.0 version?

Upvotes: 5

Views: 6453

Answers (1)

Ashish Karn
Ashish Karn

Reputation: 1143

You should use style and explode properties instead:

  - name: param
    in: query
    description: Id description
    required: false
    style: form
    explode: true
    schema:
      type: array
      items:
        type: string

where

  • explode: true will form param=abc&param=xyz etc and
  • explode: false will form param=abc,xyz

References:

Upvotes: 9

Related Questions