Open colmanhumphrey opened 6 months ago
That behavior was ignored by Pydantic until 2.8.2, but starting 2.9.0 it end up with the error on generated model:
TypeError: 'list' is not a valid discriminated union variant; should be a
BaseModelor
dataclass``
Maybe there is workaround to bypass it?
This is blocking us from upgrading pydantic, does anyone have any workaround?
This is blocking us from upgrading pydantic, does anyone have any workaround?
the same issue :/
Describe the bug
Generation of list/array of discriminated union annotates the list, not the union. Same problem with
= Field(..., discriminator)
too if you don't use annotated.To Reproduce
Example schema:
Used commandline:
This gives:
This doesn't work:
Expected behavior
The problem is that the Annotation should be on the Union, not on the list, so the SomeTest class should be:
And now it works. Note that we get more or less the same problem if you remove
--use-annotated
Version:
Additional context
Thanks!