swagger-api / swagger-api/swagger-ui
swagger ui adds extra quotes when form submitted as 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 |
|---|---|
| Bug or feature request? | Bug |
| Which Swagger/OpenAPI version? | 2 |
| Which Swagger-UI version? | 3.9.2 |
| How did you install Swagger-UI? | |
| Which browser & version? | |
| Which operating system? |
Demonstration API definition
swagger: '2.0'
info:
version: 0.0.0
title: Simple API
host: 'localhost'
paths:
/user/register:
post:
consumes:
- "multipart/form-data"
parameters:
- in: "formData"
name: "username"
required: false
type: "string"
allowEmptyValue: false
- in: "formData"
name: "image"
description: "User image"
required: false
type: "file"
- in: "formData"
name: "gender"
description: "Gender: {male: 1, female: 2}"
required: false
items:
type: "string"
allowEmptyValue: false
enum:
- "2"
- "1"
type: "array"
allowEmptyValue: false
When I submit this form I see this curl command below response section:
curl -X POST "http://localhost/user/register" -H "accept: application/json" -H "Content-Type: multipart/form-data" -F "username=john" -F "gender="2""
Please note "gender="2"" <- extra quotes here
On the backend side submitted form always invalid because these extra quotes. If I change consumes to application/x-www-form-urlencoded then everything is fine but I can not upload image in that case.
What do I do wrong?
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
Reproduce the issue in Swagger UI 3.9.2 using the provided Swagger 2.0 definition and multipart/form-data submission. Start by tracing how the form parameters are serialized into the displayed curl command. Done means the gender value is emitted without extra quotes while file upload continues to work, with a regression test covering the case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100