{% from "helpers.jinja" import safe_docstring %}

{% set class_name = model.class_info.name %}
{% set module_name = model.class_info.module_name %}

{% macro class_docstring_content(model) %}
    {% if model.title %}{{ model.title | wordwrap(116) }}

    {% endif -%}
    {%- if model.description %}{{ model.description | wordwrap(116) }}

    {% endif %}
    {% if not model.title and not model.description %}
    {# Leave extra space so that a section doesn't start on the first line #}

    {% endif %}
    {% if model.example %}
    Example:
        {{ model.example | string | wordwrap(112) | indent(12) }}

    {% endif %}
    {% if model.required_properties or model.optional_properties %}
    Attributes:
    {% for property in model.required_properties + model.optional_properties %}
        {{ property.to_docstring() | wordwrap(112) | indent(12) }}
    {% endfor %}{% endif %}
{% endmacro %}

from __future__ import annotations

import datetime
from pydantic import BaseModel, ConfigDict, Field
from typing import TYPE_CHECKING, TypedDict, Any, Union, Literal
from uuid import UUID

{% for relative in model.relative_imports | sort %}
{{ relative }}
{% endfor %}

{% for lazy_import in model.lazy_imports %}
{% if loop.first %}
if TYPE_CHECKING:
{% endif %}
  {{ lazy_import }}
{% endfor %}

class {{ class_name }}(BaseModel):
    {{ safe_docstring(class_docstring_content(model)) | indent(4) }}

    {% for property in model.required_properties + model.optional_properties %}
    {{ property | to_pydantic_field }}
    {% endfor %}

    model_config = ConfigDict(validate_by_name=True, validate_by_alias=True)
