{# Bengal OpenAPI Home Page ======================== API landing page showing: - API title and description - Version and server information - Authentication schemes - Tag/endpoint category overview Context: - section: Section with metadata containing API overview data - section.metadata.version: API version - section.metadata.servers: Server URLs - section.metadata.security_schemes: Auth schemes - section.metadata.tags: API categories - page: Page object - site: Site instance - config: Config instance The `endpoints` and `schemas` filters normalize access to endpoint/schema data regardless of whether the source is DocElements or Pages. Note: For section index pages, `element` is None. Use section.metadata instead. Kida Features: - {% with %} for nil-resilient optional sections - {% spaceless %} for compact badge output - Optional chaining (?.) and null coalescing (??) #} {% extends 'autodoc/openapi/layouts/reference.html' %} {# Access metadata from section (set by section_builders.py) #} {% let sec_meta = section?.metadata ?? {} %} {% let api_title = section?.title ?? page?.title ?? 'API Reference' %} {% let api_version = sec_meta?.version ?? '1.0.0' %} {% let servers = sec_meta?.servers ?? () %} {% let security_schemes = sec_meta?.security_schemes ?? {} %} {% let tags = sec_meta?.tags ?? () %} {% let description = sec_meta?.description ?? '' %} {# Use filters for normalized access #} {% let eps = section | endpoints %} {% let schs = section | schemas %} {% block header %}

{{ api_title }}

{% if api_version %}
v{{ api_version }}
{% end %} {% if description %}
{{ description | markdownify | safe }}
{% end %} {% end %} {% block content_main %}
{# Quick Stats #} {% let endpoint_count = eps | length %} {% let schema_count = schs | length %} {% let tag_count = tags | length %} {% if endpoint_count > 0 or schema_count > 0 %}
{% if endpoint_count > 0 %}
{{ endpoint_count }} Endpoints
{% end %} {% if schema_count > 0 %}
{{ schema_count }} Schemas
{% end %} {% if tag_count > 0 %}
{{ tag_count }} Categories
{% end %}
{% end %} {# Base URLs / Servers #} {% if servers | length > 0 %}

{{ icon('server', size=18) }} Base URLs

{% for server in servers %} {% let server_url = server if server is string else server?.url ?? server %} {% let server_desc = '' if server is string else server?.description ?? '' %}
{{ server_url }} {% if server_desc %} {{ server_desc }} {% end %}
{% end %}
{% end %} {# Authentication #} {% if security_schemes | length > 0 %}

{{ icon('lock', size=18) }} Authentication

{% for name, scheme in security_schemes |> items %} {% if scheme %} {% let scheme_type = scheme?.type ?? 'apiKey' %} {% let scheme_desc = scheme?.description ?? '' %} {% let scheme_in = scheme.get('in', 'header') %} {% let scheme_name = scheme?.name ?? 'Authorization' %}

{{ icon('key', size=14) }} {{ name }}

{{ scheme_type }}
{% if scheme_desc %}

{{ scheme_desc }}

{% end %} {% match scheme_type %} {% case 'apiKey' %} {{ scheme_name }}: YOUR_API_KEY {% case 'http' %} {% if scheme?.scheme == 'bearer' %} Authorization: Bearer YOUR_TOKEN {% else %} Authorization: Basic BASE64_CREDENTIALS {% end %} {% case 'oauth2' %} Authorization: Bearer ACCESS_TOKEN {% case _ %} {{ scheme_name }}: YOUR_CREDENTIALS {% end %}
{% end %} {% end %}
{% end %} {# Endpoint Categories (Tags) - Quick Jump Navigation #} {% let subsections = section?.subsections ?? () %} {% if subsections | length > 0 %}

{{ icon('folder', size=18) }} Categories

{% for subsec in subsections %} {% let tag_name = subsec?.title ?? 'Endpoints' %} {% let tag_desc = subsec?.metadata?.description ?? '' %} {% let tag_endpoints = subsec | endpoints %}

{{ tag_name }}

{{ tag_endpoints | length }}
{% if tag_desc %}

{{ tag_desc | truncate(100) }}

{% end %}
{% end %}
{% end %} {# Endpoints Grouped by Tag - with anchor IDs matching category tiles #} {% if subsections | length > 0 %} {% for subsec in subsections %} {% let tag_name = subsec?.title ?? 'Endpoints' %} {% let tag_desc = subsec?.metadata?.description ?? '' %} {% let tag_endpoints = subsec | endpoints %} {% if tag_endpoints | length > 0 %}

{{ icon('tag', size=18) }} {{ tag_name }}

{% if tag_desc %}

{{ tag_desc }}

{% end %}
{% end %} {% end %} {% end %} {# All Endpoints (only if no subsections/tags exist) #} {% if subsections | length == 0 and eps | length > 0 %}

{{ icon('list', size=18) }} Endpoints

{% end %} {# Schemas #} {% if schs | length > 0 %}

{{ icon('database', size=18) }} Schemas

{% end %}
{% end %}