swagger-api / swagger-api/swagger-ui
"Send empty value" checkbox sends empty string instead of empty array for array type parameters in multipart/form-data
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 26.3 (arm64)
- Browser: Brave 1.88.136 (Chromium 146.0.7680.164)
- Method of installation: Used via FastAPI's built-in
/docsendpoint (loads swagger-ui from CDN) - Swagger-UI version: 5.x (latest, loaded from
https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/) - Swagger/OpenAPI version: OpenAPI 3.1.0
Content & configuration
Example Swagger/OpenAPI definition:
paths:
/api/test/import-file:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
files:
type: array
items:
type: string
Swagger-UI configuration options:
// Default FastAPI /docs configuration (no custom options)
Describe the bug you're encountering
When the "Send empty value" checkbox is checked for an array<string> parameter in a multipart/form-data request, Swagger UI sends an empty string (-F 'files=') instead of either omitting the field entirely or sending an empty array.
This causes the server to respond with 422 Unprocessable Entity, because an empty string is not a valid value for the expected array type.
The generated curl command:
curl -X 'POST' \
'http://localhost:8088/api/test/import-file' \
-H 'accept: application/json' \
-H 'Content-Type: multipart/form-data' \
-F 'files='
Server response:
{
"detail": [
{
"loc": [
"body",
"files"
]
}
]
}
To reproduce...
Steps to reproduce the behavior:
- Define a POST endpoint that accepts
multipart/form-datawith anarray<string>parameter (e.g.,files). - Open Swagger UI and navigate to the endpoint.
- Do not add any string items to the
filesfield. - Check the "Send empty value" checkbox for the
filesparameter. - Click Execute.
- Observe the generated curl:
-F 'files='sends an empty string. - Server responds with 422 Unprocessable Entity.
Expected behavior
When "Send empty value" is checked for an array type parameter, Swagger UI should either:
- Omit the field entirely from the request body, or
- Send it as an empty array (no value entries)
It should not send an empty string, as that is a type mismatch (string vs array).
Screenshots
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 from the Swagger UI /docs flow and reproduce the multipart/form-data request using the provided OpenAPI schema and the "Send empty value" checkbox. Trace how the files array is serialized into the generated curl command, then verify that the executed request no longer sends an empty string and that the documented reproduction avoids the 422 response.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 65/100