{# Bengal OpenAPI Schema Page ========================== Standalone schema/model documentation page. Displays JSON Schema object structure with examples. Context: - element: DocElement with OpenAPISchemaMetadata - page: Page object - section: Section for navigation - site: Site instance - config: Config instance Kida Features: - {% with %} for nil-resilient optional sections - {% cache %} for expensive schema rendering - Optional chaining (?.) and null coalescing (??) #} {% extends 'autodoc/openapi/layouts/reference.html' %} {% from 'autodoc/openapi/_schema.html' import schema_viewer %} {% let schema = element | schema_view %} {% let schema_name = schema?.name ?? page?.title ?? 'Schema' %} {% let schema_type = schema?.schema_type ?? 'object' %} {% let properties = schema?.properties ?? {} %} {% let required_props = schema?.required ?? () %} {% let enum_vals = schema?.enum %} {% let example_val = schema?.example %} {% let description = schema?.description ?? element?.description ?? '' %} {% let schema_format = schema?.raw_schema?.format ?? '' %} {% let composition = schema?.display_schema | schema_composition %} {% let additional = schema?.display_schema | schema_additional_properties %} {% let flags = schema?.display_schema | schema_flags %} {# A schema has a renderable "body" when it has properties, is composed (oneOf/anyOf/allOf), or is an open/typed map (additionalProperties). #} {% let has_body = properties | length > 0 or composition is not none or additional is not none %} {% block api_left %} {% end %} {% block api_header %} Schema

{{ schema_name }} {{ schema_type }} {% if flags?.deprecated %}deprecated{% end %}

{% if description %}
{{ description | markdownify | safe }}
{% end %} {% end %} {% block api_main %}
{# Schema body: properties, composition (oneOf/anyOf/allOf), and/or open maps. Rendered once through the recursive viewer so composed and polymorphic schemas (which often have no direct properties) still get a full detail body, not an empty page. #} {% if has_body %}

{% if properties | length > 0 %}Properties{% elif composition is not none %}Variants{% else %}Structure{% end %}

{% cache 'openapi-schema-' ~ schema_name %} {{ schema_viewer(schema?.display_schema ?? {}, name=schema_name, depth=0) }} {% end %}
{% end %} {% if not has_body and enum_vals | length == 0 %}

Shape

Type {{ schema_type }}
{% if schema_format %}
Format {{ schema_format }}
{% end %}
{# Primitive schemas don't go through the viewer, so render their flags and validation constraints here so pattern/min/max/format still surface. #} {% let shape_flags = schema?.display_schema | schema_flags %} {% if shape_flags?.nullable or shape_flags?.deprecated %}
{% if shape_flags?.nullable %}nullable{% end %} {% if shape_flags?.deprecated %}deprecated{% end %}
{% end %} {% let shape_constraints = schema?.display_schema | schema_constraints %} {% if shape_constraints | length > 0 %}
{% for clabel, cvalue in shape_constraints |> items %} {{ clabel }}{% if cvalue %}: {{ cvalue }}{% end %} {% end %}
{% end %}
{% end %} {# Enum Values (for enum types) #} {% with enum_vals as enums %} {% if enums | length > 0 %}

Allowed Values

{% for val in enums %} {{ val }} {% end %}
{% end %} {% end %} {# Example — only for primitive/enum schemas without a viewer body; body schemas render their examples inside the viewer above (no duplication). #} {% if example_val is not none and not has_body %} {% let example = example_val %}

Example

{{ example | tojson(indent=2) }}
{% end %} {# Usage Information #} {% with element?.see_also as refs %} {% if refs | length > 0 %}

Used In

{% end %} {% end %}
{% end %} {% block api_right %}

{{ icon('database', size=14) }} Model

Name
{{ schema_name }}
Type
{{ schema_type }}
{% if schema_format %}
Format
{{ schema_format }}
{% end %}
Properties
{{ properties | length }}
Required
{{ required_props | length }}
{% if enum_vals | length > 0 %}
Values
{{ enum_vals | length }}
{% end %} {% if composition is not none %}
{{ composition.kind }}
{{ composition.branches | length }} variants
{% end %} {% if composition?.discriminator %}
Discriminator
{{ composition.discriminator.property_name }}
{% end %}
{% end %}