{%- from 'includes/type_hint.py.jinja' import type_hint %}
{%- macro render_field(field) %}
    {%- if field.annotation.field_props %}
    {{ field.name }}: typing.Annotated[
        {{ type_hint(field.annotation.type, path) }},
        pydantic.Field(
            {%- for key, value in field.annotation.field_props.items() | sort %}
            {{ key }}={{ value }},
            {%- endfor %}
        )
    ]
    {%- else %}
    {{ field.name }}: {{ type_hint(field.annotation.type, path) }}
    {%- endif -%}
    {%- if field.required is false %} = None{% endif %}
{%- endmacro %}
class {{ model.class_name }}({{ type_hint(model.base_type, path) }}):
{%- for field in model.fields if field.required %}
{{- render_field(field) }}
{% endfor %}
{%- for field in model.fields if not field.required %}
{{- render_field(field) }}
{% endfor %}

{%- if model.allow_extra %}
    model_config = pydantic.ConfigDict(
        extra='allow'
    )
{% endif -%}
