Skip to content

Commit 019972b

Browse files
authored
Add codestarts to server extension (#1037) (#1232)
1 parent b7a7a81 commit 019972b

File tree

11 files changed

+263
-3
lines changed

11 files changed

+263
-3
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
cache: 'maven'
5151

5252
- name: Build with Maven
53-
run: mvn '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check verify --file pom.xml
53+
run: mvn '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check install --file pom.xml
5454

5555
build_reactive:
5656
name: Build - RESTEasy Reactive
@@ -79,4 +79,4 @@ jobs:
7979
cache: 'maven'
8080

8181
- name: Build with Maven
82-
run: mvn -Presteasy-reactive '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check verify --file pom.xml
82+
run: mvn -Presteasy-reactive '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check install --file pom.xml
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<parent>
5+
<artifactId>quarkus-openapi-generator-server-integration-tests-parent</artifactId>
6+
<groupId>io.quarkiverse.openapi.generator</groupId>
7+
<version>3.0.0-lts-SNAPSHOT</version>
8+
<relativePath>../pom.xml</relativePath>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>quarkus-openapi-generator-server-integration-tests-codestarts</artifactId>
13+
<name>Quarkus - Openapi Generator - Server - Integration Tests - Codestarts</name>
14+
15+
<dependencies>
16+
<dependency>
17+
<groupId>io.quarkiverse.openapi.generator</groupId>
18+
<artifactId>quarkus-openapi-generator-server</artifactId>
19+
<version>${project.version}</version>
20+
</dependency>
21+
<dependency>
22+
<groupId>io.quarkus</groupId>
23+
<artifactId>quarkus-devtools-testing</artifactId>
24+
<scope>test</scope>
25+
</dependency>
26+
</dependencies>
27+
28+
<build>
29+
<pluginManagement>
30+
<plugins>
31+
<plugin>
32+
<groupId>io.quarkus</groupId>
33+
<artifactId>quarkus-maven-plugin</artifactId>
34+
<version>${quarkus.version}</version>
35+
</plugin>
36+
<plugin>
37+
<artifactId>maven-surefire-plugin</artifactId>
38+
<version>${version.surefire.plugin}</version>
39+
<configuration>
40+
<systemPropertyVariables>
41+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
42+
<maven.home>${maven.home}</maven.home>
43+
<maven.repo>${settings.localRepository}</maven.repo>
44+
</systemPropertyVariables>
45+
</configuration>
46+
</plugin>
47+
<plugin>
48+
<artifactId>maven-failsafe-plugin</artifactId>
49+
<version>${failsafe-plugin.version}</version>
50+
<configuration>
51+
<systemPropertyVariables>
52+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
53+
<maven.home>${maven.home}</maven.home>
54+
<maven.repo>${settings.localRepository}</maven.repo>
55+
</systemPropertyVariables>
56+
</configuration>
57+
</plugin>
58+
<plugin>
59+
<artifactId>maven-compiler-plugin</artifactId>
60+
<version>${compiler-plugin.version}</version>
61+
<configuration>
62+
<compilerArgs>
63+
<arg>-parameters</arg>
64+
</compilerArgs>
65+
</configuration>
66+
</plugin>
67+
</plugins>
68+
</pluginManagement>
69+
<plugins>
70+
<plugin>
71+
<groupId>org.apache.maven.plugins</groupId>
72+
<artifactId>maven-resources-plugin</artifactId>
73+
<version>3.3.1</version> <!-- Adjust the version if needed -->
74+
<executions>
75+
<execution>
76+
<id>copy-resources</id>
77+
<phase>generate-resources</phase>
78+
<goals>
79+
<goal>copy-resources</goal>
80+
</goals>
81+
<configuration>
82+
<outputDirectory>${project.build.outputDirectory}</outputDirectory>
83+
<resources>
84+
<resource>
85+
<directory>
86+
${project.basedir}/../runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java
87+
</directory>
88+
<filtering>false</filtering>
89+
</resource>
90+
</resources>
91+
</configuration>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>io.quarkus</groupId>
97+
<artifactId>quarkus-maven-plugin</artifactId>
98+
<executions>
99+
<execution>
100+
<goals>
101+
<goal>build</goal>
102+
<goal>generate-code</goal>
103+
</goals>
104+
</execution>
105+
</executions>
106+
</plugin>
107+
</plugins>
108+
</build>
109+
</project>

server/integration-tests/codestarts/src/main/resources/application.properties

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package io.quarkiverse.openapi.server.generator.it;
2+
3+
import org.junit.jupiter.api.Test;
4+
import org.junit.jupiter.api.extension.RegisterExtension;
5+
6+
import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog;
7+
import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest;
8+
9+
public class QuarkusOpenAPIGeneratorServerCodestartsTest {
10+
11+
@RegisterExtension
12+
public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder()
13+
.languages(QuarkusCodestartCatalog.Language.JAVA)
14+
.setupStandaloneExtensionTest("io.quarkiverse.openapi.generator:quarkus-openapi-generator-server").build();
15+
16+
@Test
17+
void testContent() throws Throwable {
18+
codestartTest
19+
.assertThatGeneratedFile(QuarkusCodestartCatalog.Language.JAVA, "src/main/resources/application.properties")
20+
.content()
21+
.contains("quarkus.openapi.generator.spec=openapi.yml");
22+
codestartTest
23+
.assertThatGeneratedFile(QuarkusCodestartCatalog.Language.JAVA, "src/main/resources/openapi/openapi.yml")
24+
.content()
25+
.contains("title: Generated API");
26+
}
27+
}

server/integration-tests/pom.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
<modules>
1717
<module>reactive</module>
1818
<module>resteasy</module>
19+
<module>codestarts</module>
1920
</modules>
2021

21-
</project>
22+
</project>

server/runtime/pom.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,26 @@
6060
</execution>
6161
</executions>
6262
</plugin>
63+
<plugin>
64+
<artifactId>maven-jar-plugin</artifactId>
65+
<executions>
66+
<execution>
67+
<id>generate-codestart-jar</id>
68+
<phase>generate-resources</phase>
69+
<goals>
70+
<goal>jar</goal>
71+
</goals>
72+
<configuration>
73+
<classesDirectory>${project.basedir}/src/main</classesDirectory>
74+
<includes>
75+
<include>codestarts/**</include>
76+
</includes>
77+
<classifier>codestarts</classifier>
78+
<skipIfEmpty>true</skipIfEmpty>
79+
</configuration>
80+
</execution>
81+
</executions>
82+
</plugin>
6383
</plugins>
6484
</build>
6585
</project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name: openapi-generator-server-codestart
2+
ref: openapi-generator-server
3+
type: code
4+
tags: extension-codestart
5+
metadata:
6+
title: OpenAPI Generator Server
7+
description: This codestart generates a simple API with OpenAPI documentation.
8+
related-guide-section: https://docs.quarkiverse.io/quarkus-openapi-generator/dev/server.html
9+
language:
10+
base:
11+
dependencies:
12+
- io.quarkus:quarkus-resteasy
13+
- io.quarkus:quarkus-smallrye-openapi
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{#include readme-header /}
2+
3+
## Requirements
4+
5+
If you do not have added the `io.quarkus:quarkus-smallrye-openapi` extension in your project, add it first:
6+
7+
### SmallRye OpenAPI:
8+
9+
Quarkus CLI:
10+
11+
```bash
12+
quarkus ext add io.quarkus:quarkus-smallrye-openapi
13+
```
14+
15+
Maven:
16+
```bash
17+
./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-smallrye-openapi"
18+
```
19+
20+
Gradle:
21+
22+
```bash
23+
./gradlew addExtension --extensions="io.quarkus:quarkus-smallrye-openapi"
24+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
quarkus:
2+
openapi:
3+
generator:
4+
spec:
5+
openapi.yml
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
openapi: 3.0.3
2+
info:
3+
title: Generated API
4+
version: "1.0"
5+
paths:
6+
/pets:
7+
get:
8+
responses:
9+
200:
10+
description: OK
11+
content:
12+
application/json: { }
13+
post:
14+
requestBody:
15+
content:
16+
application/json:
17+
schema:
18+
$ref: '#/components/schemas/Pet'
19+
responses:
20+
200:
21+
description: OK
22+
content:
23+
application/json: { }
24+
delete:
25+
requestBody:
26+
content:
27+
application/json:
28+
schema:
29+
$ref: '#/components/schemas/Pet'
30+
responses:
31+
200:
32+
description: OK
33+
content:
34+
application/json: { }
35+
components:
36+
schemas:
37+
Pet:
38+
properties:
39+
description:
40+
type: string
41+
name:
42+
type: string

0 commit comments

Comments
 (0)