4

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?

1 Answer 1

8

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:

2
  • 1
    explode (true/false) specifies whether arrays and objects should generate separate parameters for each array item or object property. You can check this concept from the schema vs content section of this page. Commented Jun 23, 2020 at 4:38
  • why there is no explode=both ? spring mvc supports both types. Commented Nov 11, 2021 at 14:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.