{%- set ref = get_type_for_items(model) %}

class {{ name }}(ModelSimple):
    """
    {{ model.description|docstring|indent(8) }}

{# empty line #}
{%- if "default" in model and model.default != None %}
    :param value: If omitted defaults to "{{ model.default }}".
{%- endif %}
{%- if ref %}
    :type value: [{{ ref }}]
{%- else %}
    :type value: [{{ type_to_python(model.get("items"), in_list=True) }}{%- if model["items"].get("nullable") %}, none_type{%- endif %}]
{%- endif %}
    """

{% set validation_ns = namespace(started=false) %}
{%- set has_validation = (
      (not model.nullable and required) or
      model.maxLength is defined or
      model.minLength is defined or
      model.maximum is defined or
      model.minimum is defined or
      model.pattern is defined or
      model.maxItems is defined or
      model.minItems is defined
    ) %}
{%- if has_validation %}
{%- if not validation_ns.started %}
    validations = {
{%- set validation_ns.started = true %}
{%- endif %}
        "value": {
{%- if model.maxLength is defined %}
            "max_length": {{ model.maxLength }},
{%- endif %}
{%- if model.minLength is defined %}
            "min_length": {{ model.minLength }},
{%- endif %}
{%- if model.maxItems is defined %}
            "max_items": {{ model.maxItems }},
{%- endif %}
{%- if model.minItems is defined %}
            "min_items": {{ model.minItems }},
{%- endif %}
{%- if model.maximum is defined %}
            "inclusive_maximum": {{ model.maximum }},
{%- endif %}
{%- if model.minimum is defined %}
            "inclusive_minimum": {{ model.minimum }},
{%- endif %}
        },
{%- endif %}
{%- if validation_ns.started %}
    }
{%- endif %}

    @cached_property
    def openapi_types(_):
{%- if ref %}
        from {{ package }}.{{ version }}.model.{{ ref|safe_snake_case }} import {{ ref }}
        return {
            "value": ([{{ ref }}],),
        }
{%- else %}
        return {
            "value": ([{{ type_to_python(model.get("items"), in_list=True) }}{%- if model["items"].get("nullable") %}, none_type{%- endif %}],),
        }
{%- endif %}
