fix: compose JAX-RS method-level @Path with class-level prefix#1007
Open
CharlesQueiroz wants to merge 1 commit into
Open
fix: compose JAX-RS method-level @Path with class-level prefix#1007CharlesQueiroz wants to merge 1 commit into
CharlesQueiroz wants to merge 1 commit into
Conversation
…ata#1005) JAX-RS splits a route across two annotations: the verb comes from a bare @GET/@POST/... and the path from a sibling @path. The annotation scan returned on the first mapping annotation, so the @get matched, defaulted the path to "/" and the sibling @path was never read. Class-level @path was never recognized as a prefix either, because a lone @path carries no verb and the scan reported no route. scan_route_annotations() now collects the whole annotation set (mapping verb + optional inline path, and a separate JAX-RS @path), then: - method-level: verb required; path = inline mapping path, else @path, else "/" - class-level prefix: inline mapping path, else @path Also recognizes bare @HEAD/@options verbs. Spring behavior is unchanged (mapping annotations keep their inline path); covered by the existing test suite plus a new regression test.
Owner
|
Thanks for the targeted JAX-RS fix. I have triaged it into 0.9.1-rc as the fix candidate for #1005. Review focus will be class-plus-method path composition and making sure Spring-style annotation extraction does not regress. |
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.
Fixes #1005.
Root cause
extract_route_from_annotations()returned on the first mapping annotation. For JAX-RS methods the verb and the path live in two sibling annotations:The
@GETmatched first (annotation_route_method("GET")), defaulted the path to"/", and the sibling@Pathwas never read: every method-level@Pathwas silently dropped. Class-level@Pathprefixes were never recognized either, because a lone@Pathcarries no verb, so the scan reported "no route" andspring_class_route_prefix()returned NULL.This also explains the "inconsistent" symptom in #1005: resources whose endpoints are exercised by RestAssured tests got Route nodes from the tests' full-URL string literals, masking the missing annotation-derived routes; resources without such tests showed only the class-level route.
Fix
New
scan_route_annotations()collects the whole annotation set in one pass: the mapping verb (+ optional inline path, Spring style) and a separate JAX-RS@Pathvalue. Then:extract_route_from_annotations): a verb annotation is still required (a lone@Pathsub-resource locator is not an endpoint); path = inline mapping path, else@Path, else"/".spring_class_route_prefix): inline mapping path (@RequestMapping("/api")), else class-level@Path.@HEAD/@OPTIONSverbs are now recognized alongside GET/POST/PUT/DELETE/PATCH.Spring extraction is unchanged: mapping annotations keep their inline path and the collecting scan preserves the first-mapping-annotation-wins order.
Validation
extract_java_jaxrs_path_composition_issue1005(class prefix alone, prefix + method@Path, verb preserved).@ConfigPropertyparams and generic DTO return types included) indexed with the patched binary now yields:__route__GET__/api/v1/widgets__route__GET__/api/v1/widgets/count__route__POST__/api/v1/widgets/{}/archive__route__GET__/api/v2/things/allunchanged.