{{/* Renders an inline summary of an OpenAPI schema. Args: dict "schema" $schema "spec" $spec */}} {{- $schema := .schema -}} {{- $spec := .spec -}} {{- /* Resolve $ref */ -}} {{- $ref := index $schema "$ref" -}} {{- if $ref -}} {{- $name := replace $ref "#/components/schemas/" "" -}} {{- $schema = index $spec.components.schemas $name -}}

Schema: {{ $name }}

{{- end -}} {{- if eq $schema.type "array" -}}

Array of:

{{- $items := $schema.items -}} {{- $itemsRef := index $items "$ref" -}} {{- if $itemsRef -}} {{- $name := replace $itemsRef "#/components/schemas/" "" -}} {{- $items = index $spec.components.schemas $name -}}

{{ $name }}

{{- end -}} {{- $schema = $items -}} {{- end -}} {{- if $schema.properties -}}
{{- $required := default (slice) $schema.required -}} {{- range $name, $prop := sort $schema.properties -}} {{- $propRef := index $prop "$ref" -}} {{- end -}}
Field Type Notes
{{ $name }}{{ if in $required $name }}*{{ end }} {{- if $propRef -}} {{ replace $propRef "#/components/schemas/" "" }} {{- else if eq $prop.type "array" -}} {{- $itemsRef := index $prop.items "$ref" -}} {{- if $itemsRef -}} {{ replace $itemsRef "#/components/schemas/" "" }}[] {{- else -}} {{ default "any" $prop.items.type }}[] {{- end -}} {{- else -}} {{ default "any" $prop.type }}{{ with $prop.format }} ({{ . }}){{ end }} {{- end -}} {{- if $prop.nullable }} | null{{ end -}} {{- with $prop.description }}{{ . }}{{ end -}} {{- if $prop.readOnly }}read-only{{ end -}} {{- if $prop.writeOnly }}write-only{{ end -}} {{- with $prop.enum }}
{{- range . -}}{{ . }}{{- end -}}
{{- end -}}
{{- else if $schema.enum -}}
{{- range $schema.enum -}}{{ . }}{{- end -}}
{{- else -}}

{{ default "any" $schema.type }}

{{- end -}}