swagger-api / swagger-api/swagger-codegen
[BUG][JAVA] RequestBody multiple contents not working, only takes first one into consideration
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Hello guys.
I have this schema example:
post:
operationId: operation_1
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/RequestJson'
multipart/form-data:
schema:
$ref: '#/components/schemas/Request'
application/x-www-form-urlencoded:
schema:
$ref: '#/components/schemas/Request'
Which is valid and generated the correct UI on Swagger UI as seen below



The generated client should have 2 methods, one for application/json content-type that accepts RequestJson body, and another one for application/x-www-form-urlencoded and multipart/form-data content-types that accepts Request body.
This does not occur and instead we only have one method that accepts RequestJson body, even in model folder, there is no Request file, which means that it is only being taken into consideration the RequestJson Model.
Thank you
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 with the OpenAPI requestBody schema shown in the report and inspect the Java client generation entry point that processes multiple content types. Verify how application/json, multipart/form-data, and application/x-www-form-urlencoded are handled. Done means separate generated methods use RequestJson and Request, and both models are present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100