{% if base_class != "BaseModel" and "," not in base_class and not fields and not config -%}

{# if this is just going to be `class Foo(Bar): pass`, then might as well just make Foo
an alias for Bar: every pydantic model class consumes considerable memory. #}
{{ class_name }} = {{ base_class }}

{% else -%}

{% for decorator in decorators -%}
{{ decorator }}
{% endfor -%}
class {{ class_name }}({{ base_class }}):{% if comment is defined %}  # {{ comment }}{% endif %}
{%- if description %}
    """
    {{ description | indent(4) }}
    """
{%- endif %}
{%- if not fields and not description %}
    pass
{%- endif %}
{%- if config %}
{%- filter indent(4) %}
{% include 'ConfigDict.jinja2' %}
{%- endfilter %}
{%- endif %}
{%- for field in fields -%}
    {%- if not field.annotated and field.field %}
    {%- if field.alias and '@type' == field.alias %}
    {{ field.name }}: {{ field.type_hint }} = {{ field.field }}
    {%- else %}
    {{ field.name }}: {{ field.type_hint }} = Field(
        {%- if field.required %}...{%- else %}default=None{%- endif %},
        validation_alias=AliasChoices(
            '{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}',
            'https://schema.org/{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}'
        ),
        serialization_alias='https://schema.org/{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}'
    )
    {%- endif %}
    {%- else %}
    {%- if field.annotated %}
    {{ field.name }}: {{ field.annotated }}
    {%- else %}
    {{ field.name }}: {{ field.type_hint }} = Field(
        {%- if field.required %}...{%- else %}default=None{%- endif %},
        validation_alias=AliasChoices(
            '{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}',
            'https://schema.org/{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}'
        ),
        serialization_alias='https://schema.org/{%- if field.alias %}{{ field.alias }}{%- else %}{{ field.name }}{%- endif %}'
    )
    {%- endif %}
    {%- if not (field.required or (field.represented_default == 'None' and field.strip_default_none)) or field.data_type.is_optional
            %} = {{ field.represented_default }}
    {%- endif -%}
    {%- endif %}
    {%- if field.docstring %}
    """
    {{ field.docstring | indent(4) }}
    """
    {%- endif %}
{%- for method in methods -%}
    {{ method }}
{%- endfor -%}
{%- endfor -%}

{%- endif %}
