OpenAPITools / OpenAPITools/openapi-generator
[BUG][JAVA] RequestBody multiple contents not working, only takes first one into consideration
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
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.
Is there any way for me to achieve what I want to achieve with current functionality? Or code needs to be written in order for this to be supported?
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
Start by reproducing the issue with the OpenAPI schema shown in the report and inspect how the Java generator processes multiple requestBody content types. Done means the generated client exposes the appropriate methods and models for the JSON, form-urlencoded, and multipart alternatives; no specific files or tests are named in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100