Skip to content

Commit cc323f2

Browse files
authored
Fixes the "mutiny" config (#401)
Signed-off-by: Helber Belmiro <[email protected]>
1 parent 9f939de commit cc323f2

File tree

8 files changed

+404
-0
lines changed

8 files changed

+404
-0
lines changed

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public class CodegenConfig {
2727
static final String BUILD_TIME_SPEC_PREFIX_FORMAT = "quarkus." + CODEGEN_TIME_CONFIG_PREFIX + ".spec.%s";
2828
private static final String BASE_PACKAGE_PROP_FORMAT = "%s.base-package";
2929
private static final String SKIP_FORM_MODEL_PROP_FORMAT = "%s.skip-form-model";
30+
private static final String MUTINY_PROP_FORMAT = "%s.mutiny";
3031
private static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS_PROP_FORMAT = "%s.additional-model-type-annotations";
3132
private static final String TYPE_MAPPINGS_PROP_FORMAT = "%s.type-mappings";
3233
private static final String IMPORT_MAPPINGS_PROP_FORMAT = "%s.import-mappings";
@@ -76,6 +77,10 @@ public static String getSkipFormModelPropertyName(final Path openApiFilePath) {
7677
return String.format(SKIP_FORM_MODEL_PROP_FORMAT, getBuildTimeSpecPropertyPrefix(openApiFilePath));
7778
}
7879

80+
public static String getMutinyPropertyName(final Path openApiFilePath) {
81+
return String.format(MUTINY_PROP_FORMAT, getBuildTimeSpecPropertyPrefix(openApiFilePath));
82+
}
83+
7984
public static String getAdditionalModelTypeAnnotationsPropertyName(final Path openApiFilePath) {
8085
return String.format(ADDITIONAL_MODEL_TYPE_ANNOTATIONS_PROP_FORMAT, getBuildTimeSpecPropertyPrefix(openApiFilePath));
8186
}

deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getClientHeaderFactoryPropertyName;
1111
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getCustomRegisterProvidersFormat;
1212
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getImportMappingsPropertyName;
13+
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getMutinyPropertyName;
1314
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getNormalizerPropertyName;
1415
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getReturnResponsePropertyName;
1516
import static io.quarkiverse.openapi.generator.deployment.CodegenConfig.getSanitizedFileName;
@@ -152,6 +153,9 @@ protected void generate(final Config config, final Path openApiFilePath, final P
152153
.withCircuitBreakerConfig(CircuitBreakerConfigurationParser.parse(
153154
config));
154155

156+
config.getOptionalValue(getMutinyPropertyName(openApiFilePath), Boolean.class)
157+
.ifPresent(generator::withMutiny);
158+
155159
config.getOptionalValue(getSkipFormModelPropertyName(openApiFilePath), String.class)
156160
.ifPresent(generator::withSkipFormModelConfig);
157161

deployment/src/main/resources/templates/api.qute

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,11 @@ public interface {classname} {
8686
{#if return-response}
8787
public io.smallrye.mutiny.Uni<jakarta.ws.rs.core.Response> {op.nickname}(
8888
{#else}
89+
{#if op.returnType == "void"}
90+
public {#if op.returnType}io.smallrye.mutiny.Uni<Void>{#else}io.smallrye.mutiny.Uni<jakarta.ws.rs.core.Response>{/if} {op.nickname}(
91+
{#else}
8992
public {#if op.returnType}io.smallrye.mutiny.Uni<{op.returnType}>{#else}io.smallrye.mutiny.Uni<jakarta.ws.rs.core.Response>{/if} {op.nickname}(
93+
{/if}
9094
{/if}
9195
{#else}
9296
{#if return-response}

integration-tests/mutiny/pom.xml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<parent>
7+
<groupId>io.quarkiverse.openapi.generator</groupId>
8+
<artifactId>quarkus-openapi-generator-integration-tests</artifactId>
9+
<version>3.0.0-SNAPSHOT</version>
10+
</parent>
11+
12+
<artifactId>quarkus-openapi-generator-it-mutiny</artifactId>
13+
<name>Quarkus - Openapi Generator - Integration Tests - Mutiny</name>
14+
<description>Example project for general usage with Mutiny</description>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>io.quarkiverse.openapi.generator</groupId>
19+
<artifactId>quarkus-openapi-generator</artifactId>
20+
</dependency>
21+
<dependency>
22+
<groupId>org.assertj</groupId>
23+
<artifactId>assertj-core</artifactId>
24+
<scope>test</scope>
25+
</dependency>
26+
<dependency>
27+
<groupId>io.quarkus</groupId>
28+
<artifactId>quarkus-junit5</artifactId>
29+
<scope>test</scope>
30+
</dependency>
31+
</dependencies>
32+
33+
<build>
34+
<plugins>
35+
<plugin>
36+
<groupId>io.quarkus</groupId>
37+
<artifactId>quarkus-maven-plugin</artifactId>
38+
<extensions>true</extensions>
39+
<executions>
40+
<execution>
41+
<goals>
42+
<goal>build</goal>
43+
<goal>generate-code</goal>
44+
<goal>generate-code-tests</goal>
45+
</goals>
46+
</execution>
47+
</executions>
48+
</plugin>
49+
</plugins>
50+
</build>
51+
<profiles>
52+
<profile>
53+
<id>native-image</id>
54+
<activation>
55+
<property>
56+
<name>native</name>
57+
</property>
58+
</activation>
59+
<build>
60+
<plugins>
61+
<plugin>
62+
<artifactId>maven-surefire-plugin</artifactId>
63+
<configuration>
64+
<skipTests>${native.surefire.skip}</skipTests>
65+
</configuration>
66+
</plugin>
67+
<plugin>
68+
<artifactId>maven-failsafe-plugin</artifactId>
69+
<executions>
70+
<execution>
71+
<goals>
72+
<goal>integration-test</goal>
73+
<goal>verify</goal>
74+
</goals>
75+
<configuration>
76+
<systemPropertyVariables>
77+
<native.image.path>${project.build.directory}/${project.build.finalName}-runner</native.image.path>
78+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
79+
<maven.home>${maven.home}</maven.home>
80+
</systemPropertyVariables>
81+
</configuration>
82+
</execution>
83+
</executions>
84+
</plugin>
85+
</plugins>
86+
</build>
87+
<properties>
88+
<quarkus.package.type>native</quarkus.package.type>
89+
</properties>
90+
</profile>
91+
</profiles>
92+
93+
</project>

0 commit comments

Comments
 (0)