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
{{ message }}
Repository navigation
Invalid typedefs when spec uses same ref name for request body and schema #407
When I have a spec that defines the same thing twice (but in different namespaces) I get invalid code generated. For example, with a spec containing something like this (notice the reuse of the same identifier myThing for both the request body and the schema):
Then I used up with a typedef in the generated code like: type MyThing MyThing which is invalid.
I've currently worked around this by altering typedef.tmpl to do the following:
{{range .Types}}
{{if ne .TypeName .Schema.TypeDecl }}
{{ with .Schema.Description }}{{ . }}{{ else }}// {{.TypeName}} defines model for {{.JsonName}}.{{ end }}
type {{.TypeName}} {{if and (opts.AliasTypes) (.CanAlias)}}={{end}} {{.Schema.TypeDecl}}
{{end}}
{{end}}
Which skips doing a typedef with a type name equal to it's schema declaration, but that is a bit of a hack and ideally the generator would create either unique names or be able to deduplicate identical types internally before iterating over them in the templates.
Activity
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution
feat: multi-pass type name resolution (#2213)
mromaszewicz commentedon Mar 2, 2026
This was addressed in #2213, please enable name conflict resolution via the output options and file a new issue if it doesn't work for you