5

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

9

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:

Sign up to request clarification or add additional context in comments.

2 Comments

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.
why there is no explode=both ? spring mvc supports both types.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.