Problem
The JAX-RS codegen generates interface methods that return POJOs directly (e.g., Beer getBeer(...)), which implicitly assumes HTTP 200. To return alternative status codes (201, 202, 204, etc.), developers must either:
- Change all methods to return
jakarta.ws.rs.Response, losing type safety
- Manually edit the generated interfaces to use a framework-specific wrapper
Frameworks like RESTEasy Reactive provide typed wrappers such as RestResponse<T> that preserve type safety while allowing status and header control. The codegen currently has no way to leverage these.
Proposed Solution
Add a genericReturnType setting to JaxRsProjectSettings — a fully-qualified class name (e.g., org.jboss.resteasy.reactive.RestResponse) that wraps all return types:
Beer getBeer(...) → RestResponse<Beer> getBeer(...)
void deleteBeer(...) → RestResponse<Void> deleteBeer(...)
- With reactive mode:
CompletionStage<RestResponse<Beer>> getBeer(...)
The setting should be framework-agnostic — any class that takes a single type parameter should work.
Prior Art
PR #295 implemented this feature but became stale due to the package rename and other codebase changes. The approach in that PR is a good design reference: it adds a generateGenericReturnType method to OpenApi2JaxRs and applies the wrapping before reactive type wrapping in the return type chain.
Problem
The JAX-RS codegen generates interface methods that return POJOs directly (e.g.,
Beer getBeer(...)), which implicitly assumes HTTP 200. To return alternative status codes (201, 202, 204, etc.), developers must either:jakarta.ws.rs.Response, losing type safetyFrameworks like RESTEasy Reactive provide typed wrappers such as
RestResponse<T>that preserve type safety while allowing status and header control. The codegen currently has no way to leverage these.Proposed Solution
Add a
genericReturnTypesetting toJaxRsProjectSettings— a fully-qualified class name (e.g.,org.jboss.resteasy.reactive.RestResponse) that wraps all return types:Beer getBeer(...)→RestResponse<Beer> getBeer(...)void deleteBeer(...)→RestResponse<Void> deleteBeer(...)CompletionStage<RestResponse<Beer>> getBeer(...)The setting should be framework-agnostic — any class that takes a single type parameter should work.
Prior Art
PR #295 implemented this feature but became stale due to the package rename and other codebase changes. The approach in that PR is a good design reference: it adds a
generateGenericReturnTypemethod toOpenApi2JaxRsand applies the wrapping before reactive type wrapping in the return type chain.