From 6a4c99fcc2bf9a44356f964ca06439e2291f5c36 Mon Sep 17 00:00:00 2001 From: Maximilian Zellhofer Date: Tue, 15 Aug 2023 22:18:46 +0200 Subject: [PATCH] Response for individual operations (#426) * Improved return-response tests Signed-off-by: Helber Belmiro * Return `Response` instead of `void` (#386) * Apply suggestions from code review * Apply suggestions from code review --------- Signed-off-by: Helber Belmiro Co-authored-by: Helber Belmiro --- .../src/main/resources/templates/api.qute | 6 +- ...-response-false-string-simple-openapi.yaml | 274 ++++++++++++++++++ ...rn-response-false-void-simple-openapi.yaml | 270 +++++++++++++++++ ...n-response-true-string-simple-openapi.yaml | 274 ++++++++++++++++++ ...urn-response-true-void-simple-openapi.yaml | 270 +++++++++++++++++ ...response-false-string-simple-openapi.yaml} | 2 +- ...rn-response-false-void-simple-openapi.yaml | 270 +++++++++++++++++ ...-response-true-string-simple-openapi.yaml} | 2 +- ...urn-response-true-void-simple-openapi.yaml | 270 +++++++++++++++++ .../src/main/resources/application.properties | 31 +- .../generator/it/ReturnResponseTest.java | 62 +++- 11 files changed, 1719 insertions(+), 12 deletions(-) create mode 100644 integration-tests/return-response/src/main/openapi/mutiny-return-response-false-string-simple-openapi.yaml create mode 100644 integration-tests/return-response/src/main/openapi/mutiny-return-response-false-void-simple-openapi.yaml create mode 100644 integration-tests/return-response/src/main/openapi/mutiny-return-response-true-string-simple-openapi.yaml create mode 100644 integration-tests/return-response/src/main/openapi/mutiny-return-response-true-void-simple-openapi.yaml rename integration-tests/return-response/src/main/openapi/{response-simple-openapi.yaml => return-response-false-string-simple-openapi.yaml} (99%) create mode 100644 integration-tests/return-response/src/main/openapi/return-response-false-void-simple-openapi.yaml rename integration-tests/return-response/src/main/openapi/{model-simple-openapi.yaml => return-response-true-string-simple-openapi.yaml} (99%) create mode 100644 integration-tests/return-response/src/main/openapi/return-response-true-void-simple-openapi.yaml diff --git a/deployment/src/main/resources/templates/api.qute b/deployment/src/main/resources/templates/api.qute index a98e8e25..a181d478 100644 --- a/deployment/src/main/resources/templates/api.qute +++ b/deployment/src/main/resources/templates/api.qute @@ -76,7 +76,7 @@ public interface {classname} { public io.smallrye.mutiny.Uni {op.nickname}( {#else} {#if op.returnType == "void"} - public {#if op.returnType}io.smallrye.mutiny.Uni{#else}io.smallrye.mutiny.Uni{/if} {op.nickname}( + public io.smallrye.mutiny.Uni {op.nickname}( {#else} public {#if op.returnType}io.smallrye.mutiny.Uni<{op.returnType}>{#else}io.smallrye.mutiny.Uni{/if} {op.nickname}( {/if} @@ -85,7 +85,11 @@ public interface {classname} { {#if return-response} public jakarta.ws.rs.core.Response {op.nickname}( {#else} + {#if op.returnType == "void"} + public jakarta.ws.rs.core.Response {op.nickname}( + {#else} public {#if op.returnType}{op.returnType}{#else}jakarta.ws.rs.core.Response{/if} {op.nickname}( + {/if} {/if} {/if} {#if op.hasFormParams} diff --git a/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-string-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-string-simple-openapi.yaml new file mode 100644 index 00000000..8783ba2e --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-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: + - MutinyReturnResponseFalseString + 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/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-void-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-void-simple-openapi.yaml new file mode 100644 index 00000000..49793aa7 --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/mutiny-return-response-false-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: + - MutinyReturnResponseFalseVoid + 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/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-string-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-string-simple-openapi.yaml new file mode 100644 index 00000000..96610eb0 --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-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: + - MutinyReturnResponseTrueString + 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/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-void-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-void-simple-openapi.yaml new file mode 100644 index 00000000..04c0cbad --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/mutiny-return-response-true-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: + - MutinyReturnResponseTrueVoid + 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/integration-tests/return-response/src/main/openapi/response-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/return-response-false-string-simple-openapi.yaml similarity index 99% rename from integration-tests/return-response/src/main/openapi/response-simple-openapi.yaml rename to integration-tests/return-response/src/main/openapi/return-response-false-string-simple-openapi.yaml index 8f2152fd..4053167d 100644 --- a/integration-tests/return-response/src/main/openapi/response-simple-openapi.yaml +++ b/integration-tests/return-response/src/main/openapi/return-response-false-string-simple-openapi.yaml @@ -21,7 +21,7 @@ paths: /hello: get: tags: - - Response + - ReturnResponseFalseString operationId: hello responses: "200": diff --git a/integration-tests/return-response/src/main/openapi/return-response-false-void-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/return-response-false-void-simple-openapi.yaml new file mode 100644 index 00000000..21beab1a --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/return-response-false-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: + - ReturnResponseFalseVoid + 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/integration-tests/return-response/src/main/openapi/model-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/return-response-true-string-simple-openapi.yaml similarity index 99% rename from integration-tests/return-response/src/main/openapi/model-simple-openapi.yaml rename to integration-tests/return-response/src/main/openapi/return-response-true-string-simple-openapi.yaml index 8eda18d8..f76e9ffa 100644 --- a/integration-tests/return-response/src/main/openapi/model-simple-openapi.yaml +++ b/integration-tests/return-response/src/main/openapi/return-response-true-string-simple-openapi.yaml @@ -21,7 +21,7 @@ paths: /hello: get: tags: - - Model + - ReturnResponseTrueString operationId: hello responses: "200": diff --git a/integration-tests/return-response/src/main/openapi/return-response-true-void-simple-openapi.yaml b/integration-tests/return-response/src/main/openapi/return-response-true-void-simple-openapi.yaml new file mode 100644 index 00000000..0e32db75 --- /dev/null +++ b/integration-tests/return-response/src/main/openapi/return-response-true-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/integration-tests/return-response/src/main/resources/application.properties b/integration-tests/return-response/src/main/resources/application.properties index be73002d..970c6984 100644 --- a/integration-tests/return-response/src/main/resources/application.properties +++ b/integration-tests/return-response/src/main/resources/application.properties @@ -1,4 +1,29 @@ -quarkus.openapi-generator.codegen.spec.model_simple_openapi_yaml.base-package=org.acme.openapi +quarkus.openapi-generator.codegen.spec.return_response_false_string_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.return_response_false_void_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.return_response_true_string_simple_openapi_yaml.base-package = org.acme.openapi +quarkus.openapi-generator.codegen.spec.return_response_true_void_simple_openapi_yaml.base-package = org.acme.openapi -quarkus.openapi-generator.codegen.spec.response_simple_openapi_yaml.base-package=org.acme.openapi -quarkus.openapi-generator.codegen.spec.response_simple_openapi_yaml.return-response=true \ No newline at end of file +quarkus.openapi-generator.codegen.spec.return_response_false_string_simple_openapi_yaml.return-response = false +quarkus.openapi-generator.codegen.spec.return_response_false_void_simple_openapi_yaml.return-response = false +quarkus.openapi-generator.codegen.spec.return_response_true_string_simple_openapi_yaml.return-response = true +quarkus.openapi-generator.codegen.spec.return_response_true_void_simple_openapi_yaml.return-response = true + +quarkus.openapi-generator.codegen.spec.return_response_false_string_simple_openapi_yaml.mutiny = false +quarkus.openapi-generator.codegen.spec.return_response_false_void_simple_openapi_yaml.mutiny = false +quarkus.openapi-generator.codegen.spec.return_response_true_string_simple_openapi_yaml.mutiny = false +quarkus.openapi-generator.codegen.spec.return_response_true_void_simple_openapi_yaml.mutiny = false + +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_string_simple_openapi_yaml.base-package = ${quarkus.openapi-generator.codegen.spec.return_response_false_string_simple_openapi_yaml.base-package} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_void_simple_openapi_yaml.base-package = ${quarkus.openapi-generator.codegen.spec.return_response_false_void_simple_openapi_yaml.base-package} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_string_simple_openapi_yaml.base-package = ${quarkus.openapi-generator.codegen.spec.return_response_true_string_simple_openapi_yaml.base-package} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_void_simple_openapi_yaml.base-package = ${quarkus.openapi-generator.codegen.spec.return_response_true_void_simple_openapi_yaml.base-package} + +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_string_simple_openapi_yaml.return-response = ${quarkus.openapi-generator.codegen.spec.return_response_false_string_simple_openapi_yaml.return-response} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_void_simple_openapi_yaml.return-response = ${quarkus.openapi-generator.codegen.spec.return_response_false_void_simple_openapi_yaml.return-response} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_string_simple_openapi_yaml.return-response = ${quarkus.openapi-generator.codegen.spec.return_response_true_string_simple_openapi_yaml.return-response} +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_void_simple_openapi_yaml.return-response = ${quarkus.openapi-generator.codegen.spec.return_response_true_void_simple_openapi_yaml.return-response} + +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_string_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_return_response_false_void_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_string_simple_openapi_yaml.mutiny = true +quarkus.openapi-generator.codegen.spec.mutiny_return_response_true_void_simple_openapi_yaml.mutiny = true diff --git a/integration-tests/return-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnResponseTest.java b/integration-tests/return-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnResponseTest.java index 242ae37e..52bca908 100644 --- a/integration-tests/return-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnResponseTest.java +++ b/integration-tests/return-response/src/test/java/io/quarkiverse/openapi/generator/it/ReturnResponseTest.java @@ -4,8 +4,14 @@ import jakarta.ws.rs.core.Response; -import org.acme.openapi.api.ModelApi; -import org.acme.openapi.api.ResponseApi; +import org.acme.openapi.api.MutinyReturnResponseFalseStringApi; +import org.acme.openapi.api.MutinyReturnResponseFalseVoidApi; +import org.acme.openapi.api.MutinyReturnResponseTrueStringApi; +import org.acme.openapi.api.MutinyReturnResponseTrueVoidApi; +import org.acme.openapi.api.ReturnResponseFalseStringApi; +import org.acme.openapi.api.ReturnResponseFalseVoidApi; +import org.acme.openapi.api.ReturnResponseTrueStringApi; +import org.acme.openapi.api.ReturnResponseTrueVoidApi; import org.junit.jupiter.api.Test; import io.quarkus.test.junit.QuarkusTest; @@ -14,14 +20,58 @@ class ReturnResponseTest { @Test - void testModel() throws NoSuchMethodException { - assertThat(ModelApi.class.getMethod("hello").getReturnType()) + void testReturnResponseFalseString() throws NoSuchMethodException { + var method = ReturnResponseFalseStringApi.class.getMethod("hello"); + assertThat(method.getReturnType()) .isEqualTo(String.class); } @Test - void testResponse() throws NoSuchMethodException { - assertThat(ResponseApi.class.getMethod("hello").getReturnType()) + void testReturnResponseTrueString() throws NoSuchMethodException { + var method = ReturnResponseTrueStringApi.class.getMethod("hello"); + assertThat(method.getReturnType()) .isEqualTo(Response.class); } + + @Test + void testReturnResponseFalseVoid() throws NoSuchMethodException { + var method = ReturnResponseFalseVoidApi.class.getMethod("hello"); + assertThat(method.getReturnType()) + .isEqualTo(Response.class); + } + + @Test + void testReturnResponseTrueVoid() throws NoSuchMethodException { + var method = ReturnResponseTrueVoidApi.class.getMethod("hello"); + assertThat(method.getReturnType()) + .isEqualTo(Response.class); + } + + @Test + void testMutinyReturnResponseFalseString() throws NoSuchMethodException { + var method = MutinyReturnResponseFalseStringApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni"); + } + + @Test + void testMutinyReturnResponseTrueString() throws NoSuchMethodException { + var method = MutinyReturnResponseTrueStringApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni"); + } + + @Test + void testMutinyReturnResponseFalseVoid() throws NoSuchMethodException { + var method = MutinyReturnResponseFalseVoidApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni"); + } + + @Test + void testMutinyReturnResponseTrueVoid() throws NoSuchMethodException { + var method = MutinyReturnResponseTrueVoidApi.class.getMethod("hello"); + assertThat(method.getGenericReturnType().getTypeName()) + .isEqualTo("io.smallrye.mutiny.Uni"); + } }