Added HTTP-client typed Either<T,E> response mapping - #716
Open
GoodforGod wants to merge 3 commits into
Open
Conversation
Test Results140 tests 140 ✅ 10m 38s ⏱️ Results for commit d5aabe6. ♻️ This comment has been updated with latest results. |
Dependency Vulnerability ReportFound Checked
|
Dependency Update ReportUpdate level: Found
|
…an inclusive status range. - Support `HttpResponseEntity<Either<T, E>>` in declarative HTTP clients so non-2xx responses can be mapped into typed error values instead of always throwing. Add built-in `HttpClientEitherResponseMapper` and Kora extension wiring for both Java annotation processor and KSP. - Also support JSON-tagged Either mapping variants: - `@Json HttpResponseEntity<Either<T, E>>` - `HttpResponseEntity<Either<@JSON T, @JSON E>>` - Cover Java and KSP scenarios with tests for range mapping, all-status Either entity mapping, top-level JSON tags, and per-Either-argument JSON tags.
Added support for mapping `HttpResponseEntity<Either<T, E>>` across all response statuses, keeping successful responses in the left side and error responses in the right side. - Added built-in client response mapper support for `Either<T, E>` and `HttpResponseEntity<Either<T, E>>`. - Added JSON tag propagation for both top-level `@Json` response mappings and per-branch `Either<@JSON T, @JSON E>` mappings. - Removed `@ResponseCodeMapperRange` before release since the explicit range annotation was redundant with the new typed Either response flow.
GoodforGod
force-pushed
the
feature/http-client-response-code-mapper-range
branch
from
July 23, 2026 13:56
d5aabe6 to
987a382
Compare
@ResponseCodeMapperRange for mapping default responses in status rangeEither<T,E> response mapping
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 typed Either response mapping for HTTP clients with JSON tag propagation
EN
Added support for declarative HTTP clients to map
HttpResponseEntity<Either<T, E>>across all response statuses. This enables hand-written clients to receive typed successful and error bodies without custom response mappers, while keeping the existing default behavior for ordinary return types.RU
Добавлена поддержка
HttpResponseEntity<Either<T, E>>в декларативных HTTP-клиентах: теперь успешные и ошибочные ответы можно получать типизированно без собственного маппера ответа. Для обычных возвращаемых типов старое поведение сохраняется.Either<T, E>where 2xx responses are mapped to the left branch and non-2xx responses are mapped to the right branch.HttpResponseEntity<Either<T, E>>handling so response status and headers are preserved while the body is mapped into the appropriateEitherbranch.@Json HttpResponseEntity<Either<T, E>>andHttpResponseEntity<Either<@Json T, @Json E>>.@ResponseCodeMapperRangeAPI since the typedEitherflow covers the intended use case without another annotation.Design
The new mapping path is owned by the HTTP client response mapper layer.
HttpClientEitherResponseMapper<T, E>delegates body decoding to two existingHttpClientResponseMapperinstances: one for successful statuses and one for error statuses.For status codes in the
200..299range, the response body is mapped with the success mapper and returned asEither.left(...). For all other status codes, the response body is mapped with the error mapper and returned asEither.right(...).HttpResponseEntitykeeps the original status code and headers.JSON mapping works in two forms. A top-level
@Jsonapplies the same tag to bothEitherbranches:Per-branch annotations allow different tagged mappers for each side:
Java annotation processor and KSP both synthesize the required graph dependencies so users do not need to write a custom mapper for the common JSON case. Existing behavior remains unchanged for non-
Eitherreturn types: non-2xx responses still throwHttpClientResponseExceptionunless explicit response code mapping is configured.