From 6db283c03b0e461e7b1ca05b3a787c4c818ca7ef Mon Sep 17 00:00:00 2001 From: Cody Mikol Date: Tue, 29 Sep 2020 08:52:14 -0400 Subject: [PATCH] [FIX][CLI] handle null result messages (#7472) swagger-parser has the potential to return null for messages which will throw NPE on initialization of the validationMessages hashset. rather that allow this to happen we will assume that a null message collection represents an empty collection and continue. Fixes #7453 --- .../org/openapitools/codegen/config/CodegenConfigurator.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java index c5b03683569c..cf0de7a73882 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java @@ -518,7 +518,7 @@ public Context toContext() { SwaggerParseResult result = new OpenAPIParser().readLocation(inputSpec, authorizationValues, options); // TODO: Move custom validations to a separate type as part of a "Workflow" - Set validationMessages = new HashSet<>(result.getMessages()); + Set validationMessages = new HashSet<>(null != result.getMessages() ? result.getMessages() : new ArrayList<>()); OpenAPI specification = result.getOpenAPI(); // TODO: The line below could be removed when at least one of the issue below has been resolved. // https://github.com/swagger-api/swagger-parser/issues/1369