Include tag_value
as discriminator attribute when writing Ash.Type.Union to OpenAPI
#272
Labels
enhancement
New feature or request
It would be really useful to include more information about union type variants inside the OpenAPI output.
Say that I declare these types:
As things stand today, the output will be this:
Notice how it doesn't include the
tag_value
property defined in the embedded resources, and howSquare
andEquilaterialTriangle
are merged into the same object due to having the same fields.This is a bit unfortunate, since it throws away information about which variant the data comes from. This is useful information to have when using the OpenAPI specification to generate e.g. TypeScript or Swift types, since these languages can use the discriminator field to narrow down the current variant.
Ideally, I'd like to see this output instead:
In this version, the union type has a
"discriminator"
field, and how"type"
has been added as a single enum property to each variant type.Is this something you think could be useful? I'm happy to have a go at implementing it and making a PR.
The text was updated successfully, but these errors were encountered: