Commit a46bd1a
fix: propagate user name overrides through codegen
The collision resolver had two bugs when resolve-type-name-collisions
was enabled:
1. x-go-name was ignored: generateCandidateName() never consulted the
x-go-name extension, so schemas/responses/requestBodies/parameters/
headers with explicit Go name overrides would lose them during
collision resolution.
2. Client wrapper names bypassed the name normalizer:
generateCandidateName() used UppercaseFirstCharacter(operationID)
instead of SchemaNameToTypeName(operationID), so configured
normalizers (e.g. ToCamelCaseWithInitialisms) were not applied to
client response wrapper type names.
Changes:
- Add GoNameOverride field to GatheredSchema, populated from x-go-name
on the parent container (schema, response, requestBody, parameter,
header) when the component is not a $ref
- Add extractGoNameOverride() helper to read x-go-name from extensions
- Add Pinned field to ResolvedName; pinned names are returned as-is
from generateCandidateName() and skipped by all collision resolution
strategies (context suffix, content type, status code, param index,
numeric fallback)
- Fix client wrapper candidate name to use SchemaNameToTypeName()
- Add unit tests for GoNameOverride population and pinning behaviour
- Add integration test patterns K/L/M (x-go-name on schema, response,
and requestBody) and regenerate
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 5e3fede commit a46bd1a
File tree
7 files changed
+1160
-34
lines changed- internal/test/name_conflict_resolution
- pkg/codegen
7 files changed
+1160
-34
lines changed
0 commit comments