You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When the base spec references a response defined in an external file via import-mapping, the generated client-with-responses wrapper builds the imported type name from the raw component name. It does not honour the Go name the external package actually generated, so the base package can reference a type the imported package never declares, and the generated client fails to compile.
This was discovered while fixing #2308 (external path item responses). The path-item case is fixed there, but the same gap exists for direct external response refs and is broader.
Two cases
1. x-go-name on the external response (direct ref).
The external package declares type OutcomeResult = string, but the base client emits:
JSON200*externalRef0.Outcome// undefined: imported package only declares OutcomeResult
2. Cross-package collision renames.
If the external document's name resolver renames a component because of a collision within that document, the base run cannot reproduce that name: each codegen run resolves names independently and there is no shared resolved-name map / artifact between them. So the base package again references a name the imported package never declared.
Why it happens
For external refs the name is resolved with RefPathToGoType → refPathToGoTypeSelf, which keys off the root spec (resolvedNameForComponent / findSchemaNameByRefPath against globalState.spec) and otherwise falls back to SchemaNameToTypeName(<rawName>). It never consults the external component's x-go-name, nor the external document's own name resolution.
Note that x-go-name is recoverable (it rides along on the resolved $ref value's Extensions), so case 1 is fixable locally — that is exactly what the #2308 fix does for the path-item branch. Case 2 (collision renames) is not recoverable without resolving the external document.
Scope / suggestion
Honour x-go-name on the resolved external component for direct external refs too, so it matches the path-item behaviour landed in PathItem support missing #2308 (symmetry; fixes case 1).
Cross-package collision naming (case 2) likely needs a shared/persisted resolved-name map between codegen runs, or a documented constraint that external components avoid collision-driven renames.
Reproduction
x-go-name case reproduces with generate: { client: true, models: true } plus an import-mapping entry for spec-ext.yaml, using the specs above.
Summary
When the base spec references a response defined in an external file via
import-mapping, the generatedclient-with-responseswrapper builds the imported type name from the raw component name. It does not honour the Go name the external package actually generated, so the base package can reference a type the imported package never declares, and the generated client fails to compile.This was discovered while fixing #2308 (external path item responses). The path-item case is fixed there, but the same gap exists for direct external response refs and is broader.
Two cases
1.
x-go-nameon the external response (direct ref).spec-ext.yaml:spec-base.yaml(direct ref, no path item):The external package declares
type OutcomeResult = string, but the base client emits:2. Cross-package collision renames.
If the external document's name resolver renames a component because of a collision within that document, the base run cannot reproduce that name: each codegen run resolves names independently and there is no shared resolved-name map / artifact between them. So the base package again references a name the imported package never declared.
Why it happens
For external refs the name is resolved with
RefPathToGoType→refPathToGoTypeSelf, which keys off the root spec (resolvedNameForComponent/findSchemaNameByRefPathagainstglobalState.spec) and otherwise falls back toSchemaNameToTypeName(<rawName>). It never consults the external component'sx-go-name, nor the external document's own name resolution.Note that
x-go-nameis recoverable (it rides along on the resolved$refvalue'sExtensions), so case 1 is fixable locally — that is exactly what the #2308 fix does for the path-item branch. Case 2 (collision renames) is not recoverable without resolving the external document.Scope / suggestion
x-go-nameon the resolved external component for direct external refs too, so it matches the path-item behaviour landed in PathItem support missing #2308 (symmetry; fixes case 1).Reproduction
x-go-namecase reproduces withgenerate: { client: true, models: true }plus animport-mappingentry forspec-ext.yaml, using the specs above.