swagger-api / swagger-api/swagger-ui
When using oneOf with multipart/form-data the ability to upload a file is incorrectly replaced with a string.
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: Ubuntu 20.04.2 LTS
- Browser: Chrome
- Version: Version 92.0.4515.131 (Official Build) (64-bit)
- Method of installation: https://editor.swagger.io/
- Swagger-UI version: Whatever is used by the online editor (also effects the latest 3.52.0)
- Swagger/OpenAPI version: [OpenAPI 3.0]
Content & configuration
Example Swagger/OpenAPI definition:
openapi: 3.0.3
info:
title: SE Demo
description: Why doesn't this work?
version: 4.0.0
paths:
/does_work_common1:
post:
summary: This displays
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/Common1Combine"
responses:
default:
description: Doesn't matter
/does_work_common2:
post:
summary: This displays
requestBody:
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/Common2Combine"
responses:
default:
description: Doesn't matter
/does_not_work_combine:
post:
summary: This doesn't display
requestBody:
content:
multipart/form-data:
schema:
oneOf:
- $ref: "#/components/schemas/Common1Combine"
- $ref: "#/components/schemas/Common2Combine"
responses:
default:
description: Doesn't matter
components:
schemas:
Common1Combine:
allOf:
- $ref: "#/components/schemas/Common1"
- $ref: "#/components/schemas/File"
Common2Combine:
allOf:
- $ref: "#/components/schemas/Common2"
- $ref: "#/components/schemas/File"
Common1:
type: object
properties:
common:
type: object
properties:
a:
type: string
example: val1
b:
type: string
example: val2
Common2:
type: object
properties:
common:
type: object
properties:
c:
type: string
example: val1
d:
type: string
example: val2
File:
type: object
properties:
core:
type: string
description: A zip
format: binary
Describe the bug you're encountering
When using oneOf with multipart/form-data the ability to upload a file is incorrectly replaced with a string. When clicking does_work_common1's or does_work_common2's "Try it out" button, the common object is displayed and core allows for a file upload as expected. When clicking /does_not_work_combine's "Try it out" button the common object whole definition is json and does not allow for any file upload.
To reproduce...
Steps to reproduce the behavior:
- Go to 'https://editor.swagger.io/'
- Paste the above swagger yaml
- Click on '/does_not_work_combine'
- Click on 'Try it out'
- Scroll down to 'Request Body'
- See that 'core' is treated like a string and does not allow for a file upload.
Expected behavior
For oneOf to choose a ref and then display similar to /does_work_common1.
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
Begin by reproducing the issue in Swagger Editor with the YAML example and compare the working multipart/form-data schemas with the oneOf schema. Trace the request-body rendering path for oneOf/allOf and binary fields; done when the core field in /does_not_work_combine offers file upload behavior like the working endpoints.
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