Skip to content

Commit 2fe954a

Browse files
committed
Specifying package for each api file should be optional.
1 parent 195b6b6 commit 2fe954a

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public abstract class OpenApiGeneratorCodeGenBase implements CodeGenProvider {
2626
static final String YML = ".yml";
2727
static final String JSON = ".json";
2828

29+
private static final String DEFAULT_PACKAGE = "org.openapi.quarkus";
30+
2931
@Override
3032
public String inputDirectory() {
3133
return "openapi";
@@ -43,8 +45,9 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
4345
.map(Path::toString)
4446
.filter(s -> s.endsWith(this.inputExtension()))
4547
.map(Path::of).forEach(openApiFilePath -> {
46-
final String basePackage = getRequiredIndexedProperty(
47-
getResolvedBasePackageProperty(openApiFilePath), context);
48+
final String basePackage = context.config()
49+
.getOptionalValue(getResolvedBasePackageProperty(openApiFilePath), String.class)
50+
.orElse(DEFAULT_PACKAGE);
4851
final OpenApiClientGeneratorWrapper generator = new OpenApiClientGeneratorWrapper(
4952
openApiFilePath.normalize(), outDir)
5053
.withApiPackage(basePackage + API_PKG_SUFFIX)
@@ -59,9 +62,4 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
5962
}
6063
return false;
6164
}
62-
63-
private String getRequiredIndexedProperty(final String propertyKey, final CodeGenContext context) {
64-
// this is how we get a required property. The configSource will handle the exception for us.
65-
return context.config().getValue(propertyKey, String.class);
66-
}
6765
}

0 commit comments

Comments
 (0)