Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<quarkus.version>3.24.4</quarkus.version>
<apicurio.version>1.2.1.Final</apicurio.version>
<apicurio.version>1.2.5.Final</apicurio.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 All @@ -63,14 +66,11 @@ public void generate(Path openApiResource) throws CodeGenException {

try (FileOutputStream fos = new FileOutputStream(zipFile);
FileInputStream openApiStream = new FileInputStream(openApiFile)) {
OpenApi2JaxRs generator = new OpenApi2JaxRs() {
{
config = new ConfigurableGenerationConfig(ApicurioCodegenWrapper.this.config);
}
};
OpenApi2JaxRs generator = new OpenApi2JaxRs();
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 +114,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

This file was deleted.