Skip to content

Commit 02851cc

Browse files
committed
Add bean validation feature from apicurio-codegen 1.2.5.Final
1 parent d27f5b3 commit 02851cc

File tree

8 files changed

+42
-39
lines changed

8 files changed

+42
-39
lines changed

.all-contributorsrc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,15 @@
455455
"contributions": [
456456
"code"
457457
]
458+
},
459+
{
460+
"login": "cmoine-swi",
461+
"name": "Christophe Moine",
462+
"avatar_url": "https://avatars.githubusercontent.com/u/180930830?v=4",
463+
"profile": "https://github.com/cmoine-swi",
464+
"contributions": [
465+
"code"
466+
]
458467
}
459468
],
460469
"contributorsPerLine": 7,

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<br>
1111

1212
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
13-
[![All Contributors](https://img.shields.io/badge/all_contributors-48-orange.svg?style=flat-square)](#contributors-)
13+
[![All Contributors](https://img.shields.io/badge/all_contributors-49-orange.svg?style=flat-square)](#contributors-)
1414
<!-- ALL-CONTRIBUTORS-BADGE:END -->
1515
[![Build](<https://img.shields.io/github/actions/workflow/status/quarkiverse/quarkus-openapi-generator/build.yml?branch=main&logo=GitHub&style=flat-square>)](https://github.com/quarkiverse/quarkus-openapi-generator/actions?query=workflow%3ABuild)
1616
[![Maven Central](https://img.shields.io/maven-central/v/io.quarkiverse.openapi.generator/quarkus-openapi-generator.svg?label=Maven%20Central&style=flat-square)](https://search.maven.org/artifact/io.quarkiverse.openapi.generator/quarkus-openapi-generator)
@@ -109,6 +109,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
109109
<td align="center" valign="top" width="14.28%"><a href="https://dev.to/dellamas"><img src="https://avatars.githubusercontent.com/u/80655200?v=4?s=100" width="100px;" alt="Luis Fabrício De Llamas"/><br /><sub><b>Luis Fabrício De Llamas</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-openapi-generator/commits?author=dellamas" title="Documentation">📖</a> <a href="https://github.com/quarkiverse/quarkus-openapi-generator/commits?author=dellamas" title="Tests">⚠️</a></td>
110110
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jghagemann"><img src="https://avatars.githubusercontent.com/u/42047435?v=4?s=100" width="100px;" alt="João Guilherme Hagemann"/><br /><sub><b>João Guilherme Hagemann</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-openapi-generator/commits?author=jghagemann" title="Documentation">📖</a></td>
111111
<td align="center" valign="top" width="14.28%"><a href="https://github.com/omatheusmesmo"><img src="https://avatars.githubusercontent.com/u/99829531?v=4?s=100" width="100px;" alt="Matheus Oliveira da Silva"/><br /><sub><b>Matheus Oliveira da Silva</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-openapi-generator/commits?author=omatheusmesmo" title="Code">💻</a></td>
112+
<td align="center" valign="top" width="14.28%"><a href="https://github.com/cmoine-swi"><img src="https://avatars.githubusercontent.com/u/180930830?v=4?s=100" width="100px;" alt="Christophe Moine"/><br /><sub><b>Christophe Moine</b></sub></a><br /><a href="https://github.com/quarkiverse/quarkus-openapi-generator/commits?author=cmoine-swi" title="Code">💻</a></td>
112113
</tr>
113114
</tbody>
114115
</table>

moqu/core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<name>Quarkus :: Openapi Generator :: Moqu :: Core</name>
1212

1313
<properties>
14-
<commons.io.version>2.19.0</commons.io.version>
14+
<commons.io.version>2.20.0</commons.io.version>
1515
</properties>
1616

1717
<dependencies>

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
<maven.compiler.release>17</maven.compiler.release>
2929
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3030
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
31-
<quarkus.version>3.24.3</quarkus.version>
32-
<apicurio.version>1.2.1.Final</apicurio.version>
31+
<quarkus.version>3.24.4</quarkus.version>
32+
<apicurio.version>1.2.5.Final</apicurio.version>
3333
<version.com.github.javaparser>3.27.0</version.com.github.javaparser>
3434
<version.org.assertj>3.27.3</version.org.assertj>
3535
<version.org.eclipse.microprofile.fault-tolerance>4.1.2</version.org.eclipse.microprofile.fault-tolerance>

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/CodegenConfig.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public interface CodegenConfig extends ServerCodegenConfig {
1414
String INPUT_BASE_DIR = CODEGEN_TIME_CONFIG_PREFIX + ".input-base-dir";
1515
String CODEGEN_REACTIVE = CODEGEN_TIME_CONFIG_PREFIX + ".reactive";
1616
String GENERATE_BUILDERS = CODEGEN_TIME_CONFIG_PREFIX + ".builders";
17+
String CODEGEN_BEAN_VALIDATION = CODEGEN_TIME_CONFIG_PREFIX + ".bean-validation";
1718

1819
static String getBasePackagePropertyName() {
1920
return CODEGEN_BASE_PACKAGE;
@@ -34,4 +35,8 @@ static String getCodegenReactive() {
3435
static String getGenerateBuilders() {
3536
return GENERATE_BUILDERS;
3637
}
38+
39+
static String getUseBeanValidation() {
40+
return CODEGEN_BEAN_VALIDATION;
41+
}
3742
}

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/ServerCodegenConfig.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,10 @@ public interface ServerCodegenConfig {
3737
*/
3838
@WithDefault(DEFAULT_PACKAGE)
3939
Optional<String> basePackage();
40+
41+
/**
42+
* Whether it must generate resources and beans using bean validation (JSR-303).
43+
*/
44+
@WithDefault("false")
45+
boolean useBeanValidation();
4046
}

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/codegen/ApicurioCodegenWrapper.java

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import io.apicurio.hub.api.codegen.JaxRsProjectSettings;
2424
import io.apicurio.hub.api.codegen.OpenApi2JaxRs;
25+
import io.quarkiverse.openapi.server.generator.deployment.CodegenConfig;
2526
import io.quarkus.bootstrap.prebuild.CodeGenException;
2627

2728
public class ApicurioCodegenWrapper {
@@ -42,6 +43,8 @@ public ApicurioCodegenWrapper(Config config, File outdir, JaxRsProjectSettings p
4243
this.projectSettings = projectSettings;
4344
this.projectSettings.setJavaPackage(getBasePackage());
4445
this.projectSettings.setReactive(getReactiveValue());
46+
this.projectSettings.setUseJsr303(getUseBeanValidation());
47+
this.projectSettings.setGenerateBuilders(getGenerateBuilders());
4548
}
4649

4750
public void generate(Path openApiResource) throws CodeGenException {
@@ -63,14 +66,11 @@ public void generate(Path openApiResource) throws CodeGenException {
6366

6467
try (FileOutputStream fos = new FileOutputStream(zipFile);
6568
FileInputStream openApiStream = new FileInputStream(openApiFile)) {
66-
OpenApi2JaxRs generator = new OpenApi2JaxRs() {
67-
{
68-
config = new ConfigurableGenerationConfig(ApicurioCodegenWrapper.this.config);
69-
}
70-
};
69+
OpenApi2JaxRs generator = new OpenApi2JaxRs();
7170
generator.setSettings(projectSettings);
7271
generator.setUpdateOnly(true);
7372
generator.setOpenApiDocument(openApiStream);
73+
7474
log.info("Generating code...");
7575
generator.generate(fos);
7676
} catch (Exception e) {
@@ -114,13 +114,23 @@ private void unzip(File fromZipFile, File toOutputDir) throws IOException {
114114

115115
private String getBasePackage() {
116116
return config
117-
.getOptionalValue(getBasePackagePropertyName(), String.class)
117+
.getOptionalValue(CodegenConfig.getBasePackagePropertyName(), String.class)
118118
.orElse(DEFAULT_PACKAGE);
119119
}
120120

121121
private Boolean getReactiveValue() {
122122
return config
123-
.getOptionalValue(getCodegenReactive(), Boolean.class)
123+
.getOptionalValue(CodegenConfig.getCodegenReactive(), Boolean.class)
124+
.orElse(Boolean.FALSE);
125+
}
126+
127+
private Boolean getUseBeanValidation() {
128+
return config.getOptionalValue(CodegenConfig.getUseBeanValidation(), Boolean.class)
129+
.orElse(Boolean.FALSE);
130+
}
131+
132+
private Boolean getGenerateBuilders() {
133+
return config.getOptionalValue(CodegenConfig.getGenerateBuilders(), Boolean.class)
124134
.orElse(Boolean.FALSE);
125135
}
126136

server/deployment/src/main/java/io/quarkiverse/openapi/server/generator/deployment/codegen/ConfigurableGenerationConfig.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)