* Revert "Generate shared path-level parameter helper types once (#2466)"
This reverts commit a07731d.
* Name shared path parameter helper types once, hashing cross-path collisions
Closes: #2090
A parameter declared at the path-item level is inherited by every method on
the path. Its hoisted helper types -- the members of an inline anyOf/oneOf and
similar -- were named from the parameter alone and declared once per
operation, so a path with more than one method redeclared them ("Id0
redeclared in this block"). The same bare names also collided across different
paths that reuse the same parameter, which is the common REST case of an {id}
shared by sibling paths.
Resolve path-item-level parameters in a single pre-pass
(resolveSharedParameters): describe each scope's shared parameters once, count
how many scopes hoist a helper type under each name, and emit each scope's
helper types once for its path item rather than once per operation. A name
produced by two or more scopes is disambiguated by prefixing that scope's
parameters with a short, stable FNV hash of the scope, extended to the full
hash only if two scopes' short hashes clash. A parameter that does not collide
keeps its historical undecorated name, so existing generated code is
unaffected -- the only outputs that change are specs that previously failed to
compile.
Applied uniformly to regular paths, webhooks, and callbacks, which share the
one global Go type namespace. Disambiguated types carry a doc comment
explaining the hash prefix and pointing back to the source path.
Adds internal/test/parameters/shared_collision covering a shared anyOf
parameter across multiple methods on a path (bare, emitted once), the same
parameter reused across sibling paths (hash-disambiguated), and a
non-colliding single-method parameter (unchanged).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments