{% extends "base.html" %} {# ================================================================================ OpenAPI Reference Endpoint Template (Kida-Native v2) ================================================================================ Three-panel layout optimized for REST API documentation. Uses the unified autodoc skeleton with OpenAPI-specific extensions. This template receives: - element: DocElement for the endpoint - config: Autodoc configuration - site: Site instance KIDA FEATURES USED: - {% let %} for scoped variable binding - {% match %} for HTTP method dispatching and status code styling - {% with %} for nil-resilient metadata access - {% cache %} for expensive response table rendering - Pipeline operators (|>) for clean filter chains - {% spaceless %} for compact badge rendering - Optional chaining (?.) and null coalescing (??) ================================================================================ #} {% from 'partials/navigation-components.html' import breadcrumbs, page_navigation, toc %} {# ============================================================================= HTTP METHOD STYLING DATA Centralized for consistency and easy customization ============================================================================= #} {% let HTTP_METHODS_WITH_BODY = ['POST', 'PUT', 'PATCH'] %} {# ============================================================================= STATUS CODE HELPER MACRO Returns semantic category for styling ============================================================================= #} {% def status_category(code) %} {% match code | string | first %} {% case '2' %}success {% case '3' %}redirect {% case '4' %}client-error {% case '5' %}server-error {% case _ %}info {% end %} {% end %} {% block content %} {# Extract element metadata with nil-resilience #} {% let meta = element?.metadata ?? {} %} {% let http_method = meta?.method ?? 'GET' %} {% let endpoint_path = meta?.path ?? '/' %} {% let operation_id = meta?.operation_id %} {% let is_deprecated = meta?.deprecated ?? false %} {% let summary = meta?.summary ?? element?.description ?? '' %} {# Three-panel REST API layout #}
{# Left Sidebar: Navigation #} {# Center: Endpoint Documentation #}
{# Breadcrumbs #} {{ breadcrumbs(page) }} {# Article Content - New autodoc skeleton #}
{# Header with method badge - pattern matched styling #}
{% if is_deprecated %}
Deprecated
{% end %}

{{ http_method |> upper }} {{ endpoint_path }}

{% if summary %}

{{ summary }}

{% end %} {% if operation_id %}
Operation ID: {{ operation_id }}
{% end %}
{# Parameters Section #} {% with meta?.parameters as api_params %} {% if api_params | length > 0 %} {% let params = api_params %} {% let title = 'Parameters' %} {% include 'autodoc/partials/params-table.html' %} {% end %} {% end %} {# Request Body Section #} {% with meta?.request_body as req_body %} {% if req_body %}

Request Body

{% if req_body?.description %}

{{ req_body.description }}

{% end %} {% with req_body?.content as content_types %} {% if content_types %} {% spaceless %}
{% for content_type, schema in content_types |> items %} {{ content_type }} {% end %}
{% end %} {% end %} {% end %}
{% end %} {% end %} {# Responses Section - with cache for complex rendering #} {% with meta?.responses as responses %} {% if responses | length > 0 %}

Responses

{% cache 'openapi-responses-' ~ endpoint_path ~ '-' ~ http_method %} {% for status_code, response in responses |> items %} {% let category = status_category(status_code) %} {% end %}
Status Description Content Type
{{ status_code }} {{ response?.description ?? t('api.no_description', default='No description') }} {% with response?.content as content %} {% if content %} {% spaceless %} {% for content_type in content |> keys %} {{ content_type }}{% if not loop.last %}, {% end %} {% end %} {% end %} {% else %} {% end %} {% end %}
{% end %}
{% end %} {% end %} {# Tags #} {% with page?.tags as tags %} {% if tags | length > 0 %}
Tagged {% from 'partials/components/tags.html' import tag_list %} {{ tag_list(tags) }}
{% end %} {% end %}
{# Page navigation (prev/next) at bottom #} {{ page_navigation(page) }}
{# Right Panel: Code Examples #}
{# Mobile sidebar toggle button #} {# Sidebar overlay for mobile #} {% end %}