better null check for response (#9105)

This commit is contained in:
William Cheng 2021-03-29 12:05:17 +08:00 committed by GitHub
parent ab6c6962c2
commit 8d372fa66a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -813,11 +813,13 @@ public class DefaultCodegen implements CodegenConfig {
schemas.put(opId, requestSchema); schemas.put(opId, requestSchema);
} }
// process all response bodies // process all response bodies
for (Map.Entry<String, ApiResponse> ar : op.getValue().getResponses().entrySet()) { if (op.getValue().getResponses() != null) {
ApiResponse a = ModelUtils.getReferencedApiResponse(openAPI, ar.getValue()); for (Map.Entry<String, ApiResponse> ar : op.getValue().getResponses().entrySet()) {
Schema responseSchema = ModelUtils.getSchemaFromResponse(a); ApiResponse a = ModelUtils.getReferencedApiResponse(openAPI, ar.getValue());
if (responseSchema != null) { Schema responseSchema = ModelUtils.getSchemaFromResponse(a);
schemas.put(opId + ar.getKey(), responseSchema); if (responseSchema != null) {
schemas.put(opId + ar.getKey(), responseSchema);
}
} }
} }
} }