swagger-api / swagger-api/swagger-client
Incorrect request body when 'multipart/mixed' is used
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2.7k
- Forks
- 765
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 6
Description
Q&A (please complete the following information)
- OS: Windows, macOS
- Environment: Nodejs 12, any browser
- Method of installation: npm
- Swagger-Client version: 3.18
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
Swagger/OpenAPI definition:
requestBody:
description: .....
content:
application/json:
schema:
$ref: 'certificate.yaml#/Certificate'
multipart/mixed; boundary=BOUNDARY:
schema:
type: object
properties:
CertificateBody:
$ref: '#/Certificate'
CerificateContent:
type: string
format: binary
required: true
Swagger-Client usage:
Default configuration, just use a definition containing multipart/mixed
Describe the bug you're encountering
Multipart/mixed request is broken. When used, the request body is JSON and not multipart. It was working prior to version 3.10.6. All later versions including the latest have the same behavior.
To reproduce...
Steps to reproduce the behavior:
- Compose a yaml using OpenAPI 3.0 and use multipart/mixed content type. Use two parts - one JSON, and the other string/binary.
- Add the yaml in swagger url
- Fill the JSON/file parts of the request and execute
Expected behavior
The request body should be multipart.
Current behavior
The request body is JSON and the request fails.
Screenshots
Additional context or thoughts
I think the issue is caused by this commit: https://github.com/swagger-api/swagger-js/commit/651e85713c90345508c3d32bfef63cba7fce7c5c
The condition for multipart/ is changed to 'multipart/form-data' which results in non-working multipart/mixed.
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 with the OpenAPI 3.0 definition described in the issue, using one JSON part and one string/binary part. Compare multipart handling with the linked commit and verify that the generated request body is multipart/mixed rather than JSON; the issue is resolved when the described request executes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100