Skip to content

Commit a7a5c02

Browse files
Merge pull request #24 from fjtirado/optional_package
Specifying package for each api file should be optional.
2 parents d2b1f24 + 2fe954a commit a7a5c02

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)
@@ -60,9 +63,4 @@ public boolean trigger(CodeGenContext context) throws CodeGenException {
6063
}
6164
return false;
6265
}
63-
64-
private String getRequiredIndexedProperty(final String propertyKey, final CodeGenContext context) {
65-
// this is how we get a required property. The configSource will handle the exception for us.
66-
return context.config().getValue(propertyKey, String.class);
67-
}
6866
}

0 commit comments

Comments
 (0)