OpenAPITools / OpenAPITools/openapi-generator
[Question]: RequestBody & Multiple Content-Types
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Support for multiple content-types in RequestBody
In the documentation can be find a OpenApi example with multiple content-types in requestBody. But in the code is a index with 0 fix implement.
When is it planned to handling multiple content-types in requestBody ?
paths:
/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX:
post:
summary: Post a message to Slack
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/Message'
application/x-www-form-urlencoded:
schema:
type: object
properties:
payload: # <--- form field that contains the JSON message
$ref: '#/components/schemas/Message'
encoding:
payload:
contentType: application/json
protected String getContentType(RequestBody requestBody) {
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
return null;
}
return new ArrayList<>(requestBody.getContent().keySet()).get(0);
}
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 in modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java, especially getContentType(RequestBody), and compare it with the multiple-content-type RequestBody example in the issue. Determine the expected generated behavior for each content type and identify the affected generators before defining completion criteria and tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100