swagger-api / swagger-api/swagger-ui

Multi selection of query parameters with array of enum

Open
#8,583 5 comments 32 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

needs: UX/design input P3 pull-request-welcome type: bug
Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

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 :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the OpenAPI query parameter example in Swagger UI and start by tracing the form handling for array parameters with enum items. Done means the UI can accept duplicate enum values in a chosen order and the generated request preserves those repeated values.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.