Question on declaring @anyOf on Named Unions #4387
-
I'm finding that declaring a Named Union with the I also tried decorating the property in the Model that accepts the Named Union as the value with Example can be found here However, removing the Name Union and using a Union Expression inside the model, will allow it to generate with Example can be found here Should the first example work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I think in the first case it might be a confusion in the syntax that result in not exactly what you expect In named union the variants are separated with comma See this playground showing the difference |
Beta Was this translation helpful? Give feedback.
I think in the first case it might be a confusion in the syntax that result in not exactly what you expect
In named union the variants are separated with comma
,
. What you have is a union of modelA
andB
inside that named union. So when openapi3 sees it, it sees a union with a single variantA | B
so just ignore anyOf or oneOf and just render the single variant which happens to be a union which is then not annotated with@oneOf
See this playground showing the difference