From f8d4b3d8c721b5c918c01d94829b25d0da1245fe Mon Sep 17 00:00:00 2001 From: Karsten Thoms Date: Fri, 18 Feb 2022 17:25:40 +0100 Subject: [PATCH] [#11323] Fixed wrong clearing of CodegenModel#hasEnum field A CodegenModel's hasEnum property is set in addVars: cm.hasEnums = true; This state was cleared afterwards again. As one of its results the import for @JsonValue was not added for the model class in the Spring code generator, where 'model.hasEnums' was evaluated to false where it should be true. --- .../openapitools/codegen/DefaultCodegen.java | 3 +- .../java/spring/SpringCodegenTest.java | 28 +++++++++++++ .../test/resources/3_0/spring/issue_11323.yml | 41 +++++++++++++++++++ 3 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 modules/openapi-generator/src/test/resources/3_0/spring/issue_11323.yml diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java index ce8b3243795b..76ec33626275 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java @@ -5181,7 +5181,6 @@ protected void addVars(CodegenModel m, Map properties, List mandatory = required == null ? Collections.emptySet() : new TreeSet<>(required); @@ -5192,7 +5191,7 @@ protected void addVars(CodegenModel m, Map properties, List