Restrict :param path params to the start of a path segment

CP
3d ago
+118-2

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. A legacy trailing colon is consumed only before / or the route end, so /:itemId:archive retains its suffix. Added a regression test in tests/spec/issue-1833/basic.test.ts that fails on the baseline and passes with the fix.