swagger-api / swagger-api/swagger-ui

"Allow Empty Value" only works before you select then unselect something from the array list

Open
#10,941 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
29k
Forks
9.3k
Avg merge
2d 23h
Merged PRs (30d)
25

Description

Q&A (please complete the following information)
  • OS: ALL
  • Browser: ALL
  • Version: ALL
  • Method of installation: ALL
  • Swagger-UI version:Latest/5.32.8
  • Swagger/OpenAPI version: Swagger 2 OpenAPI 3.1
Content & configuration

Allow empty only works once. If you select something from the list, and unselect, the empty query parameter does not get attached.

Example Swagger/OpenAPI definition:

{
                        "name": "status",
                        "in": "query",
                        "description": "Find Something. Send status= to clear the status filter.",
                        "style": "form",
                        "explode": true,
                        "allowEmptyValue": true,
                        "schema": {
                            "anyOf": [
                                {
                                    "type": "array",
                                    "items": {
                                        "type": "string",
                                        "description": "Something",
                                        "enum": [
                                            "FOO",
                                            "BAR"
                                        ]
                                    }
                                },
                                {
                                    "type": "null"
                                }
                                
                            ]
                        }
                    },

Swagger-UI configuration options:
Defaults.

To reproduce...

Steps to reproduce the behavior:

  1. Have an api-doc similar/including to what I shared above.
  2. Check the "Allow Empty" checkbox
  3. Send a request and see that it works / status= is sent.
  4. Select then unselect any item in the list. It should be empty again.
  5. See that status= is NOT sent.
Expected behavior

status= should continue to be sent after selecting/unselecting everything.

Screenshots
Image
Additional context or thoughts

I have already fixed this here: https://github.com/swagger-api/swagger-ui/pull/10940 :)

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

Review pull request #10940 and reproduce the issue with the provided Swagger/OpenAPI definition. Start by checking the Allow Empty flow for an array query parameter, then verify that selecting and unselecting all values still sends status= as expected.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, openapi
Domain
frontend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.