Skip to content

Add configurable generic return type wrapper for JAX-RS codegen#431

Merged
EricWittmann merged 1 commit into
mainfrom
generic-return-type-wrapper
Jun 4, 2026
Merged

Add configurable generic return type wrapper for JAX-RS codegen#431
EricWittmann merged 1 commit into
mainfrom
generic-return-type-wrapper

Conversation

@EricWittmann

Copy link
Copy Markdown
Contributor

Summary

  • Adds a genericReturnType setting to JaxRsProjectSettings that wraps all generated JAX-RS return types in a user-specified generic class (e.g. org.jboss.resteasy.reactive.RestResponse)
  • Enables type-safe HTTP status code control: Beer getBeer(...) becomes RestResponse<Beer> getBeer(...), void methods become RestResponse<Void>, and reactive mode produces CompletionStage<RestResponse<T>>
  • Based on the approach from stale PR Add option to wrap return type in a generic class #295, reimplemented against the current codebase

Changes

  • JaxRsProjectSettings.java — new genericReturnType field (default null = no wrapping)
  • OpenApi2JaxRs.java — new generateGenericReturnType() method, inserted into the return type chain between type generation and reactive wrapping; updated setVoidReturnType() to handle the wrapper
  • OpenApi2JaxRsTest.java — 2 new test methods (generic-only and generic+reactive), new doFullTest overload
  • Test fixtures — 2 new expected output directories

Test plan

  • All 42 existing + new tests pass (mvn test -pl core)
  • Verified generated output: RestResponse<Beer>, RestResponse<Void>, CompletionStage<RestResponse<T>>
  • Quarkus codegen inherits the feature automatically (no changes needed)
  • Verify CI passes

Resolves #430

🤖 Generated with Claude Code

Adds a genericReturnType setting to JaxRsProjectSettings that wraps
all generated return types in a user-specified generic class (e.g.
org.jboss.resteasy.reactive.RestResponse). This enables type-safe
HTTP status code control without losing the generated type information.

Resolves #430
@EricWittmann EricWittmann merged commit 85f99e7 into main Jun 4, 2026
2 checks passed
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.

Add option to wrap JAX-RS return types in a configurable generic class

1 participant