Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -13,6 +13,8 @@ public interface CodegenConfig extends ServerCodegenConfig {
String CODEGEN_SPEC = CODEGEN_TIME_CONFIG_PREFIX + ".spec";
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 @@ -29,4 +31,12 @@ static String getInputBaseDirPropertyName() {
static String getCodegenReactive() {
return CODEGEN_REACTIVE;
}

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 @@ -31,4 +31,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 @@ -38,8 +39,10 @@ public ApicurioCodegenWrapper(Config config, File outdir) {
public ApicurioCodegenWrapper(Config config, File outdir, JaxRsProjectSettings projectSettings) {
this.outdir = outdir;
this.projectSettings = projectSettings;
this.projectSettings.setJavaPackage(getBasePackage(config));
this.projectSettings.setReactive(getReactiveValue(config));
this.projectSettings.setJavaPackage(getBasePackage());
this.projectSettings.setReactive(getReactiveValue());
this.projectSettings.setUseJsr303(getUseBeanValidation());
this.projectSettings.setGenerateBuilders(getGenerateBuilders());
}

public void generate(Path openApiResource) throws CodeGenException {
Expand All @@ -65,6 +68,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 @@ -108,13 +112,23 @@ private void unzip(File fromZipFile, File toOutputDir) throws IOException {

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

private Boolean getReactiveValue(final Config config) {
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