Skip to content

Commit 87c7707

Browse files
Choobzwing328
authored andcommitted
[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)
1 parent 4e47426 commit 87c7707

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AvroSchemaCodegen.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,8 @@ public AvroSchemaCodegen() {
4343

4444
outputFolder = "generated-code/avro-schema";
4545
modelTemplateFiles.put("model.mustache", ".avsc");
46-
apiPackage = "api";
47-
modelPackage = "model";
46+
// Force the model package to the package name so import can be fully qualified
47+
modelPackage = packageName;
4848
importMapping.clear();
4949
embeddedTemplateDir = templateDir = AVRO;
5050

@@ -81,10 +81,12 @@ public void processOpts() {
8181
super.processOpts();
8282
if (additionalProperties.containsKey(CodegenConstants.PACKAGE_NAME)) {
8383
packageName = (String) additionalProperties.get(CodegenConstants.PACKAGE_NAME);
84+
85+
// Force the model package to the package name so import can be fully qualified
86+
modelPackage = packageName;
8487
}
8588

8689
additionalProperties.put("packageName", packageName);
87-
8890
}
8991

9092
@Override
@@ -132,4 +134,4 @@ public String escapeQuotationMark(String input) {
132134
return input;
133135
}
134136

135-
}
137+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
4.1.1-SNAPSHOT
1+
4.2.0-SNAPSHOT

samples/openapi3/schema/petstore/avro-schema/InlineObject1.avsc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
{
1313
"name": "file",
14-
"type": ["null", "model.File"],
14+
"type": ["null", ],
1515
"doc": "file to upload"
1616
}
1717
]

0 commit comments

Comments
 (0)