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
I had a quick poke around in the code and I'm not familiar enough the internals of pydantic to make an obvious patch (the current tagged_union.py logic assumes that the fields will all be available as literals when the model is created. However I did end up whipping up a really simple unit test that hopefully highlights the issue.
joshvote
changed the title
Support for discriminated uniones with callable discriminator
Support for discriminated unions with callable discriminator
Jan 4, 2024
The latest pydantic release has added support for Union discriminators that can be implemented via a custom function: https://docs.pydantic.dev/latest/concepts/unions/#discriminated-unions-with-callable-discriminator
I recently attempted to utilise this with pydantic-xml but ran into the following error raised by pydantic-xml:
E pydantic_xml.errors.ModelFieldError: .... field type error: only string discriminators are supported
I'd be willing to contribute a PR if you're able to point me in the right direction of how to add support for this to pydantic-xml
The text was updated successfully, but these errors were encountered: