Skip to content

Restrict :param path params to the start of a path segment - #1839

Merged
js2me merged 4 commits into
acacode:mainfrom
cpruijsen:fix/issue-1833
Nov 4, 2026
Merged

js2me merged 4 commits into
acacode:mainfrom
cpruijsen:fix/issue-1833

Conversation

@cpruijsen

@cpruijsen cpruijsen commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

The parser preserves literal colon suffixes in generated URLs and recognizes colon parameters only at the start of a path segment.

Problem

/v1/items:search produced a required search: string argument and the URL /v1/items${search}.
/v1/items/{itemId}:archive had the same extra-argument and suffix-loss problem.

Solution

src/schema-routes/schema-routes.ts uses the same segment boundary for parameter detection and replacement.
A literal suffix cannot capture a later parameter's substitution.
The parser consumes a legacy trailing colon only before / or the route end, so /:itemId:archive retains its suffix.

The parser retains /users/:userId and brace parameters for compatibility with existing clients.
Full Express route grammar remains outside scope: embedded colon syntax becomes literal path text.

Verification

The inline OpenAPI regression test in tests/spec/issue-1833/basic.test.ts fails on the baseline and passes with this fix.
The package test suite passes.

Closes #1833.


Summary by cubic

Fixes routes with AIP-136 custom methods (like /v1/items:search or /v1/items/{itemId}:archive) generating a bogus required string argument and dropping the literal :suffix from the request URL.

:paramName is now parsed as an Express-style path parameter only at the start of a path segment, so /users/:userId keeps working while mid-segment colons stay part of the literal path. The fix also keeps a legacy trailing-colon param form (/users/:id:) substitutable before / or the route end, and handles a colon param at the route start without a leading slash (as produced by hooks like onPreBuildRoutePath).

Added regression tests in tests/spec/issue-1833/basic.test.ts covering the custom-method suffixes, the trailing-colon form, and the no-leading-slash case; they fail on the baseline and pass with the fix.

Written for commit d7ac54c. Summary will update on new commits.

View guided diff

@changeset-bot

changeset-bot Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: d7ac54c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
swagger-typescript-api Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 3 files

Reply with feedback, questions, or to request a fix.

View guided diff | Re-trigger cubic

Comment thread src/schema-routes/schema-routes.ts Resolved
Comment thread src/schema-routes/schema-routes.ts Resolved
@js2me

js2me commented Nov 4, 2026

Copy link
Copy Markdown
Member

Thank you

@js2me
js2me merged commit e67c3a7 into acacode:main Nov 4, 2026
5 checks passed
@github-actions github-actions Bot mentioned this pull request Nov 4, 2026
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.

Colon suffix in path segment (AIP-136 custom method, e.g. /v1/items:search) becomes a phantom required path param

2 participants