From 3bb412ae82565d1ecc5ee1edc808ee5c44a3e6e3 Mon Sep 17 00:00:00 2001 From: Lars Uffmann Date: Thu, 7 Apr 2022 18:22:54 +0200 Subject: [PATCH] Polishing --- .../org/openapitools/codegen/languages/SpringCodegen.java | 6 +++--- .../openapitools/codegen/java/spring/SpringCodegenTest.java | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java index 8494c5991f15..8bec1cc942f6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/SpringCodegen.java @@ -904,7 +904,7 @@ public Map postProcessAllModels(Map objs) for (ModelsMap modelsAttrs : objs.values()) { for (ModelMap mo : modelsAttrs.getModels()) { CodegenModel codegenModel = mo.getModel(); - Set additionalImports = new HashSet<>(); + Set inheritedImports = new HashSet<>(); Map propertyHash = new HashMap<>(codegenModel.vars.size()); for (final CodegenProperty property : codegenModel.vars) { propertyHash.put(property.name, property); @@ -923,7 +923,7 @@ public Map postProcessAllModels(Map objs) for (String imp: imports) { // Avoid dupes if (!codegenModel.getImports().contains(imp)) { - additionalImports.add(imp); + inheritedImports.add(imp); codegenModel.getImports().add(imp); } } @@ -932,7 +932,7 @@ public Map postProcessAllModels(Map objs) parentCodegenModel = parentCodegenModel.getParentModel(); } // There must be a better way ... - for (String imp: additionalImports) { + for (String imp: inheritedImports) { String qimp = importMapping().get(imp); if (qimp != null) { Map toAdd = new HashMap<>(); diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java index af87c6814c96..de2b775456bd 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/java/spring/SpringCodegenTest.java @@ -1026,6 +1026,7 @@ public void oneOf_allOf() throws IOException { // previous bugs assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/BarRef.java"), "atTypesuper.hashCode"); assertFileNotContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/BarRef.java"), "private String atBaseType"); + // imports for inherited properties assertFileContains(Paths.get(outputPath + "/src/main/java/org/openapitools/model/PizzaSpeziale.java"), "import java.math.BigDecimal"); }