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

{{ inner_text }}

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

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

Must not be:

{{ content(index ~ "_not", property_name, property["not"]) }}
{%- 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"]) }}
{%- endif -%} {%- if "contains" in property and property["contains"] != {} -%}

At least one of the items must be:

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

{{ content(index, property_name, property) }}
{%- endmacro -%} Schema Docs {%- set properties = schema.get("properties") -%} {%- if properties -%} {%- set required_properties = schema.get("required") or [] -%} {%- for property_name, property in properties.items() -%} {{ subsection(False, loop.index, property_name, property) }} {%- endfor -%} {%- endif -%}