Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>3.20.1</quarkus.version>
<apicurio.version>1.2.1.Final</apicurio.version>
<apicurio.version>1.2.5.Final</apicurio.version>
<quarkus.version>3.25.0</quarkus.version>
<version.com.github.javaparser>3.27.0</version.com.github.javaparser>
<version.org.assertj>3.27.3</version.org.assertj>
<version.org.eclipse.microprofile.fault-tolerance>4.1.2</version.org.eclipse.microprofile.fault-tolerance>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public interface CodegenConfig extends ServerCodegenConfig {
String INPUT_BASE_DIR = CODEGEN_TIME_CONFIG_PREFIX + ".input-base-dir";
String CODEGEN_REACTIVE = CODEGEN_TIME_CONFIG_PREFIX + ".reactive";
String GENERATE_BUILDERS = CODEGEN_TIME_CONFIG_PREFIX + ".builders";
String CODEGEN_BEAN_VALIDATION = CODEGEN_TIME_CONFIG_PREFIX + ".bean-validation";

static String getBasePackagePropertyName() {
return CODEGEN_BASE_PACKAGE;
Expand All @@ -34,4 +35,8 @@ static String getCodegenReactive() {
static String getGenerateBuilders() {
return GENERATE_BUILDERS;
}

static String getUseBeanValidation() {
return CODEGEN_BEAN_VALIDATION;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,10 @@ public interface ServerCodegenConfig {
*/
@WithDefault(DEFAULT_PACKAGE)
Optional<String> basePackage();

/**
* Whether it must generate resources and beans using bean validation (JSR-303).
*/
@WithDefault("false")
boolean useBeanValidation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import io.apicurio.hub.api.codegen.JaxRsProjectSettings;
import io.apicurio.hub.api.codegen.OpenApi2JaxRs;
import io.quarkiverse.openapi.server.generator.deployment.CodegenConfig;
import io.quarkus.bootstrap.prebuild.CodeGenException;

public class ApicurioCodegenWrapper {
Expand All @@ -42,6 +43,8 @@ public ApicurioCodegenWrapper(Config config, File outdir, JaxRsProjectSettings p
this.projectSettings = projectSettings;
this.projectSettings.setJavaPackage(getBasePackage());
this.projectSettings.setReactive(getReactiveValue());
this.projectSettings.setUseJsr303(getUseBeanValidation());
this.projectSettings.setGenerateBuilders(getGenerateBuilders());
}

public void generate(Path openApiResource) throws CodeGenException {
Expand Down Expand Up @@ -71,6 +74,7 @@ public void generate(Path openApiResource) throws CodeGenException {
generator.setSettings(projectSettings);
generator.setUpdateOnly(true);
generator.setOpenApiDocument(openApiStream);

log.info("Generating code...");
generator.generate(fos);
} catch (Exception e) {
Expand Down Expand Up @@ -114,13 +118,23 @@ private void unzip(File fromZipFile, File toOutputDir) throws IOException {

private String getBasePackage() {
return config
.getOptionalValue(getBasePackagePropertyName(), String.class)
.getOptionalValue(CodegenConfig.getBasePackagePropertyName(), String.class)
.orElse(DEFAULT_PACKAGE);
}

private Boolean getReactiveValue() {
return config
.getOptionalValue(getCodegenReactive(), Boolean.class)
.getOptionalValue(CodegenConfig.getCodegenReactive(), Boolean.class)
.orElse(Boolean.FALSE);
}

private Boolean getUseBeanValidation() {
return config.getOptionalValue(CodegenConfig.getUseBeanValidation(), Boolean.class)
.orElse(Boolean.FALSE);
}

private Boolean getGenerateBuilders() {
return config.getOptionalValue(CodegenConfig.getGenerateBuilders(), Boolean.class)
.orElse(Boolean.FALSE);
}

Expand Down
Loading