Files
kittycad.py/generate/union-type.py.jinja2
Jess Frazelle ed36086040 working samples
Signed-off-by: Jess Frazelle <github@jessfraz.com>
2023-11-29 10:32:31 -08:00

22 lines
435 B
Django/Jinja

from typing import Dict, Any, Union, Type, TypeVar
from pydantic import RootModel, Field
from typing_extensions import Annotated
{% if tag %}
{{name}} = RootModel[Annotated[Union[
{% for type in types %}
{{type.name}},
{% endfor %}
], Field(discriminator='{{tag}}')]]
{% else %}
{{name}} = RootModel[Union[
{% for type in types %}
{{type.name}},
{% endfor %}
]]
{% endif %}