swagger-api / swagger-api/swagger-ui
multipart/form-data should support custom content-type selection.
Open
Nobody has claimed this yet.
cat: try-it-out
specification: 3.x
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
Content & configuration
Swagger/OpenAPI definition:
paths:
/analysis/api/stores:
post:
responses:
'201':
$ref: '#/components/responses/CONTINUE'
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: '#/components/schemas/Child'
encoding: # The same level as schema
test: # Property name (see schema)
contentType: application/json
test2: # Property name (see schema)
contentType: application/xml
tags:
- Learning
info:
title: test api
version: v1
tags:
- name: Feature Request
description: respect multipart child content-type
openapi: 3.0.2
components:
schemas:
Error:
type: object
properties:
message:
type: string
description: Error message
errors:
type: object
description: Errors
status:
type: string
description: Error name
code:
type: integer
format: int32
description: Error code
Base:
type: object
properties:
company:
type: string
Child:
type: object
properties:
test:
type: array
items:
$ref: '#/components/schemas/Base'
test2:
type: array
items:
$ref: '#/components/schemas/Base'
responses:
CONTINUE:
description: Continue
content:
application/json:
schema:
type: object
properties:
error:
type: string
Is your feature request related to a problem?
It is currently not possible to define specific Content-Type for a request part via encoding/{property-name}/contentType.
Describe the solution you'd like
- Each request part should have a ContentType Component on top of it to select the content-type.
- The contentTypes prop would be the encoding/{property-name}/contentType splitted and trimmed via seperator char
,for multiple content-type possibilities. - Curlify needs to be adjusted.
- Introduced with #6461 the sample generation for multipart could then use the selected conten-type for generation.
- By default, the Content-Type of individual request parts is set automatically according to the type of the schema properties that describe the request parts:
| Schema Property Type | Content-Type |
|---|---|
| Primitive or array of primitives | text/plain |
| Complex value or array of complex values | application/json |
| String in the binary or base64 format | application/octet-stream |
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 tracing multipart request handling through src/core/components/content-type.jsx, src/core/curlify.js, and src/core/json-schema-components.jsx. Check how encoding/{property-name}/contentType is parsed and passed into request-part rendering and curl generation. Done means custom content types are selectable, used for multipart samples, and reflected in generated curl commands.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100