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
acme/client.gen.go:27357:6: Id0 redeclared in this block
acme/client.gen.go:27351:6: other declaration of Id0
acme/client.gen.go:27360:6: Id1 redeclared in this block
acme/client.gen.go:27354:6: other declaration of Id1
acme/client.gen.go:27363:6: Id0 redeclared in this block
acme/client.gen.go:27351:6: other declaration of Id0
acme/client.gen.go:27366:6: Id1 redeclared in this block
acme/client.gen.go:27354:6: other declaration of Id1
acme/client.gen.go:27374:6: Id0 redeclared in this block
acme/client.gen.go:27351:6: other declaration of Id0
acme/client.gen.go:27377:6: Id1 redeclared in this block
acme/client.gen.go:27354:6: other declaration of Id1
acme/client.gen.go:27380:6: Id0 redeclared in this block
acme/client.gen.go:27351:6: other declaration of Id0
acme/client.gen.go:27383:6: Id1 redeclared in this block
acme/client.gen.go:27354:6: other declaration of Id1
acme/client.gen.go:27386:6: Id0 redeclared in this block
acme/client.gen.go:27351:6: other declaration of Id0
acme/client.gen.go:27389:6: Id1 redeclared in this block
acme/client.gen.go:27354:6: other declaration of Id1
acme/client.gen.go:27389:6: too many errors
I can't fix this automatically, but I can detect that a collision will happen when we validate the spec before code generation.
Two path level based parameters with the same name id, will conflict with each other, since they create global types. The codegen will now error out with a message recommending to use a spec overlay or x-go-type-name or simply to rename one of the parameters out of conflict. x-go-type-name preserves the name on the wire, but the name on the wire doesn't matter very much for the path parameters, since it's never referenced by name, just by position. There are some bugs related around this that I'm fixing to make it a little more robust, but I can't make a general fix without some major upheaval in the generated code that will break a lot of users.
After my fix, it will work if you only have a single path level parameter named id in your spec.
If you have lots of paths referencing an id parameter, it's better to put it under #/components/schemas/parameters.
When two different paths hoist parameters to named types to add functions onto them, they can collide within a single pathItem, and across multiple pathItems, so the global parameters must be decorated with some kind of prefix or suffix.
The only thing which differentiates them from each other is the path itself. So, what I'm going to do is detect potential collisions across params globally, and if there are collisions, they're going to get suffixed with a few characters of the hash of the path. This makes them stable with respect to paths. i considered ordinal numbering, which is unstable, and also turning the path into a word, but I'd argue this is uglier than the hash suffix.
Activity
mromaszewicz commentedon Jul 13, 2026
I can't fix this automatically, but I can detect that a collision will happen when we validate the spec before code generation.
Two path level based parameters with the same name
id, will conflict with each other, since they create global types. The codegen will now error out with a message recommending to use a spec overlay orx-go-type-nameor simply to rename one of the parameters out of conflict.x-go-type-namepreserves the name on the wire, but the name on the wire doesn't matter very much for the path parameters, since it's never referenced by name, just by position. There are some bugs related around this that I'm fixing to make it a little more robust, but I can't make a general fix without some major upheaval in the generated code that will break a lot of users.After my fix, it will work if you only have a single path level parameter named
idin your spec.If you have lots of paths referencing an id parameter, it's better to put it under
#/components/schemas/parameters.Generate shared path-level parameter helper types once
Generate shared path-level parameter helper types once
Generate shared path-level parameter helper types once (oapi-codegen#…
mromaszewicz commentedon Jul 17, 2026
This is hard to fix.
I am reverting the PR above as part of my fix.
When two different paths hoist parameters to named types to add functions onto them, they can collide within a single pathItem, and across multiple pathItems, so the global parameters must be decorated with some kind of prefix or suffix.
The only thing which differentiates them from each other is the path itself. So, what I'm going to do is detect potential collisions across params globally, and if there are collisions, they're going to get suffixed with a few characters of the hash of the path. This makes them stable with respect to paths. i considered ordinal numbering, which is unstable, and also turning the path into a word, but I'd argue this is uglier than the hash suffix.
Name shared path parameter helper types once, hashing cross-path coll…
Name shared path parameter helper types once, hashing cross-path coll…