{#-
Related Schemas Component

Renders links to related schemas and inheritance information.
Handles schema relationships and references safely.
-#}

{% from 'macros/safe_macros.md.jinja2' import safe_section, safe_for %}
{% from 'macros/navigation.md.jinja2' import doc_link %}

{% set related_schemas = [] %}
{% if element.metadata.all_of %}
  {% set _ = related_schemas.extend(element.metadata.all_of) %}
{% endif %}
{% if element.metadata.any_of %}
  {% set _ = related_schemas.extend(element.metadata.any_of) %}
{% endif %}
{% if element.metadata.one_of %}
  {% set _ = related_schemas.extend(element.metadata.one_of) %}
{% endif %}

{% if related_schemas or element.metadata.discriminator %}
{% call safe_section("related_schemas") %}
## Related Schemas

{% if element.metadata.all_of %}
### Composed Of (All Of)

This schema is composed of all the following schemas:

{% call safe_for(element.metadata.all_of, "*No schemas in allOf.*") %}
- `{{ item.ref | default(item) }}`
{% endcall %}
{% endif %}

{% if element.metadata.any_of %}
### One Of (Any Of)

This schema matches any of the following schemas:

{% call safe_for(element.metadata.any_of, "*No schemas in anyOf.*") %}
- `{{ item.ref | default(item) }}`
{% endcall %}
{% endif %}

{% if element.metadata.one_of %}
### Exactly One Of

This schema matches exactly one of the following schemas:

{% call safe_for(element.metadata.one_of, "*No schemas in oneOf.*") %}
- `{{ item.ref | default(item) }}`
{% endcall %}
{% endif %}

{% if element.metadata.discriminator %}
### Discriminator

This schema uses a discriminator for polymorphism:

**Property:** `{{ element.metadata.discriminator.property_name }}`

{% if element.metadata.discriminator.mapping %}
**Mapping:**
{% call safe_for(element.metadata.discriminator.mapping.items(), "*No discriminator mapping.*") %}
- `{{ item[0] }}` → `{{ item[1] }}`
{% endcall %}
{% endif %}
{% endif %}
{% endcall %}
{% endif %}
