{{ $s := .schema }}{{ $api := .api }}{{ $depth := .depth }} {{ if reflect.IsMap $s }} {{ with index $s "$ref" }} {{ $url := index $api.schemaURLs . }}

Schema: {{ if $url }} {{ strings.TrimPrefix "#/components/schemas/" . }} {{ else }} {{ . }} {{ end }}

{{ end }} {{ with $s.type }}

Type: {{ if reflect.IsSlice . }} {{ delimit . " | " }} {{ else }} {{ . }} {{ end }}

{{ end }} {{ with $s.description }}
{{ . | markdownify }}
{{ end }} {{ if lt $depth 3 }} {{ range $name,$v := $s.properties }}
{{ $name }}{{ if in $s.required $name }} · required {{ end }}{{ if $v.readOnly }} · response only {{ end }}{{ if $v.writeOnly }}· request only{{ end }} {{ partial "api-reference/schema.html" (dict "schema" $v "api" $api "depth" (add $depth 1)) }}
{{ end }} {{ range $keyword := slice "allOf" "oneOf" "anyOf" }} {{ with index $s $keyword }}
{{ if eq $keyword "allOf" }} All constraints apply {{ else if eq $keyword "oneOf" }} Exactly one alternative must match {{ else }} One or more alternatives must match {{ end }} {{ range . }} {{ partial "api-reference/schema.html" (dict "schema" . "api" $api "depth" (add $depth 1)) }} {{ end }}
{{ end }} {{ end }} {{ if isset $s "items" }}
Array item {{ partial "api-reference/schema.html" (dict "schema" $s.items "api" $api "depth" (add $depth 1)) }}
{{ end }} {{ end }} {{ if or (ge $depth 3) (not (index $s "$ref")) (gt (len $s) 1) }}
All schema constraints and annotations
{{ $s | jsonify (dict "indent" "  ") }}
{{ end }} {{ else }}

{{ if eq $s false }} No value satisfies this schema. {{ else if eq $s true }} Any value satisfies this schema. {{ else }} No schema is declared. {{ end }}

{{ end }}