{% load i18n passerelle %}
<li class="{{ endpoint.http_method|default:"get" }}-method">
  <div class="toggler"></div>
  <div class="description">{% if endpoint.description %}<span class="description--label">{{endpoint.description}}{% trans ':' %}</span>{% endif %}
    <a href="{{endpoint.example_url}}" class="example-url">{{ site_base_uri }}{{endpoint.example_url_as_html}}</a>
  </div>
  <ul class="params">
    {% if endpoint.get_params %}
      <li>
        <ul class="get-params">
          {% for param in endpoint.get_params %}
            <li><span class="param-name">{{param.name}}</span>
              {% if param.optional %}<span class="param-optional">({% trans 'optional' %}{% if param.default_value %},
                {% trans 'default value:' %} {{param.default_value}}{% endif %})</span>{% endif %}
              {% if param.description %}{% trans ':' %} {{param.description}}{% endif %}
              <span class="type">({% if param.type %}{{ param.type }}{% else %}string{% endif %}{% if param.blank is False %}, {% trans "not empty" %}{% endif %})</span>
            </li>
          {% endfor %}
        </ul>
      </li>
    {% endif %}
    {% if endpoint.body_schemas %}
      <li><span class="params-title">{% trans "Request body" %}</span>
        <div class="body-schemas">
          {% render_body_schemas body_schemas=endpoint.body_schemas %}
          {% if endpoint.body_schemas|get:"application/json"|get:"unflatten" %}
            <div class="pk-information">{% blocktrans trimmed %}
              Object or array parameters can be sent as flat elements, with keys and subkeys separated
              by a / character, eg: <tt>{"element": {"child": "value"}}</tt> can
              be sent as <tt>{"element/child": "value"}</tt>.
            {% endblocktrans %}</div>
          {% endif %}
        </div>
      </li>
    {% endif %}
    {% if endpoint.response_schemas %}
      <li><span class="params-title">{% trans "Response body" %}</span>
        <div class="body-schemas">
          {% render_body_schemas body_schemas=endpoint.response_schemas %}
        </div>
      </li>
    {% endif %}
    {% if endpoint.post.input_example %}
      <li><span class="params-title">{% trans "Request example" %}</span>
        <pre class="endpoint-input-example">{{ endpoint.post.input_example|json_dumps }}</pre>
      </li>
    {% endif %}
  </ul>
  {% if endpoint.long_description %}
    <div class="long-description">
      {{ endpoint.long_description|linebreaks }}
    </div>
  {% endif %}
</li>
