{{/* Wide-mode API reference layout. Reads the colocated *.yaml Page Resource, unmarshals it into a plain Hugo map with transform.Unmarshal, and renders the OpenAPI 3 spec inline using Docker docs styling. Overrides baseof's "main" block so the article spans the full available width; the built-in right-rail TOC is replaced with a custom endpoint navigator (partials/api-ref/nav.html) sticky-pinned to the viewport. $ref nodes are resolved on the fly through partials/api-ref/resolve.html; no oapi-codegen or third-party JS runtime is involved. */}} {{ define "main" }} {{- $specRes := .Resources.GetMatch "*.yaml" -}} {{- if not $specRes -}} {{- errorf "api-reference: no .yaml resource found alongside %s" .File.Path -}} {{- end -}} {{- $api := $specRes | transform.Unmarshal -}}
{{ . }}
{{ end }} {{ template "api-ref-meta" (dict "api" $api "spec" $specRes) }} {{ partialCached "md-dropdown.html" "-" "-" }} {{ template "api-ref-overview" $api }} {{ template "api-ref-auth" $api }} {{ template "api-ref-tags" $api }} {{ template "api-ref-schemas" $api }}{{ . }}
{{ .url }}
{{ $name }}
{{- with $scheme.type }}
type: {{ . }}
{{- end }}
{{- with $scheme.scheme }}
scheme: {{ . }}
{{- end }}
{{- with $scheme.bearerFormat }}
bearer format: {{ . }}
{{- end }}
{{ . }}
{{- end }} {{- range $path, $item := $paths }} {{/* Resolve shared (path-level) parameters once. */}} {{- $sharedParams := slice -}} {{- with index $item "parameters" -}} {{- range . -}} {{- $p := partial "api-ref/resolve.html" (dict "api" $api "node" .) -}} {{- $sharedParams = $sharedParams | append $p -}} {{- end -}} {{- end -}} {{- range $methods -}} {{- $method := . -}} {{- with index $item $method -}} {{- $op := . -}} {{- if in $op.tags $tagName -}} {{ template "api-ref-operation" (dict "api" $api "op" $op "method" $method "path" $path "sharedParams" $sharedParams ) }} {{- end -}} {{- end -}} {{- end -}} {{- end }}{{ $path }}
| Name | In | Type | Required | Description |
|---|---|---|---|---|
{{ .name }}
|
{{ .in }} | {{ template "api-ref-type" (dict "api" $api "schema" .schema) }} | {{ if .required }}yes{{ else }}no{{ end }} | {{ with .description }}{{ . | markdownify }}{{ end }} |
{{ . | markdownify }}
{{- end }} {{- $ct := "" -}} {{- $media := dict -}} {{- range $name, $m := $body.content -}} {{- if not $ct -}}{{- $ct = $name -}}{{- $media = $m -}}{{- end -}} {{- end -}} {{- if $ct }}
Content type:
{{ $ct }}
Schema: {{ $name }}
{{- end -}} {{- end -}} {{ end }} {{/* ── Type rendering for parameter / property tables ───────────────────── */}} {{ define "api-ref-type" }} {{- $api := .api -}} {{- $schema := .schema -}} {{- if not (reflect.IsMap $schema) -}} — {{- else -}} {{- with index $schema "$ref" -}} {{- $parts := split . "/" -}} {{- $name := index $parts (sub (len $parts) 1) -}} {{ $name }} {{- else -}} {{- with $schema.type -}} {{- if eq . "array" -}} array<{{ template "api-ref-type" (dict "api" $api "schema" $schema.items) }}> {{- else -}} {{ . }} {{- end -}} {{- else -}} {{- if $schema.allOf -}} object {{- else if $schema.anyOf -}} any {{- else if $schema.oneOf -}} any {{- else -}} — {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{ end }} {{/* ── Schemas section ──────────────────────────────────────────────────── */}} {{ define "api-ref-schemas" }} {{- $api := . -}} {{- with $api.components -}} {{- with .schemas }}
Enum:
{{- range $i, $v := . -}}
{{- if $i }},{{ end -}}
{{ $v }}
{{- end -}}
Items: {{ template "api-ref-type" (dict "api" $api "schema" .) }}
{{- end }} {{- end }}| Property | Type | Required | Description |
|---|---|---|---|
{{ $propName }}
|
{{ template "api-ref-type" (dict "api" $api "schema" $prop) }} | {{ if in $required $propName }}yes{{ else }}no{{ end }} | {{- $resolved := partial "api-ref/resolve.html" (dict "api" $api "node" $prop) -}} {{- with $resolved.description -}} {{ . | markdownify }} {{- end -}} |