From 695f72d218864083c7304834e5995a0043792529 Mon Sep 17 00:00:00 2001 From: vladprado <76523900+vladprado@users.noreply.github.com> Date: Thu, 20 Mar 2025 07:50:46 -0300 Subject: [PATCH 1/3] Add codestarts to server extension (#1037) Add codestart to server extension - issue #1021 Adding codestarter to server extension - issue #1021 minor fixes and tests requested in PR Test update and final touches to codestart server extension Codestart test adjustments Adjust codestarts Add deps version Use install instead Add codestart for the server extension - issue #1021 Adding codestarts to server extension - issue #1021 Adding codestarts to server extension - issue #1021 --- .github/workflows/build.yml | 4 +- server/integration-tests/codestarts/pom.xml | 109 ++++++++++++++++++ .../src/main/resources/application.properties | 0 ...sOpenAPIGeneratorServerCodestartsTest.java | 27 +++++ server/integration-tests/pom.xml | 3 +- server/runtime/pom.xml | 20 ++++ .../openapi-generator-codestart/codestart.yml | 17 +++ .../java/README.tpl.qute.md | 24 ++++ .../java/src/main/resources/application.yml | 5 + .../src/main/resources/openapi/openapi.yml | 42 +++++++ .../resources/META-INF/quarkus-extension.yaml | 19 +++ 11 files changed, 267 insertions(+), 3 deletions(-) create mode 100644 server/integration-tests/codestarts/pom.xml create mode 100755 server/integration-tests/codestarts/src/main/resources/application.properties create mode 100644 server/integration-tests/codestarts/src/test/java/io/quarkiverse/openapi/server/generator/it/QuarkusOpenAPIGeneratorServerCodestartsTest.java create mode 100644 server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml create mode 100644 server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md create mode 100644 server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml create mode 100644 server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml create mode 100644 server/runtime/src/main/resources/META-INF/quarkus-extension.yaml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 84bae2002..0f9f8c49c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -50,7 +50,7 @@ jobs: cache: 'maven' - name: Build with Maven - run: mvn '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check verify --file pom.xml + run: mvn '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check install --file pom.xml build_reactive: name: Build - RESTEasy Reactive @@ -79,4 +79,4 @@ jobs: cache: 'maven' - name: Build with Maven - run: mvn -Presteasy-reactive '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check verify --file pom.xml + run: mvn -Presteasy-reactive '-Dorg.slf4j.simpleLogger.log.org.openapitools=off' -B formatter:validate impsort:check install --file pom.xml diff --git a/server/integration-tests/codestarts/pom.xml b/server/integration-tests/codestarts/pom.xml new file mode 100644 index 000000000..6f1941e5f --- /dev/null +++ b/server/integration-tests/codestarts/pom.xml @@ -0,0 +1,109 @@ + + + + quarkus-openapi-generator-server-integration-tests-parent + io.quarkiverse.openapi.generator + 3.0.0-SNAPSHOT + ../pom.xml + + 4.0.0 + + quarkus-openapi-generator-server-integration-tests-codestarts + Quarkus - Openapi Generator - Server - Integration Tests - Codestarts + + + + io.quarkiverse.openapi.generator + quarkus-openapi-generator-server + ${project.version} + + + io.quarkus + quarkus-devtools-testing + test + + + + + + + + io.quarkus + quarkus-maven-plugin + ${quarkus.version} + + + maven-surefire-plugin + ${version.surefire.plugin} + + + org.jboss.logmanager.LogManager + ${maven.home} + ${settings.localRepository} + + + + + maven-failsafe-plugin + ${failsafe-plugin.version} + + + org.jboss.logmanager.LogManager + ${maven.home} + ${settings.localRepository} + + + + + maven-compiler-plugin + ${compiler-plugin.version} + + + -parameters + + + + + + + + org.apache.maven.plugins + maven-resources-plugin + 3.3.1 + + + copy-resources + generate-resources + + copy-resources + + + ${project.build.outputDirectory} + + + + ${project.basedir}/../runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java + + false + + + + + + + + io.quarkus + quarkus-maven-plugin + + + + build + generate-code + + + + + + + diff --git a/server/integration-tests/codestarts/src/main/resources/application.properties b/server/integration-tests/codestarts/src/main/resources/application.properties new file mode 100755 index 000000000..e69de29bb diff --git a/server/integration-tests/codestarts/src/test/java/io/quarkiverse/openapi/server/generator/it/QuarkusOpenAPIGeneratorServerCodestartsTest.java b/server/integration-tests/codestarts/src/test/java/io/quarkiverse/openapi/server/generator/it/QuarkusOpenAPIGeneratorServerCodestartsTest.java new file mode 100644 index 000000000..d9a480c1b --- /dev/null +++ b/server/integration-tests/codestarts/src/test/java/io/quarkiverse/openapi/server/generator/it/QuarkusOpenAPIGeneratorServerCodestartsTest.java @@ -0,0 +1,27 @@ +package io.quarkiverse.openapi.server.generator.it; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.RegisterExtension; + +import io.quarkus.devtools.codestarts.quarkus.QuarkusCodestartCatalog; +import io.quarkus.devtools.testing.codestarts.QuarkusCodestartTest; + +public class QuarkusOpenAPIGeneratorServerCodestartsTest { + + @RegisterExtension + public static QuarkusCodestartTest codestartTest = QuarkusCodestartTest.builder() + .languages(QuarkusCodestartCatalog.Language.JAVA) + .setupStandaloneExtensionTest("io.quarkiverse.openapi.generator:quarkus-openapi-generator-server").build(); + + @Test + void testContent() throws Throwable { + codestartTest + .assertThatGeneratedFile(QuarkusCodestartCatalog.Language.JAVA, "src/main/resources/application.properties") + .content() + .contains("quarkus.openapi.generator.spec=openapi.yml"); + codestartTest + .assertThatGeneratedFile(QuarkusCodestartCatalog.Language.JAVA, "src/main/resources/openapi/openapi.yml") + .content() + .contains("title: Generated API"); + } +} diff --git a/server/integration-tests/pom.xml b/server/integration-tests/pom.xml index f6762173a..02004766a 100755 --- a/server/integration-tests/pom.xml +++ b/server/integration-tests/pom.xml @@ -16,6 +16,7 @@ reactive resteasy + codestarts - \ No newline at end of file + diff --git a/server/runtime/pom.xml b/server/runtime/pom.xml index cdd310530..29905bd9c 100755 --- a/server/runtime/pom.xml +++ b/server/runtime/pom.xml @@ -60,6 +60,26 @@ + + maven-jar-plugin + + + generate-codestart-jar + generate-resources + + jar + + + ${project.basedir}/src/main + + codestarts/** + + codestarts + true + + + + diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml new file mode 100644 index 000000000..69006d404 --- /dev/null +++ b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml @@ -0,0 +1,17 @@ +name: openapi-generator-server +ref: openapi-generator-server +type: code +tags: extension-codestart +metadata: + title: OpenAPI Generator Codestart - Server Extension + description: This codestart generates a simple API with OpenAPI documentation. + related-guide-section: https://docs.quarkiverse.io/quarkus-openapi-generator/dev/server.html +language: + base: + data: + resource: + class-name: YourResource + path: "/your-api" + dependencies: + - io.quarkus:quarkus-resteasy + - io.quarkus:quarkus-smallrye-openapi \ No newline at end of file diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md new file mode 100644 index 000000000..0d8dc1409 --- /dev/null +++ b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md @@ -0,0 +1,24 @@ +{#include readme-header /} + +## Requirements + +If you do not have added the `io.quarkus:quarkus-smallrye-openapi` extension in your project, add it first: + +### SmallRye OpenAPI: + +Quarkus CLI: + +```bash +quarkus ext add io.quarkus:quarkus-smallrye-openapi +``` + +Maven: +```bash +./mvnw quarkus:add-extension -Dextensions="io.quarkus:quarkus-smallrye-openapi" +``` + +Gradle: + +```bash +./gradlew addExtension --extensions="io.quarkus:quarkus-smallrye-openapi" +``` \ No newline at end of file diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml new file mode 100644 index 000000000..ea7674128 --- /dev/null +++ b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml @@ -0,0 +1,5 @@ +quarkus: + openapi: + generator: + spec: + openapi.yml \ No newline at end of file diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml new file mode 100644 index 000000000..707eca341 --- /dev/null +++ b/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml @@ -0,0 +1,42 @@ +openapi: 3.0.3 +info: + title: Generated API + version: "1.0" +paths: + /pets: + get: + responses: + 200: + description: OK + content: + application/json: { } + post: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + responses: + 200: + description: OK + content: + application/json: { } + delete: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/Pet' + responses: + 200: + description: OK + content: + application/json: { } +components: + schemas: + Pet: + properties: + description: + type: string + name: + type: string \ No newline at end of file diff --git a/server/runtime/src/main/resources/META-INF/quarkus-extension.yaml b/server/runtime/src/main/resources/META-INF/quarkus-extension.yaml new file mode 100644 index 000000000..fce904e16 --- /dev/null +++ b/server/runtime/src/main/resources/META-INF/quarkus-extension.yaml @@ -0,0 +1,19 @@ +name: "OpenAPI Generator - REST Server Generator" +description: "Provides personalized code generation to get started in a Server project " +artifact: ${project.groupId}:${project.artifactId}:${project.version} +metadata: + keywords: + - "openapi" + - "openapi-generator-server" + - "rest" + - "server" + categories: + - "web" + guide: "https://docs.quarkiverse.io/quarkus-openapi-generator/dev/index.html" + icon-url: "https://raw.githubusercontent.com/quarkiverse/quarkus-openapi-generator/main/docs/modules/ROOT/assets/images/openapi.svg" + status: "preview" + codestart: + name: "openapi-generator-server" + languages: + - "java" + artifact: "io.quarkiverse.openapi.generator:quarkus-openapi-generator-server:codestarts:jar:${project.version}" \ No newline at end of file From 334728025ed814374df076cba5dda8f4bb46a141 Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Mon, 7 Jul 2025 21:20:06 -0300 Subject: [PATCH 2/3] Adjust codestarts server --- .../codestart.yml | 8 ++------ .../java/README.tpl.qute.md | 0 .../java/src/main/resources/application.yml | 0 .../java/src/main/resources/openapi/openapi.yml | 0 4 files changed, 2 insertions(+), 6 deletions(-) rename server/runtime/src/main/codestarts/quarkus/{openapi-generator-codestart => openapi-generator-server-codestart}/codestart.yml (68%) rename server/runtime/src/main/codestarts/quarkus/{openapi-generator-codestart => openapi-generator-server-codestart}/java/README.tpl.qute.md (100%) rename server/runtime/src/main/codestarts/quarkus/{openapi-generator-codestart => openapi-generator-server-codestart}/java/src/main/resources/application.yml (100%) rename server/runtime/src/main/codestarts/quarkus/{openapi-generator-codestart => openapi-generator-server-codestart}/java/src/main/resources/openapi/openapi.yml (100%) diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/codestart.yml similarity index 68% rename from server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml rename to server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/codestart.yml index 69006d404..edb0f3322 100644 --- a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/codestart.yml +++ b/server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/codestart.yml @@ -1,17 +1,13 @@ -name: openapi-generator-server +name: openapi-generator-server-codestart ref: openapi-generator-server type: code tags: extension-codestart metadata: - title: OpenAPI Generator Codestart - Server Extension + title: OpenAPI Generator Server description: This codestart generates a simple API with OpenAPI documentation. related-guide-section: https://docs.quarkiverse.io/quarkus-openapi-generator/dev/server.html language: base: - data: - resource: - class-name: YourResource - path: "/your-api" dependencies: - io.quarkus:quarkus-resteasy - io.quarkus:quarkus-smallrye-openapi \ No newline at end of file diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md b/server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/README.tpl.qute.md similarity index 100% rename from server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/README.tpl.qute.md rename to server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/README.tpl.qute.md diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/src/main/resources/application.yml similarity index 100% rename from server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/application.yml rename to server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/src/main/resources/application.yml diff --git a/server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml b/server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/src/main/resources/openapi/openapi.yml similarity index 100% rename from server/runtime/src/main/codestarts/quarkus/openapi-generator-codestart/java/src/main/resources/openapi/openapi.yml rename to server/runtime/src/main/codestarts/quarkus/openapi-generator-server-codestart/java/src/main/resources/openapi/openapi.yml From 23fb7d4310ccd2c4d868a968eb9126019ce7fe16 Mon Sep 17 00:00:00 2001 From: Matheus Cruz Date: Mon, 7 Jul 2025 21:21:28 -0300 Subject: [PATCH 3/3] Adjust pom.xml --- server/integration-tests/codestarts/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/integration-tests/codestarts/pom.xml b/server/integration-tests/codestarts/pom.xml index 6f1941e5f..c4d0df180 100644 --- a/server/integration-tests/codestarts/pom.xml +++ b/server/integration-tests/codestarts/pom.xml @@ -4,7 +4,7 @@ quarkus-openapi-generator-server-integration-tests-parent io.quarkiverse.openapi.generator - 3.0.0-SNAPSHOT + 3.0.0-lts-SNAPSHOT ../pom.xml 4.0.0