2023-11-28 14:29:16 -08:00
|
|
|
from typing import Dict, Any, Union, Type, TypeVar
|
2023-11-29 10:32:31 -08:00
|
|
|
from pydantic import RootModel, Field
|
2023-11-28 14:16:05 -08:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
from typing_extensions import Annotated
|
2023-11-28 23:50:50 -08:00
|
|
|
|
2023-11-29 10:32:31 -08:00
|
|
|
|
|
|
|
|
|
|
|
{% if tag %}
|
|
|
|
{{name}} = RootModel[Annotated[Union[
|
|
|
|
{% for type in types %}
|
|
|
|
{{type.name}},
|
|
|
|
{% endfor %}
|
|
|
|
], Field(discriminator='{{tag}}')]]
|
|
|
|
{% else %}
|
2023-11-29 00:39:14 -08:00
|
|
|
{{name}} = RootModel[Union[
|
2023-11-28 14:16:05 -08:00
|
|
|
{% for type in types %}
|
|
|
|
{{type.name}},
|
|
|
|
{% endfor %}
|
2023-11-29 00:39:14 -08:00
|
|
|
]]
|
2023-11-29 10:32:31 -08:00
|
|
|
{% endif %}
|
2023-11-28 23:50:50 -08:00
|
|
|
|