{# This is a customised version of the default template for dataclasses at #}
{# https://github.com/koxudaxi/datamodel-code-generator/blob/main/datamodel_code_generator/model/template/dataclass.jinja2 #}

{% for decorator in decorators -%}
{{ decorator }}
{% endfor -%}
@dataclass
{%- if base_class %}
class {{ class_name }}({{ base_class }}):
{%- else %}
class {{ class_name }}:
{%- endif %}
{%- if description %}
    """{{ description | wordwrap(80) | indent(4) }}

    Attributes:
{%- for field in fields %}
    {%- if not field.name.startswith("ignore") %}
        {%- set wrapped = (field.name ~ " (" ~ field.type_hint ~ "): " ~ (field.docstring or "")) | wordwrap(70) %}
        {%- set lines = wrapped.split("\n") %}
        {{ lines[0] }}
        {%- for line in lines[1:] %}
            {{ line }}
        {%- endfor %}
    {%- endif %}
{%- endfor %}
    """
{%- endif %}
{%- if not fields and not description %}
    pass
{%- endif %}
{%- for field in fields -%}
    {%- if not field.name.startswith("ignore") %}
    {%- if field.field %}
    {{ field.name }}: {{ field.type_hint }} = {{ field.field }}
    {%- else %}
    {{ field.name }}: {{ field.type_hint }}
    {%- if not (field.required or (field.represented_default == "None" and field.strip_default_none))
            %} = {{ field.represented_default }}
    {%- endif -%}
    {%- endif %}
    {%- endif %}
{%- endfor -%}
