{%- macro restriction(inner_text, css_class_name, current_path, schema_path, span_id) -%} {%- set current_path = current_path ~ "/number" -%} {%- set _none = current_path | record_path_id(schema_path, span_id) -%} {%- set span_id = span_id -%}

{{ inner_text }}

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

{%- set tab_label = "Option" -%} {%- if operator == "allOf" -%} {%- set tab_label = "Requirement" -%} {%- endif -%}
{%- for element in property[operator] -%} {%- set tab_id = current_id ~ "__option" ~ loop.index -%}
{%- set current_path = current_path ~ "/" ~ loop.index0 -%} {{ content(tab_id, tab_label ~ " " ~ loop.index, element, property_path, current_path, True) }}
{%- endfor -%}
{%- endmacro -%} {%- macro add_description(property) -%} {%- set description = property.get("description") | get_description -%} {# Display description #} {%- if description -%} {%- if description is description_short -%} {{ description | markdown }} {%- else -%}
{{ description | markdown }}
{%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro content(current_id, property_name, property, property_path, current_path, named_property) -%} {%- set property, property_path, current_path, recursive_id = (property | resolve_ref(schema, property_path, current_path, link_to_reused_ref)) -%} {%- if recursive_id -%} {# There can be a description next to $ref, so let's display it #} {{ add_description(property) }} {%- if recursive_id != current_path -%} Same definition as {{ recursive_id }} {%- else -%}

Recursive definition, see #/{{ recursive_id }}

{%- endif -%} {%- else -%} {# Handle having oneOf or allOf with only one condition #} {%- if "allOf" in property and (property["allOf"] | length) == 1 -%} {%- set current_path = current_path ~ "/allOf/0" -%} {{ add_description(property) }} {{ content(current_id, property_name, property["allOf"][0], property_path, current_path, True) }} {%- elif "anyOf" in property and (property["anyOf"] | length) == 1 -%} {%- set current_path = current_path ~ "/anyOf/0" -%} {{ add_description(property) }} {{ content(current_id, property_name, property["anyOf"][0], property_path, current_path, True) }} {%- 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 -%} {{ add_description(property) }} {# Handle actual requirement #} {%- if "allOf" in property -%} {%- set current_path = current_path ~ "/allOf" -%} {%- set tab_section_id = current_id ~ "_allOf" -%} {%- set _none = current_path | record_path_id(property_path, tab_section_id) -%}
{{ tabbed_section("allOf", property, property_path, current_id) }}
{%- endif -%} {%- if "anyOf" in property -%} {%- set current_path = current_path ~ "/anyOf" -%} {%- set tab_section_id = current_id ~ "_anyOf" -%} {%- set _none = current_path | record_path_id(property_path, tab_section_id) -%}
{{ tabbed_section("anyOf", property, property_path, current_id) }}
{%- endif -%} {%- if "oneOf" in property -%} {%- set current_path = current_path ~ "/oneOf" -%} {%- set tab_section_id = current_id ~ "_oneOf" -%} {%- set _none = current_path | record_path_id(property_path, tab_section_id) -%}
{{ tabbed_section("oneOf", property, property_path, current_id) }}
{%- endif -%} {%- if "not" in property -%}

Must not be:

{%- set current_path = current_path ~ "/not" -%} {%- set card_id = current_id ~ "_not" -%} {%- set _none = current_path | record_path_id(property_path, card_id) -%}
{{ content(card_id, property_name, property["not"], property_path, current_path, True) }}
{%- endif -%} {%- if "enum" in property -%} {%- set current_path = current_path ~ "/enum" -%} {%- set enum_id = current_id ~ "_enum" -%} {%- set _none = current_path | record_path_id(property_path, enum_id) -%}

Must be one of:

{%- endif -%} {%- if "const" in property -%} {%- set current_path = current_path ~ "/const" -%} {%- set const_id = current_id ~ "_const" -%} {%- set _none = current_path | record_path_id(property_path, const_id) -%} Specific value: {{ property.const | python_to_json }} {%- endif -%} {%- if "pattern" in property -%} {%- set current_path = current_path ~ "/pattern" -%} {%- set pattern_id = current_id ~ "_pattern" -%} {%- set _none = current_path | record_path_id(property_path, pattern_id) -%} Must match regular expression: {{ property.pattern | escape }} {%- endif -%} {%- if not named_property -%} Property name must match regular expression: {{ property_name | escape }} {%- endif -%} {%- if "if" in property and "then" in property -%} {%- set has_else = "else" in property -%}

If the conditions in the "If" tab are respected, then the conditions in the "Then" tab should be respected. Otherwise, the conditions in the "Else" tab should be respected.

{%- set tab_id = current_id ~ "__if" -%}
{%- set current_path = current_path ~ "/if" -%} {{ content(tab_id, tab_label ~ " if", property["if"], property_path, current_path, True) }}
{%- set tab_id = current_id ~ "__then" -%}
{%- set current_path = current_path ~ "/then" -%} {{ content(tab_id, tab_label ~ " then", property["then"], property_path, current_path, True) }}
{%- if has_else -%} {%- set tab_id = current_id ~ "__else" -%}
{%- set current_path = current_path ~ "/else" -%} {{ content(tab_id, tab_label ~ " else", property["else"], property_path, current_path, True) }}
{%- endif -%}
{%- endif -%} {%- set undocumented_required_properties = property | get_undocumented_required_properties -%} {%- if undocumented_required_properties-%}

The following properties are required:

{%- endif -%} {# Handle type #} {%- if type == "string" -%} {%- if "minLength" in property -%} {{ restriction("Must be at least " ~ property.minLength ~ " characters long", "min-length", current_path, property_path, current_id ~ "_minLength") }} {%- endif -%} {%- if "maxLength" in property -%} {{ restriction("Must be at most " ~ property.maxLength ~ " characters long", "max-length", current_path, property_path, current_id ~ "_maxLength") }} {%- 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", current_path, property_path, current_id ~ "_number") }} {%- endif -%} {%- endif -%} {%- if type.startswith("array") -%} {%- set current_path = current_path ~ "/array" -%} {%- set array_id = current_id ~ "_array" -%} {%- set _none = current_path | record_path_id(property_path, array_id) -%} {%- if "minItems" in property -%} {{ restriction("Must contain a minimum of " ~ property.minItems ~ " items", "min-items", current_path, property_path, current_id ~ "_minItems") }} {%- endif -%} {%- if "maxItems" in property -%} {{ restriction("Must contain a maximum of " ~ property.maxItems ~ " items", "max-items", current_path, property_path, current_id ~ "_maxItems") }} {%- endif -%} {%- if "uniqueItems" in property and property.uniqueItems == True -%} {{ restriction("All items must be unique", "unique-items", current_path, property_path, current_id ~ "_uniqueItems") }} {%- endif -%} {%- if "items" in property and property["items"] is mapping and property["items"] != {} -%}

Each item of this array must be:

{%- set current_path = current_path ~ "/items" -%} {%- set card_id = array_id ~ "_items" -%} {%- set _none = current_path | record_path_id(property_path, card_id) -%}
{# Note that property["items"] is needed here because property.items is a function #} {{ content(card_id, property_name ~ " Items", property["items"], property_path, current_path, True) }}
{%- endif -%} {%- if "contains" in property and property["contains"] != {} -%} {%- set current_path = current_path ~ "/contains" -%} {%- set card_id = array_id ~ "_contains" -%} {%- set _none = current_path | record_path_id(property_path, card_id) -%}

At least one of the items must be:

{%- set current_path = current_path ~ "/contains" -%} {{ content(current_id ~ "_not", property_name, property["contains"], property_path, current_path, True) }}
{%- endif -%} {%- endif -%} {%- set examples = (property.get("examples") or []) -%} {# Display examples #} {%- if examples -%}
Example{% if examples|length > 1 %}s{% endif %}:

{%- for example in examples -%} {%- set example_id = current_id ~ "_ex" ~ loop.index -%} {%- set example_is_long = example is not description_short -%} {%- if example_is_long -%} {%- endif -%}
{{ example | to_pretty_json }}
{%- endfor -%} {%- endif -%} {%- if "properties" in property -%} {%- set required_properties = property.get("required") or [] -%} {%- set current_path = current_path ~ "/properties" -%} {%- for sub_property_name, sub_property in property["properties"].items() -%} {%- set current_path_property = current_path ~ "/" ~ sub_property_name -%} {{ subsection(False, loop.index, current_id, sub_property_name, sub_property, required_properties, property_path, current_path_property, True) }} {%- endfor -%} {%- endif -%} {%- if "patternProperties" in property -%} {%- set current_path = current_path ~ "/patternProperties" -%} {%- for sub_property_name, sub_property in property["patternProperties"].items() -%} {%- set current_path_property = current_path ~ "/" ~ sub_property_name -%} {{ subsection(False, loop.index, current_id, sub_property_name, sub_property, [], property_path, current_path_property, False) }} {%- endfor -%} {%- endif -%} {%- endif -%} {%- endif -%} {%- endmacro -%} {%- macro subsection(expanded, current_id, parent, property_name, property, required_properties, property_path, current_path, named_property) -%} {# Resolve reference #} {%- set property, property_path, current_path, is_recursive = (property | resolve_ref(schema, property_path, current_path, link_to_reused_ref)) -%} {%- set suffix = property_name -%} {%- if parent != "" -%} {%- set suffix = parent ~ "__" ~ suffix -%} {%- endif -%} {%- if named_property -%} {%- set suffix = suffix | escape_property_name_for_id -%} {%- else -%} {%- set suffix = parent | generate_id_for_pattern_property(current_id) -%} {%- if "title" in property -%} {%- set property_title = property['title'] -%} {%- else -%} {%- set property_title = property_name -%} {%- endif -%} {%- endif -%} {%- set is_required = property_name in required_properties -%}

{%- set _none = current_path | record_path_id(property_path, suffix) -%}

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

{{ title }}

{%- endif -%} {%- set properties = schema.get("properties") -%} {%- set patternProperties = schema.get("patternProperties") -%} {%- set current_path = "" -%} {%- if expand_buttons -%}
{%- endif -%} {{ content("", schema.get("title", "Main schema"), schema, schema_path, current_path, True) }}