Skip to content

fix: rename path parameters that collide with generated names - #88

Merged
MarkRosemaker merged 2 commits into
mainfrom
fix/path-param-names
Nov 25, 2026
Merged

MarkRosemaker merged 2 commits into
mainfrom
fix/path-param-names

Conversation

@MarkRosemaker

Copy link
Copy Markdown
Owner

go-api-libs/ibkr failed to build: the path parameter u of /portfolio/U{u}/summary became the argument u string, and the method then assigned the request URL to u.

  • ir/operation.go: pathParamName gives a path parameter its Go identifier. It adds the suffix Param when the name is a Go keyword, a predeclared identifier, or a name the generated code uses where the parameter is in scope: the client method's locals (u, q, req, rsp, ia, err, pr, pw, body, out, …), the receiver c, ctx, the server handler's locals, and the packages they use. GoName and VarName both come from it, so the signature, the JoinPath arguments, the server's Service/handler and api.js all agree.
  • Golden: added GET /portfolio/{u}/summary/{req}. Its generated code was produced in a scratch directory and the diff applied by hand. The diff only adds code for the new operation. A hand-written TestPath_RenamesParameters checks that the client calls /v1/portfolio/U1234/summary/r1.
  • Roadmap: the generated server panics on a parameter inside a segment (U{u}, CIK{cik}.json) because http.ServeMux does not accept that wildcard. That is why the golden case uses whole segments.

make ready passes. make all (govulncheck) was not run.


Generated by Claude Code

A path parameter whose Go name is one the generated method or handler uses
itself, such as go-api-libs/ibkr's u, the request URL, no longer breaks the
build: it is suffixed with Param, as are keywords and predeclared names, in
the signature, the path, the server handler and api.js alike.

The golden spec gains /portfolio/{u}/summary/{req}. The server's panic on a
parameter inside a segment, which ibkr's path also has, goes on the roadmap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Pd6RdtkAJq4fCsH7CzhRx
@MarkRosemaker
MarkRosemaker merged commit aeeae2d into main Nov 25, 2026
1 check passed
@MarkRosemaker
MarkRosemaker deleted the fix/path-param-names branch November 25, 2026 18:59
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.

2 participants