swagger-api / swagger-api/swagger-ui
Missing type:object in multipart causes example to be in json, not file uploads
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)
- Swagger-UI version: "3.17.0"
- Swagger/OpenAPI version: OAS 3
Content & configuration
ie: a mutlipart/form object, that doesn't include type: object
post:
summary: Create an item
requestBody:
content:
multipart/form-data:
schema:
# type: object # <-- makes it work
properties: # Request parts should NOT be rendered as JSON
image:
type: string
format: binary
Describe the bug you're encountering
The body component creates a json example instead of a list of file upload buttons
To reproduce...
Steps to reproduce the behavior:
View a spec as above.
Expected behavior
Try it out form renders with file upload parameters
Screenshots
Actual

Expected

Fix/Notes
Bam: https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/oas3/components/request-body.jsx#L32
Doesn't use inference (ie: if properties, then its an object )
Aternatively ( outside issue ) we make this a validation error.
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 src/core/plugins/oas3/components/request-body.jsx at the referenced line and reproduce the behavior with the linked multipart/form-data example. The change is done when a schema with properties but no explicit type: object renders file upload controls in the Try it out form instead of a JSON example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100