[java][jaxrs-spec][quarkus] Add @ResponseStatus annotation HTTP success codes#23628
[java][jaxrs-spec][quarkus] Add @ResponseStatus annotation HTTP success codes#23628Ignacio-Vidal wants to merge 5 commits intoOpenAPITools:masterfrom
Conversation
|
please follow step 3 to update the samples. |
|
I will try again and post here once completed. I noticed the third script hangs and never finishes on macos. |
8765ebc to
30ea37b
Compare
There was a problem hiding this comment.
5 issues found across 7 files (changes from recent commits).
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="docs/generators/kotlin-spring.md">
<violation number="1" location="docs/generators/kotlin-spring.md:316">
P2: kotlin-spring docs now incorrectly mark `oneOf` as unsupported, contradicting generator feature declarations and likely misleading users.</violation>
</file>
<file name="samples/client/petstore/csharp/generichost/latest/NullTypes/docs/models/Widget.md">
<violation number="1" location="samples/client/petstore/csharp/generichost/latest/NullTypes/docs/models/Widget.md:11">
P3: `DebugInfo` documentation is inconsistent: the type column says `Null`, but the description still claims it maps to nullable `Object` in C#.</violation>
</file>
<file name="samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs">
<violation number="1" location="samples/client/petstore/csharp/generichost/latest/NullTypes/src/Org.OpenAPITools/Model/NullTypeDirect.cs:152">
P1: Converter incorrectly rejects null for an OAS `type: null` property, causing valid read/write payloads with `alwaysNull: null` to fail.</violation>
</file>
<file name="samples/client/petstore/csharp/generichost/latest/NullTypes/docs/models/NullTypeDirect.md">
<violation number="1" location="samples/client/petstore/csharp/generichost/latest/NullTypes/docs/models/NullTypeDirect.md:8">
P2: The updated model docs are internally inconsistent: the property type is `Null` but the description still says it maps to nullable `Object`, which can mislead users.</violation>
</file>
<file name="docs/generators/java.md">
<violation number="1" location="docs/generators/java.md:100">
P2: `useJackson3` docs were changed to exclude `apache-httpclient`, but generator code still supports it, creating a user-facing documentation/behavior mismatch.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
30ea37b to
daf076f
Compare
There was a problem hiding this comment.
2 issues found across 16 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache">
<violation number="1" location="modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache:47">
P2: `@ResponseStatus` is emitted on Quarkus stub methods that return explicit `Response`, where Quarkus ignores the annotation; this can produce misleading generated status contracts.</violation>
<violation number="2" location="modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache:47">
P1: Raw injection of success response code into `@ResponseStatus(...)` can generate invalid Java for range keys like `2XX`, causing compile failures.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| }){{^-last}},{{/-last}}{{/responses}} | ||
| }){{/hasProduces}}{{/useMicroProfileOpenAPIAnnotations}} | ||
| public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) { | ||
| {{#vendorExtensions.x-java-success-response-code}}@ResponseStatus({{{vendorExtensions.x-java-success-response-code}}}) |
There was a problem hiding this comment.
P1: Raw injection of success response code into @ResponseStatus(...) can generate invalid Java for range keys like 2XX, causing compile failures.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache, line 47:
<comment>Raw injection of success response code into `@ResponseStatus(...)` can generate invalid Java for range keys like `2XX`, causing compile failures.</comment>
<file context>
@@ -44,6 +44,7 @@
}){{^-last}},{{/-last}}{{/responses}}
}){{/hasProduces}}{{/useMicroProfileOpenAPIAnnotations}}
- public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
+ {{#vendorExtensions.x-java-success-response-code}}@ResponseStatus({{{vendorExtensions.x-java-success-response-code}}})
+ {{/vendorExtensions.x-java-success-response-code}}public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
return {{#supportAsync}}{{#useMutiny}}Uni.createFrom().item({{/useMutiny}}{{^useMutiny}}CompletableFuture.supplyAsync(() -> {{/useMutiny}}{{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
</file context>
| }){{^-last}},{{/-last}}{{/responses}} | ||
| }){{/hasProduces}}{{/useMicroProfileOpenAPIAnnotations}} | ||
| public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) { | ||
| {{#vendorExtensions.x-java-success-response-code}}@ResponseStatus({{{vendorExtensions.x-java-success-response-code}}}) |
There was a problem hiding this comment.
P2: @ResponseStatus is emitted on Quarkus stub methods that return explicit Response, where Quarkus ignores the annotation; this can produce misleading generated status contracts.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At modules/openapi-generator/src/main/resources/JavaJaxRS/spec/libraries/quarkus/apiMethod.mustache, line 47:
<comment>`@ResponseStatus` is emitted on Quarkus stub methods that return explicit `Response`, where Quarkus ignores the annotation; this can produce misleading generated status contracts.</comment>
<file context>
@@ -44,6 +44,7 @@
}){{^-last}},{{/-last}}{{/responses}}
}){{/hasProduces}}{{/useMicroProfileOpenAPIAnnotations}}
- public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
+ {{#vendorExtensions.x-java-success-response-code}}@ResponseStatus({{{vendorExtensions.x-java-success-response-code}}})
+ {{/vendorExtensions.x-java-success-response-code}}public {{#supportAsync}}{{#useMutiny}}Uni{{/useMutiny}}{{^useMutiny}}CompletionStage{{/useMutiny}}<{{/supportAsync}}{{#returnJBossResponse}}{{>returnResponseTypeInterface}}{{/returnJBossResponse}}{{^returnJBossResponse}}Response{{/returnJBossResponse}}{{#supportAsync}}>{{/supportAsync}} {{nickname}}({{#allParams}}{{>queryParams}}{{>pathParams}}{{>cookieParams}}{{>headerParams}}{{>bodyParams}}{{>formParams}}{{^-last}},{{/-last}}{{/allParams}}) {
return {{#supportAsync}}{{#useMutiny}}Uni.createFrom().item({{/useMutiny}}{{^useMutiny}}CompletableFuture.supplyAsync(() -> {{/useMutiny}}{{/supportAsync}}Response.ok().entity("magic!").build(){{#supportAsync}}){{/supportAsync}};
</file context>
daf076f to
4f7b018
Compare
When using the
jaxrs-specgenerator withibrary=quarkus, interfaceOnly=true, and returning plain POJOs (i.e. returnResponse=false and returnJBossResponse=false), RESTEasy Reactive always defaults the HTTP response status to 200 OK. If the OpenAPI specification declares a different primary success code (e.g. 201 Created on a POST, or a 3xx redirect), the generated interface had no way to communicate that status without wrapping the return type in RestResponse or Response.This PR adds support for
@org.jboss.resteasy.reactive.ResponseStatuson generated interface methods, following the Quarkus REST guide.Behaviour:
Example: Given a spec with:
Then it generates an ApiInterface:
PR checklist
Commit all changed files.
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)"fixes #123"present in the PR description)Summary by cubic
Adds
@org.jboss.resteasy.reactive.ResponseStatusto Quarkusjaxrs-specgenerated APIs so plain return types reflect the spec’s 2xx/3xx success code without usingResponse/RestResponse. Adds the RESTEasy Reactive dependency only when the annotation is generated.New Features
@ResponseStatus(<code>)on interface and class methods using the first success code (2xx/3xx), including 200.returnResponse=trueorreturnJBossResponse=true. ImportsResponseStatusonly when needed.Dependencies
io.quarkus.resteasy.reactive:resteasy-reactiveto the generatedpom.xmlwhen response status annotations are emitted (or whenreturnJBossResponse=true).Written for commit b8f0eb8. Summary will update on new commits. Review in cubic