ogen icon indicating copy to clipboard operation
ogen copied to clipboard

Generated type for Discriminator conflicts with existing type

Open dan-j opened this issue 2 years ago • 2 comments

What version of ogen are you using?

$ go list -m github.com/ogen-go/ogen

github.com/ogen-go/ogen v0.72.0

Can this issue be reproduced with the latest version?

Yes

What did you do?

  1. Define a schema component like FooType which is an enum of strings.
  2. Create a oneOf sum type called Foo where the discriminator.propertyName = 'type'
  3. The library generates two types named FooType, one for the enum and another as the discriminator type.

I've tried to use the x-ogen-name extension on the discriminator object but this doesn't change anything.

What did you expect to see?

To generate a unique name, or use the extension property to manually control it.

What did you see instead?

Go code which does not compile.

dan-j avatar Jul 27 '23 11:07 dan-j

Looks like this is hardcoded within the template, it's going to be hard to fix this

https://github.com/ogen-go/ogen/blob/eb1bcf60a92dbea6dd2b0fea1870944f4c0c150a/gen/_template/schema/sum.tmpl#L4-L26

dan-j avatar Jul 27 '23 20:07 dan-j

This is still open? Hm.

bZichett avatar Oct 03 '25 18:10 bZichett