datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Union modes in Pydantic V2

Open pmbrull opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe.

With pydantic V2, union modes behave different by default from pydantic V1. We have issues with the default setup and would like to use union_mode='left_to_right'.

Describe the solution you'd like An argument for the CLI. Something like --union-mode XYZ.

Describe alternatives you've considered I tried playing with the templates. Updating the Union.jinja2. I guess I am doing something wrong there. If it is "as simple" as templating it out, happy to get it sorted that way as well.

Additional context

Using datamodel-code-generator==0.25.6 and Pythong 3.10.12

Thanks!!

pmbrull avatar Jun 04 '24 08:06 pmbrull