{#
Bengal OpenAPI Parameter Row
============================

Atomic display unit for a single API parameter.
Shows name, type, required status, and description.

Context:
- param: OpenAPIParameterMetadata or dict with:
  - name: Parameter name
  - schema_type: Type (string, integer, array, etc.)
  - location: Where parameter is sent (path, query, header, cookie)
  - required: bool
  - description: Parameter description
  - default: Default value (optional)
  - enum: List of allowed values (optional)
  - example: Example value (optional)

Kida Features:
- {% with %} for nil-safe optional sections
- {% spaceless %} for compact badge output
- Optional chaining (?.) and null coalescing (??)
#}
{% let name = param?.name ?? 'unnamed' %}
{% let type = param?.schema_type ?? 'string' %}
{% let location = param?.location ?? 'query' %}
{% let is_required = param?.required ?? false %}
{% let description = param?.description ?? '' %}
{% let default_val = param?.default %}
{% let enum_vals = param?.enum %}
{% let example = param?.example %}

<div class="api-param-row{% if is_required %} api-param-row--required{% end %}" data-required="{{ is_required }}">
  {# Parameter Meta: Name, Type, Badges #}
  <div class="api-param-row__meta">
    <code class="api-param-row__name">{{ name }}</code>
    <span class="api-param-row__type">{{ type }}</span>

    {% spaceless %}
    <div class="api-param-row__badges">
      {% if is_required %}
      <span class="badge badge--danger-subtle badge--sm">required</span>
      {% end %}
      <span class="badge badge--outline badge--sm">{{ location }}</span>
    </div>
    {% end %}
  </div>

  {# Description #}
  {% if description %}
  <div class="api-param-row__description">
    {{ description | markdownify | safe }}
  </div>
  {% end %}

  {# Default Value #}
  {% with default_val as default %}
  <div class="api-param-row__default">
    <span class="api-param-row__label">Default:</span>
    <code>{{ default }}</code>
  </div>
  {% end %}

  {# Enum Values #}
  {% with enum_vals as enums %}
  {% if enums | length > 0 %}
  <div class="api-param-row__enum">
    <span class="api-param-row__label">Allowed:</span>
    {% spaceless %}
    {% for val in enums %}
    <code class="api-param-row__enum-value">{{ val }}</code>{% if not loop.last %} {% end %}
    {% end %}
    {% end %}
  </div>
  {% end %}
  {% end %}

  {# Example #}
  {% with example as ex %}
  <div class="api-param-row__example">
    <span class="api-param-row__label">Example:</span>
    <code>{{ ex }}</code>
  </div>
  {% end %}
</div>
