[core] consider schema in headers when computing unused schemas (#2138)

This commit is contained in:
Jérémie Bresson
2019-02-13 09:19:05 +01:00
committed by William Cheng
parent b6c2266a14
commit 598bf0cd09
3 changed files with 49 additions and 6 deletions

View File

@@ -192,10 +192,20 @@ public class ModelUtils {
if (operation.getResponses() != null) {
for (ApiResponse r : operation.getResponses().values()) {
ApiResponse apiResponse = getReferencedApiResponse(openAPI, r);
if (apiResponse != null && apiResponse.getContent() != null) {
for (Entry<String, MediaType> e : apiResponse.getContent().entrySet()) {
if (e.getValue().getSchema() != null) {
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
if (apiResponse != null) {
if (apiResponse.getContent() != null) {
for (Entry<String, MediaType> e : apiResponse.getContent().entrySet()) {
if (e.getValue().getSchema() != null) {
visitSchema(openAPI, e.getValue().getSchema(), e.getKey(), visitedSchemas, visitor);
}
}
}
if (apiResponse.getHeaders() != null) {
for (Entry<String, Header> e : apiResponse.getHeaders().entrySet()) {
Header header = getReferencedHeader(openAPI, e.getValue());
if (header.getSchema() != null) {
visitSchema(openAPI, header.getSchema(), e.getKey(), visitedSchemas, visitor);
}
}
}
}