{# Bengal OpenAPI Schema Viewer ============================ Recursive component for displaying JSON Schema / OpenAPI schema objects. Supports nested objects, arrays, enums, and examples. Context: - schema: OpenAPISchemaMetadata or dict with: - schema_type: Type (object, array, string, etc.) - properties: Dict of property definitions - required: Tuple of required property names - enum: Enum values (optional) - example: Example value (optional) - items: Array item schema (for arrays) - description: Schema description - name: Schema name (optional, for display) - depth: Nesting depth (for indentation, default 0) Kida Features: - {% cache %} for expensive recursive rendering (500+ endpoint specs) - {% with %} for nil-safe optional sections - Recursive {% include %} for nested objects - Optional chaining (?.) and null coalescing (??) #} {% let schema_type = schema?.schema_type ?? 'object' %} {% let properties = schema?.properties ?? {} %} {% let required_props = schema?.required ?? () %} {% let enum_vals = schema?.enum ?? none %} {% let example_val = schema?.example ?? none %} {% let items_schema = schema?.items ?? none %} {% let description = schema?.description ?? '' %} {% let current_depth = depth ?? 0 %} {% let max_depth = 4 %} {% cache 'schema-viewer-' ~ (name ?? 'anon') ~ '-' ~ current_depth %}
{{ name }}
{{ schema_type }}
{{ prop_name }}
{{ prop_type }}
{% if is_required %}
required
{% end %}
{{ val }}
{% end %}
{{ default }}
{{ items_schema?.type ??
items_schema?.schema_type ?? 'any' }}
{% end %}
{{ val }}
{% end %}
{{ example | tojson(indent=2) }}