From 87c77076ef0ea85adf738fcfd1e00ba8e5986a7e Mon Sep 17 00:00:00 2001 From: Perennes Date: Wed, 9 Oct 2019 09:46:29 +0200 Subject: [PATCH] [AVRO] Fix the package handling for the avro generator (#3987) (#4078) * [AVRO] Fix the package handling for the avro generator (#3987) Also fix an issue with the outputFolder that wasn't overridable through opts * Update sample files through avro-petstore.sh There's an issue with inlined object but it's already present with the previous commit * Revert the fix on outputFolder (not a bug) --- .../codegen/languages/AvroSchemaCodegen.java | 10 ++++++---- .../petstore/avro-schema/.openapi-generator/VERSION | 2 +- .../schema/petstore/avro-schema/InlineObject1.avsc | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AvroSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AvroSchemaCodegen.java index 0da3aa03787..9ea0d8a7dd7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AvroSchemaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AvroSchemaCodegen.java @@ -43,8 +43,8 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig { outputFolder = "generated-code/avro-schema"; modelTemplateFiles.put("model.mustache", ".avsc"); - apiPackage = "api"; - modelPackage = "model"; + // Force the model package to the package name so import can be fully qualified + modelPackage = packageName; importMapping.clear(); embeddedTemplateDir = templateDir = AVRO; @@ -81,10 +81,12 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig { super.processOpts(); if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) { packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME); + + // Force the model package to the package name so import can be fully qualified + modelPackage = packageName; } additionalProperties.put("packageName", packageName); - } @Override @@ -132,4 +134,4 @@ public class AvroSchemaCodegen extends DefaultCodegen implements CodegenConfig { return input; } -} +} \ No newline at end of file diff --git a/samples/openapi3/schema/petstore/avro-schema/.openapi-generator/VERSION b/samples/openapi3/schema/petstore/avro-schema/.openapi-generator/VERSION index 2f81801b794..c3a2c7076fa 100644 --- a/samples/openapi3/schema/petstore/avro-schema/.openapi-generator/VERSION +++ b/samples/openapi3/schema/petstore/avro-schema/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.1-SNAPSHOT \ No newline at end of file +4.2.0-SNAPSHOT \ No newline at end of file diff --git a/samples/openapi3/schema/petstore/avro-schema/InlineObject1.avsc b/samples/openapi3/schema/petstore/avro-schema/InlineObject1.avsc index 322dae3751e..683c4029532 100644 --- a/samples/openapi3/schema/petstore/avro-schema/InlineObject1.avsc +++ b/samples/openapi3/schema/petstore/avro-schema/InlineObject1.avsc @@ -11,7 +11,7 @@ }, { "name": "file", - "type": ["null", "model.File"], + "type": ["null", ], "doc": "file to upload" } ]