swagger-api / swagger-api/swagger-ui
Arrays are sent incorrectly 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: Windows 11
- Browser: Firefox
- Version: 130
- Method of installation: npm
- Swagger-UI version: 5.18.2
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.1
info:
title: DotNet9WebApi
version: '1.0'
paths:
/WeatherForecast/post:
post:
tags:
- DotNet9WebApi
requestBody:
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/PostBody'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/PostBody'
responses:
'200':
description: OK
components:
schemas:
PostBody:
type: object
properties:
content:
type: string
nullable: true
intArrProp:
type: array
items:
type: integer
format: int32
nullable: true
additionalProperties: false
Describe the bug you're encountering
When submitting an array as multipart/form-data content, the values are sent as a comma-separated list, instead of as multiple form parts with the same name.
To reproduce...
Steps to reproduce the behavior:
- Go to https://editor-next.swagger.io/
- Paste the above sample YAML into the editor
- Try out the
/WeatherForecast/postendpoint - Add 2 or more items into the
intArrProparray using theAdd integer itembutton - Click
Executeand observe the resultingcurl
Expected behavior
The curl should look like this:
curl -X 'POST' \
'https://editor-next.swagger.io/WeatherForecast/post' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'content=string' \
-F 'intArrProp=1' \
-F 'intArrProp=2' \
-F 'intArrProp=3'
Actual behavior
The curl looks like this:
curl -X 'POST' \
'https://editor-next.swagger.io/WeatherForecast/post' \
-H 'accept: */*' \
-H 'Content-Type: multipart/form-data' \
-F 'content=string' \
-F 'intArrProp=1,2,3'
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 by reproducing the request in editor-next.swagger.io with the supplied OpenAPI 3.0.1 definition and inspect the multipart/form-data request generation. Done means the generated curl sends each intArrProp value as a separate repeated -F form part rather than one comma-separated value.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, openapi
- Domain
- api, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100