-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Milestone
Description
In 3.0.0_enhancements
branch, I noticed this line:
swagger-codegen/modules/swagger-codegen/src/main/java/io/swagger/codegen/DefaultCodegen.java
Lines 3446 to 3450 in 112c1f0
protected String getContentType(RequestBody requestBody) { | |
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) { | |
return null; | |
} | |
return new ArrayList<>(requestBody.getContent().keySet()).get(0); |
This appears to select the only the first content-type for a RequestBody.
What can we expect will be the plan for code generation, for the RequestBody for cases 1) and 2) below?
1) Multiple content-types with the same Schema
"requestBody": {
"description": "Pet object that needs to be added to the store",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Pet"
}
}
},
"required": false
},
2) Multiple content-types with different Schemas
Schemas can vary by media type.
https://swagger.io/docs/specification/describing-request-body/
"requestBody": {
"description": "Pet object that needs to be added to the store",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Cat"
}
},
"application/xml": {
"schema": {
"$ref": "#/components/schemas/Dog"
}
}
},
"required": false
},