Added OpenAPI client successful response mode with typed error exceptions - #761
Open
GoodforGod wants to merge 2 commits into
Open
Added OpenAPI client successful response mode with typed error exceptions#761GoodforGod wants to merge 2 commits into
GoodforGod wants to merge 2 commits into
Conversation
Test Results761 tests 752 ✅ 30m 50s ⏱️ Results for commit 524ccf4. ♻️ This comment has been updated with latest results. |
Dependency Update ReportUpdate level: Found
|
…ions Added `clientResponseMode=SUCCESSFUL` to narrow generated client return types to successful responses where possible while preserving sealed responses when success variants are ambiguous. Error and default responses are now routed through operation-level mappers that parse typed error responses and throw per-operation `HttpClientResponseException` subclasses with buffered response bodies. - Added `SEALED` as the default client response mode to preserve existing generated client behavior. - Added operation-level `*SuccessfulResponseMapper` generation for operations with error/default responses, including ambiguous successful response shapes. - Added buffered error body replay so typed error parsing uses the original body and parse failures still expose the response body on the thrown exception.
Improved `clientResponseMode=SUCCESSFUL` typed error exceptions to generate one API-level exception per unique error body type instead of one exception per operation. Shared exceptions now expose parsed `content` directly while status code, headers, and raw body remain available from the base `HttpClientResponseException`.
GoodforGod
force-pushed
the
feature/openapi-generator-response-mode-successful
branch
from
August 3, 2026 13:49
56d8b6c to
524ccf4
Compare
Squiry
approved these changes
Sep 2, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added OpenAPI client successful response mode with typed error exceptions
EN
Added
clientResponseMode=SUCCESSFULfor generated OpenAPI clients so successful calls can return narrowed success response types while error responses are exposed through typed per-operation exceptions. The default remainsSEALED, preserving existing generated client contracts unless the new mode is explicitly enabled.RU
Добавлен режим
clientResponseMode=SUCCESSFULдля OpenAPI клиентов: успешные ответы могут возвращаться как суженные success-типы, а error/default ответы превращаются в типизированные per-operation exception. Поведение по умолчанию остаетсяSEALED, поэтому существующие контракты без явного включения нового режима не меняются.clientResponseMode=SEALED | SUCCESSFUL, withSEALEDas the default compatibility mode.SUCCESSFULmode when the OpenAPI response set allows it.*SuccessfulResponseMappergeneration for operations with error/default responses, including cases where successful responses are ambiguous and the return type stays sealed.Design
clientResponseModecontrols the shape of generated client contracts.In default
SEALEDmode, the generator keeps the old behavior: every operation returns the full sealed response hierarchy and each status code is mapped through@ResponseCodeMapper.In
SUCCESSFULmode, operations with error/default responses use one operation-level mapper. If the successful response shape is unambiguous, the method return type is narrowed to the successful subtype.If success responses are ambiguous, for example
200with body and204without body, the method keeps the sealed return type but still uses one operation-level mapper. This keeps success typing correct while giving the same error-exception behavior.The generated
*SuccessfulResponseMapperowns response dispatch for the operation:2xxresponses are returned normally.HttpClientResponseExceptionfallback.Error bodies are buffered before parsing. The mapper replays the buffered body through
SimpleHttpClientResponse, so typed error parsing can consume the body while the thrown exception still exposes the original bytes. If parsing fails, the generated mapper throwsHttpClientResponseExceptionwith the buffered body and adds the parsing failure as suppressed.The typed exception keeps both layers of information: structured generated response for declared errors and raw body bytes through the base
HttpClientResponseException.