From 22c6a1f3ae455355c162467f6a2f04fb1f9198de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ben=20Zeller=C3=B6hr?= <79644542+BB223@users.noreply.github.com> Date: Wed, 19 Nov 2025 16:56:48 +0100 Subject: [PATCH 1/2] feat: support RestResponse (#1381) * feat: support RestResponse * chore: clarify default response type --- .../deployment/CommonItemConfig.java | 23 +- .../codegen/OpenApiGeneratorCodeGenBase.java | 9 +- .../OpenApiClientGeneratorWrapper.java | 18 +- .../templates/libraries/microprofile/api.qute | 42 ++- .../mutiny-return-rest-response/pom.xml | 93 ++++++ ...se-restresponse-string-simple-openapi.yaml | 274 ++++++++++++++++++ ...onse-restresponse-void-simple-openapi.yaml | 270 +++++++++++++++++ ...se-restresponse-string-simple-openapi.yaml | 274 ++++++++++++++++++ ...onse-restresponse-void-simple-openapi.yaml | 270 +++++++++++++++++ .../src/main/resources/application.properties | 20 ++ .../it/MutinyReturnRestResponseTest.java | 44 +++ client/integration-tests/pom.xml | 4 + .../return-rest-response/pom.xml | 93 ++++++ ...se-restresponse-string-simple-openapi.yaml | 274 ++++++++++++++++++ ...onse-restresponse-void-simple-openapi.yaml | 270 +++++++++++++++++ .../src/main/resources/application.properties | 10 + .../generator/it/ReturnRestResponseTest.java | 27 ++ ...i-generator_quarkus.openapi-generator.adoc | 28 +- .../includes/return-response-objects.adoc | 15 +- 19 files changed, 2020 insertions(+), 38 deletions(-) create mode 100644 client/integration-tests/mutiny-return-rest-response/pom.xml create mode 100644 client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-string-simple-openapi.yaml create mode 100644 client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-void-simple-openapi.yaml create mode 100644 client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-string-simple-openapi.yaml create mode 100644 client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-void-simple-openapi.yaml create mode 100644 client/integration-tests/mutiny-return-rest-response/src/main/resources/application.properties create mode 100644 client/integration-tests/mutiny-return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/MutinyReturnRestResponseTest.java create mode 100644 client/integration-tests/return-rest-response/pom.xml create mode 100644 client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-string-simple-openapi.yaml create mode 100644 client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-void-simple-openapi.yaml create mode 100644 client/integration-tests/return-rest-response/src/main/resources/application.properties create mode 100644 client/integration-tests/return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnRestResponseTest.java diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java index 218ef12e5..af5204ec4 100644 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/CommonItemConfig.java @@ -67,10 +67,11 @@ public interface CommonItemConfig { Optional additionalRequestArgs(); /** - * Defines if the methods should return {@link jakarta.ws.rs.core.Response} or a model. Default is {@code false}. + * Defines if the methods should return {@link jakarta.ws.rs.core.Response}, + * {@link org.jboss.resteasy.reactive.RestResponse} or a model. By default, it returns the model in the specification. */ @WithName("return-response") - Optional returnResponse(); + Optional returnResponse(); /** * Defines if security support classes should be generated @@ -92,11 +93,11 @@ public interface CommonItemConfig { Optional supportMutiny(); /** - * Defines with SmallRye Mutiny enabled if methods should return {@link jakarta.ws.rs.core.Response} or a model. Default is - * {@code false}. + * Defines with SmallRye Mutiny enabled if methods should return {@link jakarta.ws.rs.core.Response}, + * {@link org.jboss.resteasy.reactive.RestResponse} or a model. By default, it returns the model in the specification. */ @WithName("mutiny.return-response") - Optional mutinyReturnResponse(); + Optional mutinyReturnResponse(); /** * Handles the return type for each operation, depending on the configuration. @@ -107,6 +108,10 @@ public interface CommonItemConfig { * - If {@code mutiny.return-response} is enabled, the return type will be * {@link io.smallrye.mutiny.Multi}. * - If the operation has a void return type, it will return {@link io.smallrye.mutiny.Multi}. + * - If {@code mutiny.return-response} is set to {@code RestResponse}, the return type will be + * {@link io.smallrye.mutiny.Multi>}. + * - If the operation has a void return type, it will return + * {@link io.smallrye.mutiny.Multi>}. * - Otherwise, it will return {@link io.smallrye.mutiny.Multi}. *

* 2. If {@code mutiny} is enabled and the operation ID is specified to return {@code Uni}: @@ -114,6 +119,10 @@ public interface CommonItemConfig { * - If {@code mutiny.return-response} is enabled, the return type will be * {@link io.smallrye.mutiny.Uni}. * - If the operation has a void return type, it will return {@link io.smallrye.mutiny.Uni}. + * - If {@code mutiny.return-response} is set to {@code RestResponse}, the return type will be + * {@link io.smallrye.mutiny.Uni>}. + * - If the operation has a void return type, it will return + * {@link io.smallrye.mutiny.Uni>}. * - Otherwise, it will return {@link io.smallrye.mutiny.Uni}. *

* 3. If {@code mutiny} is enabled but no specific operation ID is configured for {@code Multi} or {@code Uni}: @@ -121,6 +130,10 @@ public interface CommonItemConfig { * - If {@code mutiny.return-response} is enabled, the return type will be * {@link io.smallrye.mutiny.Uni}. * - If the operation has a void return type, it will return {@link io.smallrye.mutiny.Uni}. + * - If {@code mutiny.return-response} is set to {@code RestResponse}, the return type will be + * {@link io.smallrye.mutiny.Uni>}. + * - If the operation has a void return type, it will return + * {@link io.smallrye.mutiny.Uni>}. * - Otherwise, it will return {@link io.smallrye.mutiny.Uni}`. */ @WithName("mutiny.operation-ids") diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java index c1bd7376e..fe4f9389e 100644 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/codegen/OpenApiGeneratorCodeGenBase.java @@ -279,12 +279,11 @@ protected void generate(OpenApiGeneratorOptions options) { .ifPresentOrElse(generator::withConfigKey, () -> generator.withConfigKey(getSanitizedFileName(openApiFilePath))); - generator.withReturnResponse( - getValues(config, openApiFilePath, CodegenConfig.ConfigName.RETURN_RESPONSE, Boolean.class).orElse(false)); + getValues(config, openApiFilePath, CodegenConfig.ConfigName.RETURN_RESPONSE, String.class) + .ifPresent(generator::withReturnResponse); - generator.withMutinyReturnResponse( - getValues(config, openApiFilePath, CodegenConfig.ConfigName.MUTINY_RETURN_RESPONSE, Boolean.class) - .orElse(false)); + getValues(config, openApiFilePath, CodegenConfig.ConfigName.MUTINY_RETURN_RESPONSE, String.class) + .ifPresent(generator::withMutinyReturnResponse); generator.withEnabledSecurityGeneration( getValues(config, openApiFilePath, CodegenConfig.ConfigName.ENABLE_SECURITY_GENERATION, Boolean.class) diff --git a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java index ee9b94e21..c59264d10 100644 --- a/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java +++ b/client/deployment/src/main/java/io/quarkiverse/openapi/generator/deployment/wrapper/OpenApiClientGeneratorWrapper.java @@ -143,10 +143,12 @@ public OpenApiClientGeneratorWrapper withMutiny(final Boolean config) { return this; } - public OpenApiClientGeneratorWrapper withMutinyReturnResponse(final Boolean config) { - Optional.ofNullable(config).ifPresent(cfg -> { - this.configurator.addAdditionalProperty("mutiny-return-response", cfg); - }); + public OpenApiClientGeneratorWrapper withMutinyReturnResponse(final String config) { + if (config.equalsIgnoreCase(TRUE.toString())) { + this.configurator.addAdditionalProperty("mutiny-return-response", "Response"); + } else { + this.configurator.addAdditionalProperty("mutiny-return-response", config); + } return this; } @@ -174,8 +176,12 @@ public OpenApiClientGeneratorWrapper withTypeMappings(final Map return this; } - public OpenApiClientGeneratorWrapper withReturnResponse(Boolean returnResponse) { - configurator.addAdditionalProperty("return-response", returnResponse); + public OpenApiClientGeneratorWrapper withReturnResponse(String returnResponse) { + if (returnResponse.equalsIgnoreCase(TRUE.toString())) { + this.configurator.addAdditionalProperty("return-response", "Response"); + } else { + this.configurator.addAdditionalProperty("return-response", returnResponse); + } return this; } diff --git a/client/deployment/src/main/resources/templates/libraries/microprofile/api.qute b/client/deployment/src/main/resources/templates/libraries/microprofile/api.qute index 214524aa8..cb9100977 100644 --- a/client/deployment/src/main/resources/templates/libraries/microprofile/api.qute +++ b/client/deployment/src/main/resources/templates/libraries/microprofile/api.qute @@ -61,8 +61,14 @@ public interface {classname} { {/if}{/for} {#if mutiny} {#if mutiny-operation-ids.get(op.operationIdOriginal) == "Multi"} - {#if mutiny-return-response} + {#if mutiny-return-response == "Response"} public io.smallrye.mutiny.Multi {op.nickname}( + {#else if mutiny-return-response == "RestResponse"} + {#if op.returnType == "void"} + public io.smallrye.mutiny.Multi> {op.nickname}( + {#else} + public io.smallrye.mutiny.Multi> {op.nickname}( + {/if} {#else} {#if op.returnType == "void"} public io.smallrye.mutiny.Multi {op.nickname}( @@ -72,8 +78,14 @@ public interface {classname} { {/if} {#else} {#if mutiny-operation-ids.get(op.operationIdOriginal) == "Uni"} - {#if mutiny-return-response} + {#if mutiny-return-response == "Response"} public io.smallrye.mutiny.Uni {op.nickname}( + {#else if mutiny-return-response == "RestResponse"} + {#if op.returnType == "void"} + public io.smallrye.mutiny.Uni> {op.nickname}( + {#else} + public io.smallrye.mutiny.Uni> {op.nickname}( + {/if} {#else} {#if op.returnType == "void"} public io.smallrye.mutiny.Uni {op.nickname}( @@ -83,8 +95,14 @@ public interface {classname} { {/if} {#else} {#if !mutiny-operation-ids} - {#if mutiny-return-response} + {#if mutiny-return-response == "Response"} public io.smallrye.mutiny.Uni {op.nickname}( + {#else if mutiny-return-response == "RestResponse"} + {#if op.returnType == "void"} + public io.smallrye.mutiny.Uni> {op.nickname}( + {#else} + public io.smallrye.mutiny.Uni> {op.nickname}( + {/if} {#else} {#if op.returnType == "void"} public io.smallrye.mutiny.Uni {op.nickname}( @@ -100,8 +118,14 @@ public interface {classname} { public {#if op.returnType}io.smallrye.mutiny.Uni<{op.returnType}>{#else}io.smallrye.mutiny.Uni{/if} {op.nickname}( {/if} {#else} - {#if return-response} + {#if return-response == "Response"} public jakarta.ws.rs.core.Response {op.nickname}( + {#else if return-response == "RestResponse"} + {#if op.returnType == "void"} + public org.jboss.resteasy.reactive.RestResponse {op.nickname}( + {#else} + public org.jboss.resteasy.reactive.RestResponse<{#if op.returnType}{op.returnType}{#else}Void{/if}> {op.nickname}( + {/if} {#else} {#if op.returnType == "void"} public jakarta.ws.rs.core.Response {op.nickname}( @@ -114,8 +138,14 @@ public interface {classname} { {/if} {/if} {#else} - {#if return-response} + {#if return-response == "Response"} public jakarta.ws.rs.core.Response {op.nickname}( + {#else if return-response == "RestResponse"} + {#if op.returnType == "void"} + public org.jboss.resteasy.reactive.RestResponse {op.nickname}( + {#else} + public org.jboss.resteasy.reactive.RestResponse<{#if op.returnType}{op.returnType}{#else}Void{/if}> {op.nickname}( + {/if} {#else} {#if op.returnType == "void"} public jakarta.ws.rs.core.Response {op.nickname}( @@ -164,4 +194,4 @@ public interface {classname} { {/if} {! check deprecated !} {/for} -} \ No newline at end of file +} diff --git a/client/integration-tests/mutiny-return-rest-response/pom.xml b/client/integration-tests/mutiny-return-rest-response/pom.xml new file mode 100644 index 000000000..0aa82068a --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/pom.xml @@ -0,0 +1,93 @@ + + + + quarkus-openapi-generator-integration-tests + io.quarkiverse.openapi.generator + 3.0.0-SNAPSHOT + + 4.0.0 + + quarkus-openapi-generator-it-mutiny-return-rest-response + Quarkus - OpenAPI Generator - Integration Tests - Client - Mutiny Return RestResponse + Example project for usage of the mutiny-return-response property + + + + io.quarkiverse.openapi.generator + quarkus-openapi-generator + + + org.assertj + assertj-core + test + + + io.quarkus + quarkus-junit5 + test + + + + + + io.quarkus + quarkus-maven-plugin + true + + + + build + generate-code + generate-code-tests + + + + + + + + + native-image + + + native + + + + + + maven-surefire-plugin + + ${native.surefire.skip} + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + ${project.build.directory}/${project.build.finalName}-runner + + org.jboss.logmanager.LogManager + + ${maven.home} + + + + + + + + + native + + + + + diff --git a/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-string-simple-openapi.yaml b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-string-simple-openapi.yaml new file mode 100644 index 000000000..fba0801d7 --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-string-simple-openapi.yaml @@ -0,0 +1,274 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - MutinyMultiReturnResponseRestResponseString + operationId: hello + responses: + "200": + description: OK + content: + text/plain: + schema: + type: string + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-void-simple-openapi.yaml b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-void-simple-openapi.yaml new file mode 100644 index 000000000..2bde5fc18 --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-multi-return-response-restresponse-void-simple-openapi.yaml @@ -0,0 +1,270 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - MutinyMultiReturnResponseRestResponseVoid + operationId: hello + responses: + "200": + description: OK + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-string-simple-openapi.yaml b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-string-simple-openapi.yaml new file mode 100644 index 000000000..90b042fd2 --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-string-simple-openapi.yaml @@ -0,0 +1,274 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - MutinyReturnResponseRestResponseString + operationId: hello + responses: + "200": + description: OK + content: + text/plain: + schema: + type: string + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-void-simple-openapi.yaml b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-void-simple-openapi.yaml new file mode 100644 index 000000000..67be5113a --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/main/openapi/mutiny-return-response-restresponse-void-simple-openapi.yaml @@ -0,0 +1,270 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - MutinyReturnResponseRestResponseVoid + operationId: hello + responses: + "200": + description: OK + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/mutiny-return-rest-response/src/main/resources/application.properties b/client/integration-tests/mutiny-return-rest-response/src/main/resources/application.properties new file mode 100644 index 000000000..c011ad8e8 --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/main/resources/application.properties @@ -0,0 +1,20 @@ +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_string_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_string_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_void_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_void_simple_openapi_yaml.base-package = org.acme.openapi + +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_string_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_string_simple_openapi_yaml.mutiny.return-response = RestResponse + +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_string_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_string_simple_openapi_yaml.mutiny.return-response = RestResponse +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_string_simple_openapi_yaml.mutiny.operation-ids.hello = Multi + +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_void_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_return_response_restresponse_void_simple_openapi_yaml.mutiny.return-response = RestResponse + +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_void_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_void_simple_openapi_yaml.mutiny.return-response = RestResponse +quarkus.openapi-generator.codegen.spec.mutiny_multi_return_response_restresponse_void_simple_openapi_yaml.mutiny.operation-ids.hello = Multi + +quarkus.keycloak.devservices.enabled=false diff --git a/client/integration-tests/mutiny-return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/MutinyReturnRestResponseTest.java b/client/integration-tests/mutiny-return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/MutinyReturnRestResponseTest.java new file mode 100644 index 000000000..bcbae3a60 --- /dev/null +++ b/client/integration-tests/mutiny-return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/MutinyReturnRestResponseTest.java @@ -0,0 +1,44 @@ +package io.quarkiverse.openapi.generator.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.acme.openapi.api.MutinyMultiReturnResponseRestResponseStringApi; +import org.acme.openapi.api.MutinyMultiReturnResponseRestResponseVoidApi; +import org.acme.openapi.api.MutinyReturnResponseRestResponseStringApi; +import org.acme.openapi.api.MutinyReturnResponseRestResponseVoidApi; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@Tag("resteasy-reactive") +class MutinyReturnResponseTest { + @Test + void testMutinyReturnResponseRestResponseString() throws NoSuchMethodException { + var method = MutinyReturnResponseRestResponseStringApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni>"); + } + + @Test + void testMutinyMultiReturnResponseRestResponseString() throws NoSuchMethodException { + var method = MutinyMultiReturnResponseRestResponseStringApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Multi>"); + } + + @Test + void testMutinyReturnResponseRestResponseVoid() throws NoSuchMethodException { + var method = MutinyReturnResponseRestResponseVoidApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni>"); + } + + @Test + void testMutinyMultiReturnResponseRestResponseVoid() throws NoSuchMethodException { + var method = MutinyMultiReturnResponseRestResponseVoidApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Multi>"); + } +} diff --git a/client/integration-tests/pom.xml b/client/integration-tests/pom.xml index d06956451..b9eea8e2d 100644 --- a/client/integration-tests/pom.xml +++ b/client/integration-tests/pom.xml @@ -114,6 +114,10 @@ resteasy-reactive + + mutiny-return-rest-response + return-rest-response + resteasy-reactive diff --git a/client/integration-tests/return-rest-response/pom.xml b/client/integration-tests/return-rest-response/pom.xml new file mode 100644 index 000000000..9943e8113 --- /dev/null +++ b/client/integration-tests/return-rest-response/pom.xml @@ -0,0 +1,93 @@ + + + + quarkus-openapi-generator-integration-tests + io.quarkiverse.openapi.generator + 3.0.0-SNAPSHOT + + 4.0.0 + + quarkus-openapi-generator-it-return-rest-response + Quarkus - OpenAPI Generator - Integration Tests - Client - Return RestResponse + Example project for usage of the return-response property + + + + io.quarkiverse.openapi.generator + quarkus-openapi-generator + + + org.assertj + assertj-core + test + + + io.quarkus + quarkus-junit5 + test + + + + + + io.quarkus + quarkus-maven-plugin + true + + + + build + generate-code + generate-code-tests + + + + + + + + + native-image + + + native + + + + + + maven-surefire-plugin + + ${native.surefire.skip} + + + + maven-failsafe-plugin + + + + integration-test + verify + + + + + ${project.build.directory}/${project.build.finalName}-runner + + org.jboss.logmanager.LogManager + + ${maven.home} + + + + + + + + + native + + + + + diff --git a/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-string-simple-openapi.yaml b/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-string-simple-openapi.yaml new file mode 100644 index 000000000..f76e9ffa2 --- /dev/null +++ b/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-string-simple-openapi.yaml @@ -0,0 +1,274 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - ReturnResponseTrueString + operationId: hello + responses: + "200": + description: OK + content: + text/plain: + schema: + type: string + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-void-simple-openapi.yaml b/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-void-simple-openapi.yaml new file mode 100644 index 000000000..0e32db759 --- /dev/null +++ b/client/integration-tests/return-rest-response/src/main/openapi/return-response-restresponse-void-simple-openapi.yaml @@ -0,0 +1,270 @@ +--- +openapi: 3.0.3 +info: + title: greeting-flow API + version: "1.0" +paths: + /: + post: + requestBody: + content: + '*/*': + schema: + $ref: '#/components/schemas/CloudEvent' + responses: + "200": + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/Response' + /hello: + get: + tags: + - ReturnResponseTrueVoid + operationId: hello + responses: + "200": + description: OK + /messaging/topics: + get: + tags: + - Quarkus Topics Information Resource + responses: + "200": + description: OK +components: + schemas: + CloudEvent: + type: object + properties: + specVersion: + $ref: '#/components/schemas/SpecVersion' + id: + type: string + type: + type: string + source: + format: uri + type: string + dataContentType: + type: string + dataSchema: + format: uri + type: string + subject: + type: string + time: + format: date-time + type: string + attributeNames: + uniqueItems: true + type: array + items: + type: string + extensionNames: + uniqueItems: true + type: array + items: + type: string + data: + $ref: '#/components/schemas/CloudEventData' + CloudEventData: + type: object + EntityTag: + type: object + properties: + value: + type: string + weak: + type: boolean + Family: + enum: + - INFORMATIONAL + - SUCCESSFUL + - REDIRECTION + - CLIENT_ERROR + - SERVER_ERROR + - OTHER + type: string + Link: + type: object + properties: + uri: + format: uri + type: string + uriBuilder: + $ref: '#/components/schemas/UriBuilder' + rel: + type: string + rels: + type: array + items: + type: string + title: + type: string + type: + type: string + params: + type: object + additionalProperties: + type: string + Locale: + type: object + properties: + language: + type: string + script: + type: string + country: + type: string + variant: + type: string + extensionKeys: + uniqueItems: true + type: array + items: + format: byte + type: string + unicodeLocaleAttributes: + uniqueItems: true + type: array + items: + type: string + unicodeLocaleKeys: + uniqueItems: true + type: array + items: + type: string + iSO3Language: + type: string + iSO3Country: + type: string + displayLanguage: + type: string + displayScript: + type: string + displayCountry: + type: string + displayVariant: + type: string + displayName: + type: string + MediaType: + type: object + properties: + type: + type: string + subtype: + type: string + parameters: + type: object + additionalProperties: + type: string + wildcardType: + type: boolean + wildcardSubtype: + type: boolean + MultivaluedMapStringObject: + type: object + additionalProperties: + type: array + items: + type: object + MultivaluedMapStringString: + type: object + additionalProperties: + type: array + items: + type: string + NewCookie: + type: object + properties: + name: + type: string + value: + type: string + version: + format: int32 + type: integer + path: + type: string + domain: + type: string + comment: + type: string + maxAge: + format: int32 + type: integer + expiry: + format: date + type: string + secure: + type: boolean + httpOnly: + type: boolean + Response: + type: object + properties: + status: + format: int32 + type: integer + statusInfo: + $ref: '#/components/schemas/StatusType' + entity: + type: object + mediaType: + $ref: '#/components/schemas/MediaType' + language: + $ref: '#/components/schemas/Locale' + length: + format: int32 + type: integer + allowedMethods: + uniqueItems: true + type: array + items: + type: string + cookies: + type: object + additionalProperties: + $ref: '#/components/schemas/NewCookie' + entityTag: + $ref: '#/components/schemas/EntityTag' + date: + format: date + type: string + lastModified: + format: date + type: string + location: + format: uri + type: string + links: + uniqueItems: true + type: array + items: + $ref: '#/components/schemas/Link' + metadata: + $ref: '#/components/schemas/MultivaluedMapStringObject' + headers: + $ref: '#/components/schemas/MultivaluedMapStringObject' + stringHeaders: + $ref: '#/components/schemas/MultivaluedMapStringString' + SpecVersion: + enum: + - V03 + - V1 + type: string + StatusType: + type: object + properties: + statusCode: + format: int32 + type: integer + family: + $ref: '#/components/schemas/Family' + reasonPhrase: + type: string + UriBuilder: + type: object diff --git a/client/integration-tests/return-rest-response/src/main/resources/application.properties b/client/integration-tests/return-rest-response/src/main/resources/application.properties new file mode 100644 index 000000000..ce1e9ad80 --- /dev/null +++ b/client/integration-tests/return-rest-response/src/main/resources/application.properties @@ -0,0 +1,10 @@ +quarkus.openapi-generator.codegen.spec.return_response_restresponse_string_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.return_response_restresponse_void_simple_openapi_yaml.base-package = org.acme.openapi + +quarkus.openapi-generator.codegen.spec.return_response_restresponse_string_simple_openapi_yaml.return-response = RestResponse +quarkus.openapi-generator.codegen.spec.return_response_restresponse_void_simple_openapi_yaml.return-response = RestResponse + +quarkus.openapi-generator.codegen.spec.return_response_restresponse_string_simple_openapi_yaml.mutiny = false +quarkus.openapi-generator.codegen.spec.return_response_restresponse_void_simple_openapi_yaml.mutiny = false + +quarkus.keycloak.devservices.enabled=false diff --git a/client/integration-tests/return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnRestResponseTest.java b/client/integration-tests/return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnRestResponseTest.java new file mode 100644 index 000000000..6a5013cfd --- /dev/null +++ b/client/integration-tests/return-rest-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnRestResponseTest.java @@ -0,0 +1,27 @@ +package io.quarkiverse.openapi.generator.it; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.acme.openapi.api.ReturnResponseTrueStringApi; +import org.acme.openapi.api.ReturnResponseTrueVoidApi; +import org.junit.jupiter.api.Test; + +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +class ReturnResponseTest { + + @Test + void testReturnResponseRestResponseString() throws NoSuchMethodException { + var method = ReturnResponseTrueStringApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("org.jboss.resteasy.reactive.RestResponse"); + } + + @Test + void testReturnResponseRestResponseVoid() throws NoSuchMethodException { + var method = ReturnResponseTrueVoidApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("org.jboss.resteasy.reactive.RestResponse"); + } +} diff --git a/docs/modules/ROOT/pages/includes/quarkus-openapi-generator_quarkus.openapi-generator.adoc b/docs/modules/ROOT/pages/includes/quarkus-openapi-generator_quarkus.openapi-generator.adoc index f22852d08..4ea932edd 100644 --- a/docs/modules/ROOT/pages/includes/quarkus-openapi-generator_quarkus.openapi-generator.adoc +++ b/docs/modules/ROOT/pages/includes/quarkus-openapi-generator_quarkus.openapi-generator.adoc @@ -183,7 +183,7 @@ endif::add-copy-button-to-config-props[] [.description] -- -Defines if the methods should return `jakarta.ws.rs.core.Response` or a model. Default is `false`. +Defines if the methods should return `jakarta.ws.rs.core.Response`, `org.jboss.resteasy.reactive.RestResponse` or a model. By default, it returns the model in the specification. ifdef::add-copy-button-to-env-var[] @@ -193,7 +193,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_CODEGEN_RETURN_RESPONSE+++` endif::add-copy-button-to-env-var[] -- -|boolean +|string | a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator_quarkus-openapi-generator-codegen-enable-security-generation]] [.property-path]##link:#quarkus-openapi-generator_quarkus-openapi-generator-codegen-enable-security-generation[`quarkus.openapi-generator.codegen.enable-security-generation`]## @@ -267,7 +267,7 @@ endif::add-copy-button-to-config-props[] [.description] -- -Defines with SmallRye Mutiny enabled if methods should return `jakarta.ws.rs.core.Response` or a model. Default is `false`. +Defines with SmallRye Mutiny enabled if methods should return `jakarta.ws.rs.core.Response`, `org.jboss.resteasy.reactive.RestResponse` or a model. By default, it returns the model in the specification. ifdef::add-copy-button-to-env-var[] @@ -277,7 +277,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_CODEGEN_MUTINY_RETURN_RESPONSE+++` endif::add-copy-button-to-env-var[] -- -|boolean +|string | a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator_quarkus-openapi-generator-codegen-mutiny-operation-ids-mutiny-multi-operation-ids]] [.property-path]##link:#quarkus-openapi-generator_quarkus-openapi-generator-codegen-mutiny-operation-ids-mutiny-multi-operation-ids[`quarkus.openapi-generator.codegen.mutiny.operation-ids."mutiny-multi-operation-ids"`]## @@ -290,11 +290,11 @@ endif::add-copy-button-to-config-props[] -- Handles the return type for each operation, depending on the configuration. The following cases are supported: -1. If `mutiny` is enabled and the operation ID is specified to return `Multi`: - The return type will be wrapped in `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Multi`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi`. - Otherwise, it will return `io.smallrye.mutiny.Multi`. +1. If `mutiny` is enabled and the operation ID is specified to return `Multi`: - The return type will be wrapped in `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Multi`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Multi>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi>`. - Otherwise, it will return `io.smallrye.mutiny.Multi`. -2. If `mutiny` is enabled and the operation ID is specified to return `Uni`: - The return type will be wrapped in `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - Otherwise, it will return `io.smallrye.mutiny.Uni`. +2. If `mutiny` is enabled and the operation ID is specified to return `Uni`: - The return type will be wrapped in `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Uni>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni>`. - Otherwise, it will return `io.smallrye.mutiny.Uni`. -3. If `mutiny` is enabled but no specific operation ID is configured for `Multi` or `Uni`: - The return type defaults to `Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - Otherwise, it will return `io.smallrye.mutiny.Uni``. +3. If `mutiny` is enabled but no specific operation ID is configured for `Multi` or `Uni`: - The return type defaults to `Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Uni>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni>`. - Otherwise, it will return `io.smallrye.mutiny.Uni``. ifdef::add-copy-button-to-env-var[] @@ -882,7 +882,7 @@ endif::add-copy-button-to-config-props[] [.description] -- -Defines if the methods should return `jakarta.ws.rs.core.Response` or a model. Default is `false`. +Defines if the methods should return `jakarta.ws.rs.core.Response`, `org.jboss.resteasy.reactive.RestResponse` or a model. By default, it returns the model in the specification. ifdef::add-copy-button-to-env-var[] @@ -892,7 +892,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_CODEGEN_SPEC__SPEC_ITEM__RETURN_RESPONSE+++` endif::add-copy-button-to-env-var[] -- -|boolean +|string | a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator_quarkus-openapi-generator-codegen-spec-spec-item-enable-security-generation]] [.property-path]##link:#quarkus-openapi-generator_quarkus-openapi-generator-codegen-spec-spec-item-enable-security-generation[`quarkus.openapi-generator.codegen.spec."spec-item".enable-security-generation`]## @@ -966,7 +966,7 @@ endif::add-copy-button-to-config-props[] [.description] -- -Defines with SmallRye Mutiny enabled if methods should return `jakarta.ws.rs.core.Response` or a model. Default is `false`. +Defines with SmallRye Mutiny enabled if methods should return `jakarta.ws.rs.core.Response`, `org.jboss.resteasy.reactive.RestResponse` or a model. By default, it returns the model in the specification. ifdef::add-copy-button-to-env-var[] @@ -976,7 +976,7 @@ ifndef::add-copy-button-to-env-var[] Environment variable: `+++QUARKUS_OPENAPI_GENERATOR_CODEGEN_SPEC__SPEC_ITEM__MUTINY_RETURN_RESPONSE+++` endif::add-copy-button-to-env-var[] -- -|boolean +|string | a|icon:lock[title=Fixed at build time] [[quarkus-openapi-generator_quarkus-openapi-generator-codegen-spec-spec-item-mutiny-operation-ids-mutiny-multi-operation-ids]] [.property-path]##link:#quarkus-openapi-generator_quarkus-openapi-generator-codegen-spec-spec-item-mutiny-operation-ids-mutiny-multi-operation-ids[`quarkus.openapi-generator.codegen.spec."spec-item".mutiny.operation-ids."mutiny-multi-operation-ids"`]## @@ -989,11 +989,11 @@ endif::add-copy-button-to-config-props[] -- Handles the return type for each operation, depending on the configuration. The following cases are supported: -1. If `mutiny` is enabled and the operation ID is specified to return `Multi`: - The return type will be wrapped in `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Multi`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi`. - Otherwise, it will return `io.smallrye.mutiny.Multi`. +1. If `mutiny` is enabled and the operation ID is specified to return `Multi`: - The return type will be wrapped in `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Multi`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Multi>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Multi>`. - Otherwise, it will return `io.smallrye.mutiny.Multi`. -2. If `mutiny` is enabled and the operation ID is specified to return `Uni`: - The return type will be wrapped in `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - Otherwise, it will return `io.smallrye.mutiny.Uni`. +2. If `mutiny` is enabled and the operation ID is specified to return `Uni`: - The return type will be wrapped in `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Uni>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni>`. - Otherwise, it will return `io.smallrye.mutiny.Uni`. -3. If `mutiny` is enabled but no specific operation ID is configured for `Multi` or `Uni`: - The return type defaults to `Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - Otherwise, it will return `io.smallrye.mutiny.Uni``. +3. If `mutiny` is enabled but no specific operation ID is configured for `Multi` or `Uni`: - The return type defaults to `Uni`. - If `mutiny.return-response` is enabled, the return type will be `io.smallrye.mutiny.Uni`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni`. - If `mutiny.return-response` is set to `RestResponse`, the return type will be `io.smallrye.mutiny.Uni>`. - If the operation has a void return type, it will return `io.smallrye.mutiny.Uni>`. - Otherwise, it will return `io.smallrye.mutiny.Uni``. ifdef::add-copy-button-to-env-var[] diff --git a/docs/modules/ROOT/pages/includes/return-response-objects.adoc b/docs/modules/ROOT/pages/includes/return-response-objects.adoc index 4a10de5ba..6a92bd0f2 100644 --- a/docs/modules/ROOT/pages/includes/return-response-objects.adoc +++ b/docs/modules/ROOT/pages/includes/return-response-objects.adoc @@ -1,6 +1,6 @@ By default, this extension generates the methods according to their returning models based on the https://spec.openapis.org/oas/v3.1.0#schema-object[OpenAPI specification Schema Object]. If no response model is defined, `jakarta.ws.rs.core.Response` is returned. -If you want to return `jakarta.ws.rs.core.Response` in _all_ cases instead, you can set the `return-response` property to `true`. +If you want to return `jakarta.ws.rs.core.Response` in _all_ cases instead, you can set the `return-response` property to `Response` or `true`. == Example @@ -9,4 +9,15 @@ Given you want to return `jakarta.ws.rs.core.Response` for the `my-openapi.yaml` [source,properties] ---- quarkus.openapi-generator.codegen.spec.my_openapi_yaml.return-response=true ----- \ No newline at end of file +---- + +If you want to return `org.jboss.resteasy.reactive.RestResponse` in _all_ cases instead, you can set the `return-response` property to `RestResponse`. + +== Example + +Given you want to return `org.jboss.resteasy.reactive.RestResponse` for the `my-openapi.yaml` file, you must add the following to your `application.properties` file: + +[source,properties] +---- +quarkus.openapi-generator.codegen.spec.my_openapi_yaml.return-response=RestResponse +---- From 30c6d668fff2664d40af732d38f38dd4db660f10 Mon Sep 17 00:00:00 2001 From: Ricardo Zanini <1538000+ricardozanini@users.noreply.github.com> Date: Wed, 19 Nov 2025 11:06:23 -0500 Subject: [PATCH 2/2] Add -lts suffix to versions --- client/integration-tests/mutiny-return-rest-response/pom.xml | 2 +- client/integration-tests/return-rest-response/pom.xml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/integration-tests/mutiny-return-rest-response/pom.xml b/client/integration-tests/mutiny-return-rest-response/pom.xml index 0aa82068a..e70fa9a61 100644 --- a/client/integration-tests/mutiny-return-rest-response/pom.xml +++ b/client/integration-tests/mutiny-return-rest-response/pom.xml @@ -3,7 +3,7 @@ quarkus-openapi-generator-integration-tests io.quarkiverse.openapi.generator - 3.0.0-SNAPSHOT + 3.0.0-lts-SNAPSHOT 4.0.0 diff --git a/client/integration-tests/return-rest-response/pom.xml b/client/integration-tests/return-rest-response/pom.xml index 9943e8113..01aae50f7 100644 --- a/client/integration-tests/return-rest-response/pom.xml +++ b/client/integration-tests/return-rest-response/pom.xml @@ -3,7 +3,7 @@ quarkus-openapi-generator-integration-tests io.quarkiverse.openapi.generator - 3.0.0-SNAPSHOT + 3.0.0-lts-SNAPSHOT 4.0.0