swagger-api / swagger-api/swagger-ui
A non-required array query param with no value is still passed
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: macOS
- Browser: chrome
- Version: 114.0.5735.198
- Method of installation: dist assets from tapir (Scala lib)
- Swagger-UI version: 3.10.0
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: app
version: 1.0.0
paths:
/app/foo/bar:
get:
description: Fetch data
operationId: getApp-fooBar
parameters:
- name: myArray
in: query
description: description
required: false
schema:
type: array
items:
$ref: '#/components/schemas/Item'
example:
- 1
- 2
Swagger-UI configuration options (constrainted by SwaggerUI jar, see https://github.com/softwaremill/tapir/issues/874)
Screenshots
query tried by SwaggerUI:
curl -X 'GET' \
'http://localhost:8080/app/foo/bar?myArray=' \
-H 'accept: application/json'
How can we help?
When trying the GET route in Swagger UI, selecting "--" as seen in the screenshot, the parameter is still passed in the query, causing a problem on the server side. As far as I understand since the param is not required, selecting "--" should just not pass the param, right?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in Swagger UI's Try it out flow using the provided OpenAPI 3.0 definition and reproduce the GET request for the optional array parameter. Trace how selecting "--" becomes myArray= in the generated curl request; done means the optional parameter is omitted when no value is selected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100