{%- macro restriction(inner_text, css_class_name) -%}

{{ inner_text }}

{%- endmacro -%} {%- macro tabbed_section(operator, property, property_path, index) -%}

{%- set tab_label = "Option" -%} {%- if operator == "allOf" -%} {%- set tab_label = "Requirement" -%} {%- endif -%}
{%- for element in property[operator] -%} {%- set tab_id = index ~ "__option" ~ loop.index -%}
{{ content(tab_id, tab_label ~ " " ~ loop.index, element, property_path) }}
{%- endfor -%}
{%- endmacro -%} {%- macro content(index, property_name, property, property_path) -%} {%- set property, property_path = (property | resolve_ref(schema, property_path)) -%} {%- set description = property.get("description") | get_description -%} {# Display description #} {%- if description -%} {%- if description is description_short -%} {{ description | markdown }} {%- else -%}
{{ description | markdown }}
{%- endif -%} {%- endif -%} {# Handle having oneOf or allOf with only one condition #} {%- if "allOf" in property and (property["allOf"] | length) == 1 -%} {{ content(index, property_name, property["allOf"][0], property_path) }} {%- elif "anyOf" in property and (property["anyOf"] | length) == 1 -%} {{ content(index, property_name, property["anyOf"][0], property_path) }} {%- else -%} {# Resolve type #} {%- set default, has_default = property | get_default -%} {%- set type = property | get_type_name -%} {# Display type #} {%- if not property is combining -%} Type: {{ type }} {%- endif -%} {%- if has_default -%} {{ " " }}Default: {{ default | python_to_json }} {%- endif -%} {%- if "properties" in property -%} {%- set required_properties = property.get("required") or [] -%} {%- for sub_property_name, sub_property in property["properties"].items() -%} {{ subsection(False, loop.index, index, sub_property_name, sub_property, required_properties, property_path) }} {%- endfor -%} {%- endif -%} {# Handle actual requirement #} {%- if "allOf" in property -%}
{{ tabbed_section("allOf", property, property_path, index) }}
{%- endif -%} {%- if "anyOf" in property -%}
{{ tabbed_section("anyOf", property, property_path, index) }}
{%- endif -%} {%- if "oneOf" in property -%}
{{ tabbed_section("oneOf", property, property_path, index) }}
{%- endif -%} {%- if "not" in property -%}

Must not be:

{{ content(index ~ "_not", property_name, property["not"], property_path) }}
{%- endif -%} {%- if "enum" in property -%}

Must be one of:

{%- endif -%} {%- if "const" in property -%} Specific value: {{ property.const | python_to_json }} {%- endif -%} {%- if "pattern" in property -%} Must match regular expression: {{ property.pattern }} {%- endif -%} {%- if type == "string" -%} {%- if "minLength" in property -%} {{ restriction("Must be at least " ~ property.minLength ~ " characters long", "min-length") }} {%- endif -%} {%- if "maxLength" in property -%} {{ restriction("Must be at most " ~ property.maxLength ~ " characters long", "max-length") }} {%- endif -%} {%- endif -%} {%- if type in ["integer", "number"] -%} {%- set restriction_text = (property | get_numeric_restrictions_text("", "")) -%} {%- if restriction_text -%} {{ restriction(property | get_numeric_restrictions_text("", ""), "numeric") }} {%- endif -%} {%- endif -%} {%- if type.startswith("array") -%} {%- if "minItems" in property -%} {{ restriction("Must contain a minimum of " ~ property.minItems ~ " items", "min-items") }} {%- endif -%} {%- if "maxItems" in property -%} {{ restriction("Must contain a maximum of " ~ property.maxItems ~ " items", "max-items") }} {%- endif -%} {%- if "uniqueItems" in property and property.uniqueItems == True -%} {{ restriction("All items must be unique", "unique-items") }} {%- endif -%} {%- if "items" in property and property["items"] is mapping and property["items"] != {} -%}

Each item of this array must be:

{# Note that property["items"] is needed here because property.items is a function #} {{ content(index ~ "_items", property_name ~ " Items", property["items"], property_path) }}
{%- endif -%} {%- if "contains" in property and property["contains"] != {} -%}

At least one of the items must be:

{{ content(index ~ "_not", property_name, property["contains"], property_path) }}
{%- endif -%} {%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro subsection(expanded, index, parent, property_name, property, required_properties, property_path) -%} {# Resolve reference #} {%- set property, property_path = (property | resolve_ref(schema, property_path)) -%} {%- set suffix = property_name | escape_property_name_for_id -%} {%- if parent != "" -%} {%- set suffix = parent ~ "__" ~ suffix -%} {%- endif -%} {%- set is_required = property_name in required_properties -%}

{{ content(suffix, property_name, property, property_path) }}
{%- endmacro -%} {%- set title = schema.get("title") -%} {%- if title -%}{{ title }}{%- else -%}Schema Docs{%- endif -%} {%- if title -%}

{{ title }}

{%- endif -%} {%- set properties = schema.get("properties") -%} {%- if schema.get("type") == "object" and properties -%} {%- set description = schema.get("description") -%} {%- if description -%} {{ description | markdown }} {%- endif -%} {%- if expand_buttons -%}
{%- endif -%} {%- set required_properties = schema.get("required") or [] -%} {%- for property_name, property in properties.items() -%} {{ subsection(False, loop.index, "", property_name, property, required_properties, schema_path) }} {%- endfor -%} {% else %} {{ content(0, schema.get("title", "Main schema"), schema, schema_path) }} {%- endif -%}