SwaggerUI 3 not respecting `explode: false` for query array parameters in OpenAPI 3 spec

Viewed 354

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 Answers

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
Related