normalizer: minor refactoring in responses (#16988)

This commit is contained in:
William Cheng 2023-11-05 18:04:40 +08:00 committed by GitHub
parent 588e2598f6
commit 339596aeec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
*