Skip to content

fix(swagger): order static handler paths before dynamic path - #15

Merged
kep-ria-ang merged 1 commit into
kakaoenterprise:mainfrom
kep-ria-ang:fix/swagger-handler-static-first-ordering
Aug 27, 2026
Merged

fix(swagger): order static handler paths before dynamic path#15
kep-ria-ang merged 1 commit into
kakaoenterprise:mainfrom
kep-ria-ang:fix/swagger-handler-static-first-ordering

Conversation

@kep-ria-ang

@kep-ria-ang kep-ria-ang commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

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

  • What: 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.
  • How: Float static paths ahead of dynamic ones via a stable sort, preserving the original spec order within each group. Added hasDynamicSegment, 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.
  • Tested: Added 3 ordering tests (static-before-dynamic, stable intra-group order, port-colon misclassification guard). vitest 10/10 pass, tsc --noEmit clean, eslint 0 errors, build succeeds.

Screenshot (Optional)


Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change

Checklist

  • Code follows project conventions
  • Self-reviewed
  • Tested locally
  • No console errors / warnings

See the briefing comment below for decision rationale, risk assessment, and verification details.

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>
@github-actions
github-actions Bot requested a review from kep-mei-yo August 5, 2026 06:09
@kep-ria-ang kep-ria-ang changed the title fix(swagger): order static handler paths before dynamic ones fix(swagger): order static handler paths before dynamic path Aug 5, 2026
@kep-mei-yo kep-mei-yo added the enhancement New feature or request label Aug 7, 2026
@kep-ria-ang
kep-ria-ang merged commit e55bcb3 into kakaoenterprise:main Aug 27, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants