fix(swagger): order static handler paths before dynamic path - #15
Merged
kep-ria-ang merged 1 commit intoAug 27, 2026
Conversation
MSW resolves handlers first-match-wins by registration order, so a
dynamic segment (":id") declared before a static sibling ("/health")
would shadow the static route and make it unreachable. Float static
paths ahead of dynamic ones with a stable sort that preserves the
original spec order within each group.
hasDynamicSegment splits on "/" and checks each segment start, so a
scheme/port colon in the base URL (e.g. ":8443") is never mistaken
for a dynamic segment.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Static handler paths (e.g.
/health) are now registered before dynamic ones (e.g./:id) so a dynamic segment can no longer shadow a static sibling that is declared later in the OpenAPI spec.What Changed
fix(swagger): order static handler paths before dynamic ones 0b436c9
:id) declared before a static sibling (/health) would shadow the static route and make it unreachable.sort, preserving the original spec order within each group. AddedhasDynamicSegment, which splits the URL on/and checks each segment start so a scheme/port colon in the base URL (e.g.:8443) is never mistaken for a dynamic segment.vitest10/10 pass,tsc --noEmitclean,eslint0 errors,buildsucceeds.Screenshot (Optional)
Type
Checklist
See the briefing comment below for decision rationale, risk assessment, and verification details.