Skip to content

fix(swagger): normalize kebab-case OpenAPI path params to camelCase - #12

Merged
kep-mei-yo merged 4 commits into
kakaoenterprise:mainfrom
kep-ria-ang:bug/issue-11
Jul 30, 2026
Merged

fix(swagger): normalize kebab-case OpenAPI path params to camelCase#12
kep-mei-yo merged 4 commits into
kakaoenterprise:mainfrom
kep-ria-ang:bug/issue-11

Conversation

@kep-ria-ang

Copy link
Copy Markdown
Collaborator

Summary

What Changed

Root cause

  • normalizePathParams converted {kubeflow-id} verbatim to :kubeflow-id, but path-to-regexp (used internally by MSW's http.<method>()) reads a named parameter token only up to the first non-word character — a hyphen silently truncates it, so the compiled route can never match a real request.
  • Reproduced directly: match('/v1/kubeflows/:kubeflow-id')('/v1/kubeflows/<uuid>')false.

Fix

  • normalizePathParams now sanitizes each captured brace-param name into a camelCase, path-to-regexp-safe identifier before prefixing with : ({kubeflow-id}:kubeflowId)
  • matching this codebase's existing manual-handler naming convention. Already-safe names ({id}, {kubeflowId}) are unaffected.

Known consequence (documented in ADR-0005 & release briefing)

  • For full root-cause analysis, see agent-artifacts/decisions/ADR-0005-normalize-kebab-case-path-params.md & agent-artifacts/workstreams/2026-07-16-swagger-hyphen-param-mismatch/ implementation notes, and the release briefing.

Test plan

  • Added pathParams.test.ts: brace→colon conversion, kebab-case→camelCase conversion, multi-param paths, no-op on already-safe names
  • Added an end-to-end regression test that builds a real MSW http.delete() handler from the normalized route and runs an actual Request through handler.run(), reproducing and verifying the fix for the exact symptom reported in [BUG] Swagger/OpenAPI-imported handlers unmatch issue #11
  • vitest run: 73/73 passed
  • tsc --noEmit: clean
  • eslint .: 0 errors on changed files
  • build: success
  • Verified with a local yalc link into the reporting consumer project

Type

  • Bug fix
  • Feature
  • Refactor
  • Breaking change

Checklist

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

Swagger-imported handlers whose OpenAPI path used a hyphenated param
(e.g. "{kubeflow-id}") silently never matched real requests: MSW's
path-to-regexp reads a named param token only up to the first
non-word char, so ":kubeflow-id" compiled to param "kubeflow" plus
the literal text "-id", which never appears in a real request path.
No error or warning surfaced anywhere, even with the handler shown
active with a variant selected.

normalizePathParams now sanitizes each captured param name into a
path-to-regexp-safe camelCase identifier before prefixing with ":",
matching this codebase's existing manual-handler convention.

Fixes kakaoenterprise#11

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Comment thread packages/mocking-gui/src/utils/handler/pathParams.ts Outdated
Change toSafeParamName from camelCase conversion to a single-line
underscore replacement (`{kubeflow-id}` -> `:kubeflow_id`). Simpler
regex, and unlike the camelCase variant it correctly handles leading/
trailing separators (which otherwise left an unsafe character in the
compiled route). Param names are never consumed by identifier
downstream, so matching behavior is unchanged.

Adds snake_case and trailing/leading-separator test cases; updates
ADR-0005 and the workstream docs to record the reversed decision.
Realign markdown tables in ADR INDEX and the release briefing that
drifted after the underscore-decision edits.
@kep-mei-yo
kep-mei-yo merged commit 486af05 into kakaoenterprise:main Jul 30, 2026
2 checks passed
@kep-ria-ang
kep-ria-ang deleted the bug/issue-11 branch July 31, 2026 06:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Swagger/OpenAPI-imported handlers unmatch issue

2 participants