swagger-api/swagger-ui

Multi selection of query parameters with array of enum

cornerman opened this issue · 0 comments

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.0.0
info:
title: Multi-value array parameter
version: 0.0.1
paths:
/something:
  post:
    parameters:
      - name: paramTypes
        in: query
        schema:
          type: array
          items:
            type: string
            enum:
              - number
              - string
              - boolean
              - date

Is your feature request related to a problem?

With the above configuration, I will get a form in the swagger ui like this:
2023-04-20_17-30-41-

While this works to select single or multiple enum values, I cannot select the same value multiple times. It basically just allows sending a set of values. But in my case, there is the use-case of sending, e.g., a combination like this number,number,string,string as query parameters. But the UI does not let me select this - while it would be supported by the openapi spec and by the backend.

Describe the solution you'd like

I would like to specify that I want to have duplicates in my enum array and specify an order, which should give me a UI similar to what happens, when I would just use a plain string instead of enum in my schema. Like here:
2023-04-20_17-34-52-

I could not find anything in the docs, that would configure this.

Describe alternatives you've considered

My current workaround is to accept any string and parse it in the backend - without providing a proper schema in the openapi spec. But I would like to change that :)