Skip to content

Commit 25507a2

Browse files
authored
Merge branch 'main-lts' into main-lts_upgrade-apicurio-codegen
2 parents 248fd78 + 057cf8a commit 25507a2

File tree

8 files changed

+1408
-3
lines changed

8 files changed

+1408
-3
lines changed

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
@@ -26,6 +26,12 @@ public interface ServerCodegenConfig {
2626
@WithDefault("false")
2727
boolean reactive();
2828

29+
/**
30+
* Whether it must generate builders for properties.
31+
*/
32+
@WithDefault("false")
33+
boolean builders();
34+
2935
/**
3036
* The base package to be used to generated sources.
3137
*/

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

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ public class ApicurioCodegenWrapper {
2929

3030
private static final Logger log = LoggerFactory.getLogger(ApicurioCodegenWrapper.class);
3131

32+
private final Config config;
3233
private final File outdir;
3334
private final JaxRsProjectSettings projectSettings;
3435

@@ -37,6 +38,7 @@ public ApicurioCodegenWrapper(Config config, File outdir) {
3738
}
3839

3940
public ApicurioCodegenWrapper(Config config, File outdir, JaxRsProjectSettings projectSettings) {
41+
this.config = config;
4042
this.outdir = outdir;
4143
this.projectSettings = projectSettings;
4244
this.projectSettings.setJavaPackage(getBasePackage());
@@ -64,7 +66,11 @@ public void generate(Path openApiResource) throws CodeGenException {
6466

6567
try (FileOutputStream fos = new FileOutputStream(zipFile);
6668
FileInputStream openApiStream = new FileInputStream(openApiFile)) {
67-
OpenApi2JaxRs generator = new OpenApi2JaxRs();
69+
OpenApi2JaxRs generator = new OpenApi2JaxRs() {
70+
{
71+
config = new ConfigurableGenerationConfig(ApicurioCodegenWrapper.this.config);
72+
}
73+
};
6874
generator.setSettings(projectSettings);
6975
generator.setUpdateOnly(true);
7076
generator.setOpenApiDocument(openApiStream);
@@ -110,13 +116,13 @@ private void unzip(File fromZipFile, File toOutputDir) throws IOException {
110116
}
111117
}
112118

113-
private String getBasePackage(final Config config) {
119+
private String getBasePackage() {
114120
return config
115121
.getOptionalValue(CodegenConfig.getBasePackagePropertyName(), String.class)
116122
.orElse(DEFAULT_PACKAGE);
117123
}
118124

119-
private Boolean getReactiveValue(final Config config) {
125+
private Boolean getReactiveValue() {
120126
return config
121127
.getOptionalValue(CodegenConfig.getCodegenReactive(), Boolean.class)
122128
.orElse(Boolean.FALSE);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package io.quarkiverse.openapi.server.generator.deployment.codegen;
2+
3+
import org.eclipse.microprofile.config.Config;
4+
import org.jsonschema2pojo.DefaultGenerationConfig;
5+
import org.slf4j.Logger;
6+
import org.slf4j.LoggerFactory;
7+
8+
import io.quarkiverse.openapi.server.generator.deployment.CodegenConfig;
9+
10+
public class ConfigurableGenerationConfig extends DefaultGenerationConfig {
11+
12+
private static final Logger log = LoggerFactory.getLogger(ConfigurableGenerationConfig.class);
13+
14+
private final boolean generateBuilders;
15+
16+
public ConfigurableGenerationConfig(Config config) {
17+
generateBuilders = config
18+
.getOptionalValue(CodegenConfig.getGenerateBuilders(), Boolean.class)
19+
.orElse(Boolean.FALSE);
20+
log.debug("generateBuilders={}", generateBuilders);
21+
}
22+
23+
@Override
24+
public boolean isGenerateBuilders() {
25+
return generateBuilders;
26+
}
27+
28+
}
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<parent>
4+
<artifactId>quarkus-openapi-generator-server-integration-tests-parent</artifactId>
5+
<groupId>io.quarkiverse.openapi.generator</groupId>
6+
<version>3.0.0-lts-SNAPSHOT</version>
7+
<relativePath>../pom.xml</relativePath>
8+
</parent>
9+
<modelVersion>4.0.0</modelVersion>
10+
11+
<artifactId>quarkus-openapi-generator-server-integration-tests-builders</artifactId>
12+
<name>Quarkus - OpenAPI Generator - Server - Integration Tests - Builders</name>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>io.quarkus</groupId>
17+
<artifactId>quarkus-undertow</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>io.quarkus</groupId>
21+
<artifactId>quarkus-resteasy</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>io.quarkus</groupId>
25+
<artifactId>quarkus-resteasy-jackson</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>io.quarkiverse.openapi.generator</groupId>
29+
<artifactId>quarkus-openapi-generator-server</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>io.quarkus</groupId>
33+
<artifactId>quarkus-junit5</artifactId>
34+
<scope>test</scope>
35+
</dependency>
36+
<dependency>
37+
<groupId>io.quarkus</groupId>
38+
<artifactId>quarkus-test-common</artifactId>
39+
<scope>test</scope>
40+
</dependency>
41+
<dependency>
42+
<groupId>org.junit.jupiter</groupId>
43+
<artifactId>junit-jupiter</artifactId>
44+
<scope>test</scope>
45+
</dependency>
46+
<dependency>
47+
<groupId>io.rest-assured</groupId>
48+
<artifactId>rest-assured</artifactId>
49+
<scope>test</scope>
50+
</dependency>
51+
<dependency>
52+
<groupId>io.quarkus</groupId>
53+
<artifactId>quarkus-smallrye-openapi</artifactId>
54+
</dependency>
55+
</dependencies>
56+
57+
<build>
58+
<pluginManagement>
59+
<plugins>
60+
<plugin>
61+
<groupId>io.quarkus</groupId>
62+
<artifactId>quarkus-maven-plugin</artifactId>
63+
<version>${quarkus.version}</version>
64+
</plugin>
65+
<plugin>
66+
<artifactId>maven-surefire-plugin</artifactId>
67+
<version>${version.surefire.plugin}</version>
68+
<configuration>
69+
<systemPropertyVariables>
70+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
71+
<maven.home>${maven.home}</maven.home>
72+
<maven.repo>${settings.localRepository}</maven.repo>
73+
</systemPropertyVariables>
74+
</configuration>
75+
</plugin>
76+
<plugin>
77+
<artifactId>maven-failsafe-plugin</artifactId>
78+
<version>${failsafe-plugin.version}</version>
79+
<configuration>
80+
<systemPropertyVariables>
81+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
82+
<maven.home>${maven.home}</maven.home>
83+
<maven.repo>${settings.localRepository}</maven.repo>
84+
</systemPropertyVariables>
85+
</configuration>
86+
</plugin>
87+
<plugin>
88+
<artifactId>maven-compiler-plugin</artifactId>
89+
<version>${compiler-plugin.version}</version>
90+
<configuration>
91+
<compilerArgs>
92+
<arg>-parameters</arg>
93+
</compilerArgs>
94+
</configuration>
95+
</plugin>
96+
</plugins>
97+
</pluginManagement>
98+
<plugins>
99+
<plugin>
100+
<groupId>io.quarkus</groupId>
101+
<artifactId>quarkus-maven-plugin</artifactId>
102+
<executions>
103+
<execution>
104+
<goals>
105+
<goal>build</goal>
106+
<goal>generate-code</goal>
107+
</goals>
108+
</execution>
109+
</executions>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
</project>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Codegen properties
2+
quarkus.openapi.generator.spec=petstore-openapi.json
3+
quarkus.openapi.generator.base-package=io.petstore
4+
quarkus.openapi.generator.reactive=false
5+
quarkus.openapi.generator.builders=true

0 commit comments

Comments
 (0)