mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-04-27 00:24:16 +00:00
Consider '$ref' for consumes and produces in CodegenOperation (#180)
This commit is contained in:
+8
-6
@@ -2097,13 +2097,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
op.isDeprecated = operation.getDeprecated();
|
||||
}
|
||||
|
||||
addConsumesInfo(operation, op);
|
||||
addConsumesInfo(openAPI, operation, op);
|
||||
|
||||
if (operation.getResponses() != null && !operation.getResponses().isEmpty()) {
|
||||
ApiResponse methodResponse = findMethodResponse(operation.getResponses());
|
||||
for (String key : operation.getResponses().keySet()) {
|
||||
ApiResponse response = operation.getResponses().get(key);
|
||||
addProducesInfo(response, op);
|
||||
addProducesInfo(openAPI, response, op);
|
||||
CodegenResponse r = fromResponse(key, response);
|
||||
r.hasMore = true;
|
||||
if (r.baseType != null &&
|
||||
@@ -3853,12 +3853,13 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
}
|
||||
}
|
||||
|
||||
private void addConsumesInfo(Operation operation, CodegenOperation codegenOperation) {
|
||||
if (operation.getRequestBody() == null || operation.getRequestBody().getContent() == null || operation.getRequestBody().getContent().isEmpty()) {
|
||||
private void addConsumesInfo(OpenAPI openAPI, Operation operation, CodegenOperation codegenOperation) {
|
||||
RequestBody requestBody = ModelUtils.getReferencedRequestBody(openAPI, operation.getRequestBody());
|
||||
if (requestBody == null || requestBody.getContent() == null || requestBody.getContent().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> consumes = operation.getRequestBody().getContent().keySet();
|
||||
Set<String> consumes = requestBody.getContent().keySet();
|
||||
List<Map<String, String>> mediaTypeList = new ArrayList<>();
|
||||
int count = 0;
|
||||
for (String key : consumes) {
|
||||
@@ -3921,7 +3922,8 @@ public class DefaultCodegen implements CodegenConfig {
|
||||
return ModelUtils.getReferencedSchema(openAPI, schema) != null;
|
||||
}
|
||||
|
||||
private void addProducesInfo(ApiResponse response, CodegenOperation codegenOperation) {
|
||||
private void addProducesInfo(OpenAPI openAPI, ApiResponse inputResponse, CodegenOperation codegenOperation) {
|
||||
ApiResponse response = ModelUtils.getReferencedApiResponse(openAPI, inputResponse);
|
||||
if (response == null || response.getContent() == null || response.getContent().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user