Skip to content

[jaxrs-spec][quarkus]: add @ResponseStatus annotation for non-200 success codes#23673

Open
Ignacio-Vidal wants to merge 1 commit intoOpenAPITools:masterfrom
Ignacio-Vidal:java-quarkus-respnose-status
Open

[jaxrs-spec][quarkus]: add @ResponseStatus annotation for non-200 success codes#23673
Ignacio-Vidal wants to merge 1 commit intoOpenAPITools:masterfrom
Ignacio-Vidal:java-quarkus-respnose-status

Conversation

@Ignacio-Vidal
Copy link
Copy Markdown

@Ignacio-Vidal Ignacio-Vidal commented May 1, 2026

Description

Adds @org.jboss.resteasy.reactive.ResponseStatus annotation to generated Quarkus JAX-RS server stubs when the OpenAPI spec defines a non-200 success response code (2xx). This allows Quarkus to automatically set the correct HTTP
status code on the response without the user having to manually return a Response object.

The annotation is gated on useJakartaEe: true (Quarkus 3+ / Jakarta EE namespace) because:

  • @ResponseStatus is a RESTEasy Reactive feature, which is the default REST stack in Quarkus 3+
  • Quarkus 1.x/2.x (javax namespace) projects use quarkus-resteasy (classic, non-reactive), which does not process this annotation
  • The quarkus-universe-bom:1.x BOM provides a version of io.quarkus.resteasy.reactive:resteasy-reactive that predates ResponseStatus, causing compilation failures

Changes:

  • JavaJAXRSSpecServerCodegen.java — sets x-java-success-response-code vendor extension for Quarkus+Jakarta EE+non-Response-returning operations

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package || exit
    ./bin/generate-samples.sh ./bin/configs/*.yaml || exit
    ./bin/utils/export_docs_generators.sh || exit
    
    (For Windows users, please run the script in WSL)
    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.
  • File the PR against the correct branch: master (upcoming 7.x.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR solves a reported issue, reference it using GitHub's linking syntax (e.g., having "fixes #123" present in the PR description)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

Summary by cubic

Generate Quarkus JAX-RS stubs with @ResponseStatus on interface methods to automatically set success HTTP codes for operations that don’t return Response/RestResponse. Applies to numeric 2xx responses (including 200) on Quarkus 3+ (Jakarta).

  • New Features

    • Emit @ResponseStatus(<code>) when useJakartaEe: true, library = quarkus, the operation has a numeric 2xx response, and does not return Response/RestResponse.
    • Annotate interface methods only (interfaceOnly: true); class stubs return Response and are not annotated. Import ResponseStatus only when used.
    • Set x-java-success-response-code per operation and hasResponseStatusAnnotations (file/global) to drive annotation, imports, and POM.
    • Suppress annotation when returnResponse or returnJbossResponse is true.
  • Dependencies

    • Add io.quarkus.resteasy.reactive:resteasy-reactive to the generated POM only when @ResponseStatus is emitted.

Written for commit b0e089e. Summary will update on new commits.

@Ignacio-Vidal Ignacio-Vidal changed the title feat(jaxrs-spec/quarkus): add @ResponseStatus annotation for non-200 success codes (jaxrs-spec][quarkus]: add @ResponseStatus annotation for non-200 success codes May 1, 2026
@Ignacio-Vidal Ignacio-Vidal changed the title (jaxrs-spec][quarkus]: add @ResponseStatus annotation for non-200 success codes [jaxrs-spec][quarkus]: add @ResponseStatus annotation for non-200 success codes May 1, 2026
@Ignacio-Vidal Ignacio-Vidal marked this pull request as ready for review May 1, 2026 23:32
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 16 files

@Ignacio-Vidal Ignacio-Vidal force-pushed the java-quarkus-respnose-status branch from c258cbc to 86dc86b Compare May 1, 2026 23:36
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue 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:50">
P2: @ResponseStatus is emitted on a method that still returns Response, so in Quarkus RESTEasy Reactive it will be ignored and cannot enforce the non-200 status code.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@Ignacio-Vidal Ignacio-Vidal force-pushed the java-quarkus-respnose-status branch from e13c88c to 1e82e41 Compare May 2, 2026 00:26
@Ignacio-Vidal
Copy link
Copy Markdown
Author

@chameleon82, @hiveship, @nickcmaynard or @jfiala - could you review this improvement to the jaxrs-spec/quarkus generator?

There is a circle ci job failing in the internal setup during the environment setup, any suggestions for this:

  • Setup-cpp tried to add the Ubuntu PPA ppa:ubuntu-toolchain-r/test to install LLVM/clang, but that PPA no longer exists

…ess codes

Adds @org.jboss.resteasy.reactive.ResponseStatus to generated Quarkus
JAX-RS server stubs when the OpenAPI spec defines a non-200 success
response code (2xx). This allows Quarkus to automatically set the
correct HTTP status code without the user manually returning a Response
object.

Gated on useJakartaEe: true (Quarkus 3+ / Jakarta EE namespace) because
@ResponseStatus is a RESTEasy Reactive feature, which is the default
REST stack only in Quarkus 3+. Quarkus 1.x/2.x projects use
quarkus-resteasy (classic) which does not process this annotation, and
the quarkus-universe-bom 1.x provides a version of resteasy-reactive
that predates ResponseStatus.

- JavaJAXRSSpecServerCodegen: set x-java-success-response-code vendor
  extension for Quarkus+Jakarta EE+non-Response-returning operations
- quarkus/apiMethod.mustache, api.mustache, apiInterface.mustache:
  emit @ResponseStatus(<code>) when the vendor extension is present
- quarkus/pom.mustache: add resteasy-reactive dep when annotation is used
- Tests and generated samples updated
@Ignacio-Vidal Ignacio-Vidal force-pushed the java-quarkus-respnose-status branch from 1e82e41 to b0e089e Compare May 2, 2026 09:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant