From a3bdc5cf0943ba950f68399385c5c12e9a266beb Mon Sep 17 00:00:00 2001 From: William Cheng Date: Tue, 7 Nov 2023 22:28:32 +0800 Subject: [PATCH] better null check in getSchemaFromResponse --- .../java/org/openapitools/codegen/utils/ModelUtils.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index 8a4069ea5c2a..06c645a52549 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -1010,11 +1010,16 @@ public static Schema getSchemaFromRequestBody(RequestBody requestBody) { * Return the first defined Schema for a ApiResponse * * @param openAPI OpenAPI spec. - * @param response api response of the operation + * @param response API response of the operation * @return firstSchema */ public static Schema getSchemaFromResponse(OpenAPI openAPI, ApiResponse response) { - return getSchemaFromContent(getReferencedApiResponse(openAPI, response).getContent()); + ApiResponse result = getReferencedApiResponse(openAPI, response); + if (result == null) { + return null; + } else { + return getSchemaFromContent(result.getContent()); + } } /**