Skip to content

Commit a5207f7

Browse files
author
Andy Barilla
committed
add integration tests
1 parent d182b99 commit a5207f7

File tree

7 files changed

+261
-0
lines changed

7 files changed

+261
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,12 @@ protected void generate(OpenApiGeneratorOptions options) {
288288
getValues(config, openApiFilePath, CodegenConfig.ConfigName.BEAN_VALIDATION, Boolean.class)
289289
.ifPresent(generator::withUseBeanValidation);
290290

291+
getValues(config, openApiFilePath, CodegenConfig.ConfigName.GENERATE_APIS, Boolean.class)
292+
.ifPresent(generator::withGenerateApis);
293+
294+
getValues(config, openApiFilePath, CodegenConfig.ConfigName.GENERATE_MODELS, Boolean.class)
295+
.ifPresent(generator::withGenerateModels);
296+
291297
SmallRyeConfig smallRyeConfig = config.unwrap(SmallRyeConfig.class);
292298

293299
getValues(smallRyeConfig, openApiFilePath, CodegenConfig.ConfigName.TYPE_MAPPINGS, String.class, String.class)
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
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-integration-tests</artifactId>
5+
<groupId>io.quarkiverse.openapi.generator</groupId>
6+
<version>3.0.0-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
10+
<artifactId>quarkus-openapi-generator-it-generate-flags</artifactId>
11+
<name>Quarkus - Openapi Generator - Integration Tests - Client - Generate Flags</name>
12+
<description>Example project for usage of the generate-models and generate-apis properties</description>
13+
14+
<dependencies>
15+
<dependency>
16+
<groupId>io.quarkiverse.openapi.generator</groupId>
17+
<artifactId>quarkus-openapi-generator</artifactId>
18+
</dependency>
19+
<dependency>
20+
<groupId>org.assertj</groupId>
21+
<artifactId>assertj-core</artifactId>
22+
<scope>test</scope>
23+
</dependency>
24+
<dependency>
25+
<groupId>io.quarkus</groupId>
26+
<artifactId>quarkus-junit5</artifactId>
27+
<scope>test</scope>
28+
</dependency>
29+
<dependency>
30+
<groupId>io.quarkus</groupId>
31+
<artifactId>quarkus-hibernate-validator</artifactId>
32+
</dependency>
33+
</dependencies>
34+
<build>
35+
<plugins>
36+
<plugin>
37+
<groupId>io.quarkus</groupId>
38+
<artifactId>quarkus-maven-plugin</artifactId>
39+
<extensions>true</extensions>
40+
<executions>
41+
<execution>
42+
<goals>
43+
<goal>build</goal>
44+
<goal>generate-code</goal>
45+
<goal>generate-code-tests</goal>
46+
</goals>
47+
</execution>
48+
</executions>
49+
</plugin>
50+
</plugins>
51+
</build>
52+
<profiles>
53+
<profile>
54+
<id>native-image</id>
55+
<activation>
56+
<property>
57+
<name>native</name>
58+
</property>
59+
</activation>
60+
<build>
61+
<plugins>
62+
<plugin>
63+
<artifactId>maven-surefire-plugin</artifactId>
64+
<configuration>
65+
<skipTests>${native.surefire.skip}</skipTests>
66+
</configuration>
67+
</plugin>
68+
<plugin>
69+
<artifactId>maven-failsafe-plugin</artifactId>
70+
<executions>
71+
<execution>
72+
<goals>
73+
<goal>integration-test</goal>
74+
<goal>verify</goal>
75+
</goals>
76+
<configuration>
77+
<systemPropertyVariables>
78+
<native.image.path>
79+
${project.build.directory}/${project.build.finalName}-runner
80+
</native.image.path>
81+
<java.util.logging.manager>org.jboss.logmanager.LogManager
82+
</java.util.logging.manager>
83+
<maven.home>${maven.home}</maven.home>
84+
</systemPropertyVariables>
85+
</configuration>
86+
</execution>
87+
</executions>
88+
</plugin>
89+
</plugins>
90+
</build>
91+
<properties>
92+
<quarkus.package.type>native</quarkus.package.type>
93+
</properties>
94+
</profile>
95+
</profiles>
96+
97+
</project>
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
openapi: 3.0.3
3+
info:
4+
title: Test API
5+
version: "1.0"
6+
paths:
7+
/{pathParam}:
8+
get:
9+
tags:
10+
- NonExistentEndpoint
11+
operationId: test
12+
parameters:
13+
- name: pathParam
14+
in: path
15+
required: true
16+
schema:
17+
type: string
18+
minimum: 5
19+
- name: headerParam
20+
in: header
21+
required: false
22+
schema:
23+
type: integer
24+
maximum: 5
25+
- name: cookieParam
26+
in: cookie
27+
required: true
28+
schema:
29+
type: string
30+
minLength: 10
31+
responses:
32+
"200":
33+
description: OK
34+
content:
35+
text/plain:
36+
schema:
37+
type: string
38+
components:
39+
schemas:
40+
ExistentObject:
41+
type: object
42+
description: Some object not to be validated
43+
required:
44+
- id
45+
- name
46+
- size
47+
properties:
48+
id:
49+
type: integer
50+
minimum: 1
51+
maximum: 100
52+
name:
53+
type: string
54+
pattern: "[a-zA-Z]*"
55+
minLength: 1
56+
maxLength: 10
57+
size:
58+
type: number
59+
minimum: 1.0
60+
maximum: 10.0
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
openapi: 3.0.3
3+
info:
4+
title: Test API
5+
version: "1.0"
6+
paths:
7+
/{pathParam}:
8+
get:
9+
tags:
10+
- ExistentEndpoint
11+
operationId: test
12+
parameters:
13+
- name: pathParam
14+
in: path
15+
required: true
16+
schema:
17+
type: string
18+
minimum: 5
19+
- name: headerParam
20+
in: header
21+
required: false
22+
schema:
23+
type: integer
24+
maximum: 5
25+
- name: cookieParam
26+
in: cookie
27+
required: true
28+
schema:
29+
type: string
30+
minLength: 10
31+
responses:
32+
"200":
33+
description: OK
34+
content:
35+
text/plain:
36+
schema:
37+
type: string
38+
components:
39+
schemas:
40+
NonExistentObject:
41+
type: object
42+
description: Some object not to be validated
43+
required:
44+
- id
45+
- name
46+
- size
47+
properties:
48+
id:
49+
type: integer
50+
minimum: 1
51+
maximum: 100
52+
name:
53+
type: string
54+
pattern: "[a-zA-Z]*"
55+
minLength: 1
56+
maxLength: 10
57+
size:
58+
type: number
59+
minimum: 1.0
60+
maximum: 10.0
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
quarkus.openapi-generator.codegen.spec.generate_models_false_yaml.generate-models = false
2+
quarkus.openapi-generator.codegen.spec.generate_apis_false_yaml.generate-apis = false
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.quarkiverse.openapi.generator.it;
2+
3+
import org.assertj.core.api.Assertions;
4+
import org.junit.jupiter.api.Test;
5+
6+
import io.quarkus.test.junit.QuarkusTest;
7+
8+
@QuarkusTest
9+
class GenerateFlagsTest {
10+
11+
@Test
12+
void testEndpointIsInPlace() throws ClassNotFoundException {
13+
Class.forName("org.openapi.quarkus.generate_models_false_yaml.api.ExistentEndpointApi");
14+
}
15+
16+
@Test
17+
void testModelIsInPlace() throws ClassNotFoundException {
18+
Class.forName("org.openapi.quarkus.generate_apis_false_yaml.model.ExistentObject");
19+
}
20+
21+
@Test
22+
void testEndpointIsNotInPlace() {
23+
Assertions.assertThatThrownBy(() -> {
24+
Class.forName("org.openapi.quarkus.generate_apis_false_yaml.model.NonExistentEndpointApi");
25+
}).isInstanceOf(ClassNotFoundException.class);
26+
}
27+
28+
@Test
29+
void testModelIsNotInPlace() {
30+
Assertions.assertThatThrownBy(() -> {
31+
Class.forName("org.openapi.quarkus.generate_models_false_yaml.api.NonExistentObject");
32+
}).isInstanceOf(ClassNotFoundException.class);
33+
}
34+
35+
}

client/integration-tests/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<module>enum-property</module>
2424
<module>enum-unexpected</module>
2525
<module>exclude</module>
26+
<module>generate-flags</module>
2627
<module>generation-input</module>
2728
<module>generation-tests</module>
2829
<module>include</module>

0 commit comments

Comments
 (0)