forked from loafle/openapi-generator-original
normalizer: minor refactoring in responses (#16988)
This commit is contained in:
parent
588e2598f6
commit
339596aeec
@ -189,7 +189,6 @@ public class OpenAPINormalizer {
|
||||
|
||||
normalizePaths();
|
||||
normalizeComponentsSchemas();
|
||||
normalizeComponentsResponses();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,9 +319,8 @@ public class OpenAPINormalizer {
|
||||
if (responsesEntry.getValue() == null) {
|
||||
continue;
|
||||
} else {
|
||||
normalizeContent(responsesEntry.getValue().getContent());
|
||||
normalizeHeaders(responsesEntry.getValue().getHeaders());
|
||||
|
||||
normalizeContent(ModelUtils.getReferencedApiResponse(openAPI, responsesEntry.getValue()).getContent());
|
||||
normalizeHeaders(ModelUtils.getReferencedApiResponse(openAPI, responsesEntry.getValue()).getHeaders());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -365,33 +363,6 @@ public class OpenAPINormalizer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes responses in components
|
||||
*/
|
||||
private void normalizeComponentsResponses() {
|
||||
Map<String, ApiResponse> schemas = openAPI.getComponents().getResponses();
|
||||
if (schemas == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<String> schemaNames = new ArrayList<String>(schemas.keySet());
|
||||
for (String schemaName : schemaNames) {
|
||||
ApiResponse schema = schemas.get(schemaName);
|
||||
if (schema == null) {
|
||||
LOGGER.warn("{} not fount found in openapi/components/schemas.", schemaName);
|
||||
} else {
|
||||
Content content = ModelUtils.getReferencedApiResponse(openAPI, schema).getContent();
|
||||
if (content == null || content.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<String, MediaType> entry : content.entrySet()) {
|
||||
Schema entryResult = normalizeSchema(entry.getValue().getSchema(), new HashSet<>());
|
||||
entry.getValue().setSchema(entryResult);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes a schema
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user