2

I have a query parameter defined in the OpenAPI 3 spec as follows:

      parameters:
      - in: query
        name: categories
        schema:
          type: array
          items:
            type: string
            enum:
            - category1
            - category2
          style: form
          explode: false

The expectation is that if I use the "Try it out!" feature and select both category1 and category2, the URL formed should contain: ?categories=category1,category2

However, instead SwaggerUI forms that part of the URL as follows: ?categories=category1&categories=category2

Thus, it seems that SwaggerUI is treating the parameter as though explode is set to true.

How can I get SwaggerUI to go with the comma-separated formulation as that's what the server is expecting?

1 Answer 1

7

The issue was that the explode and style properties should have been placed at the same level as schema, not nested inside of it.

      parameters:
      - in: query
        name: categories
        style: form
        explode: false
        schema:
          type: array
          items:
            type: string
            enum:
            - category1
            - category2
Sign up to request clarification or add additional context in comments.

1 Comment

Can you please mark your own answer as the right one? It works, and it is not documented in the swagger docs. This question is a valuable source of information.

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.