{%- 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, index, current_path) -%}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(index, 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(index, 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 = index ~ "_allOf" -%} {%- set _none = current_path | record_path_id(property_path, tab_section_id) -%}{{ property.const | python_to_json }}
{%- endif -%}
{%- if "pattern" in property -%}
{%- set current_path = current_path ~ "/pattern" -%}
{%- set pattern_id = index ~ "_pattern" -%}
{%- set _none = current_path | record_path_id(property_path, pattern_id) -%}
Must match regular expression: {{ property.pattern }}
{%- endif -%}
{%- if not named_property -%}
Property name must match regular expression: {{ property_name }}
{%- endif -%}
{%- if type == "string" -%}
{%- if "minLength" in property -%}
{{ restriction("Must be at least " ~ property.minLength ~ "
characters long", "min-length", current_path, property_path, index ~ "_minLength") }}
{%- endif -%}
{%- if "maxLength" in property -%}
{{ restriction("Must be at most " ~ property.maxLength ~ "
characters long", "max-length", current_path, property_path, index ~ "_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, index ~ "_number") }}
{%- endif -%}
{%- endif -%}
{%- if type.startswith("array") -%}
{%- set current_path = current_path ~ "/array" -%}
{%- set array_id = index ~ "_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, index ~ "_minItems") }}
{%- endif -%}
{%- if "maxItems" in property -%}
{{ restriction("Must contain a maximum of " ~ property.maxItems ~ "
items", "max-items", current_path, property_path, index ~ "maxItems") }}
{%- endif -%}
{%- if "uniqueItems" in property and property.uniqueItems == True -%}
{{ restriction("All items must be unique", "unique-items", current_path, property_path, index ~ "uniqueItems") }}
{%- endif -%}
{%- if "items" in property and property["items"] is mapping and property["items"] != {} -%}
{{ example | to_pretty_json }}