{{/* 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 -}}
{{ partial "breadcrumbs.html" . }}

{{ .Title | safeHTML }}

{{ with .Description }}

{{ . }}

{{ 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 }}
{{ end }} {{/* ── Meta strip: version, base URL, download link ──────────────────────── */}} {{ define "api-ref-meta" }} {{- $api := .api -}} {{- $spec := .spec -}}
{{- with $api.info }} {{- with .version }}
Version {{ . }}
{{- end }} {{- end }} {{- range $api.servers }}
Base URL {{ .url }}
{{- end }} Download OpenAPI specification
{{ end }} {{/* ── Overview ─────────────────────────────────────────────────────────── */}} {{ define "api-ref-overview" }} {{- $api := . -}} {{- with $api.info }} {{- with .description }}
{{ . | markdownify }}
{{- end }} {{- end }} {{ end }} {{/* ── Authentication ───────────────────────────────────────────────────── */}} {{ define "api-ref-auth" }} {{- $api := . -}} {{- with $api.components }} {{- with .securitySchemes }}

Authentication

{{- range $name, $scheme := . }}
{{ $name }} {{- with $scheme.type }} type: {{ . }} {{- end }} {{- with $scheme.scheme }} scheme: {{ . }} {{- end }} {{- with $scheme.bearerFormat }} bearer format: {{ . }} {{- end }}
{{- with $scheme.description }}
{{ . | markdownify }}
{{- end }} {{- end }}
{{- end }} {{- end }} {{ end }} {{/* ── Endpoints grouped by tag ─────────────────────────────────────────── */}} {{ define "api-ref-tags" }} {{- $api := . -}} {{- $paths := $api.paths -}} {{- $methods := slice "get" "post" "put" "patch" "delete" -}} {{- range $api.tags }} {{- $tagName := .name -}}

{{ $tagName | title }}

{{- with .description }}

{{ . }}

{{- 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 }}
{{- end }} {{ end }} {{/* ── Single operation card ────────────────────────────────────────────── */}} {{ define "api-ref-operation" }} {{- $api := .api -}} {{- $op := .op -}} {{- $method := .method -}} {{- $path := .path -}} {{- $sharedParams := .sharedParams -}} {{- $methodColors := dict "get" "bg-blue-100 text-blue-800 dark:bg-blue-900/40 dark:text-blue-300" "post" "bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300" "put" "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300" "patch" "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300" "delete" "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300" -}} {{- $anchor := "" -}} {{- with $op.operationId -}} {{- $anchor = printf "operation-%s" . -}} {{- end -}} {{- $curl := partial "api-ref/curl.html" (dict "api" $api "op" $op "method" $method "path" $path "sharedParams" $sharedParams ) -}}
{{ upper $method }} {{ $path }}
{{- with $op.summary }} {{ . }} {{- end }}
{{- with $op.description }}
{{ . | markdownify }}
{{- end }} {{ template "api-ref-params" (dict "api" $api "op" $op "sharedParams" $sharedParams ) }} {{ template "api-ref-body" (dict "api" $api "op" $op) }} {{ template "api-ref-responses" (dict "api" $api "op" $op) }}
{{ end }} {{/* ── Parameters table (path + operation; in: path/query/header) ───────── */}} {{ define "api-ref-params" }} {{- $api := .api -}} {{- $op := .op -}} {{- $params := .sharedParams -}} {{- with index $op "parameters" -}} {{- range . -}} {{- $p := partial "api-ref/resolve.html" (dict "api" $api "node" .) -}} {{- $params = $params | append $p -}} {{- end -}} {{- end -}} {{- if $params }}

Parameters

{{- range $params }} {{- end }}
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 }}
{{- end }} {{ end }} {{/* ── Request body ─────────────────────────────────────────────────────── */}} {{ define "api-ref-body" }} {{- $api := .api -}} {{- $op := .op -}} {{- with $op.requestBody }} {{- $body := partial "api-ref/resolve.html" (dict "api" $api "node" .) }}

Request body

{{- with $body.description }}

{{ . | markdownify }}

{{- end }} {{- $ct := "" -}} {{- $media := dict -}} {{- range $name, $m := $body.content -}} {{- if not $ct -}}{{- $ct = $name -}}{{- $media = $m -}}{{- end -}} {{- end -}} {{- if $ct }}

Content type: {{ $ct }}

{{ template "api-ref-schema-link" (dict "api" $api "schema" $media.schema) }} {{ template "api-ref-examples" (dict "examples" $media.examples "prefix" "req" ) }} {{- end }}
{{- end }} {{ end }} {{/* ── Responses ────────────────────────────────────────────────────────── */}} {{ define "api-ref-responses" }} {{- $api := .api -}} {{- $op := .op -}} {{- $statusColors := dict "200" "bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300" "201" "bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300" "204" "bg-green-100 text-green-800 dark:bg-green-900/40 dark:text-green-300" "400" "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300" "401" "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300" "403" "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300" "404" "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300" "409" "bg-yellow-100 text-yellow-800 dark:bg-yellow-900/40 dark:text-yellow-300" "500" "bg-red-100 text-red-800 dark:bg-red-900/40 dark:text-red-300" -}} {{- with $op.responses }}

Responses

{{- range $code, $resp := . }} {{- $r := partial "api-ref/resolve.html" (dict "api" $api "node" $resp) }}
{{ $code }} {{ $r.description }} {{- $ct := "" -}} {{- $media := dict -}} {{- range $name, $m := $r.content -}} {{- if not $ct -}} {{- $ct = $name -}}{{- $media = $m -}} {{- end -}} {{- end -}} {{- if $ct }}
{{ template "api-ref-schema-link" (dict "api" $api "schema" $media.schema) }} {{ template "api-ref-examples" (dict "examples" $media.examples "prefix" (printf "resp-%s" $code) ) }}
{{- end }}
{{- end }}
{{- end }} {{ end }} {{/* ── Example block with optional tabs ─────────────────────────────────── */}} {{ define "api-ref-examples" }} {{- $examples := .examples -}} {{- $prefix := .prefix -}} {{- $tabs := slice -}} {{- range $name, $ex := $examples -}} {{- $tabs = $tabs | append (dict "name" $name "ex" $ex) -}} {{- end -}} {{- if $tabs }} {{- $first := (index $tabs 0).name -}}
{{- if gt (len $tabs) 1 }}
{{- range $tabs }} {{- $label := .name -}} {{- with .ex.summary }}{{ $label = . }}{{ end -}} {{- end }}
{{- end }} {{- range $tabs }}
{{- with .ex.value -}}
{{ highlight (. | jsonify (dict "indent" " ")) "json" "" }}
{{- end }}
{{- end }}
{{- end }} {{ end }} {{/* ── Inline schema-reference link (used in body/response) ─────────────── */}} {{ define "api-ref-schema-link" }} {{- $api := .api -}} {{- $schema := .schema -}} {{- if reflect.IsMap $schema -}} {{- with index $schema "$ref" -}} {{- $parts := split . "/" -}} {{- $name := index $parts (sub (len $parts) 1) -}}

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 }}

Schemas

{{- range $name, $schema := . }}

{{ $name }}

{{- with $schema.description }}
{{ . | markdownify }}
{{- end }} {{- with $schema.enum }}

Enum: {{- range $i, $v := . -}} {{- if $i }},{{ end -}} {{ $v }} {{- end -}}

{{- end }} {{- with $schema.properties }} {{ template "api-ref-properties" (dict "api" $api "schema" $schema ) }} {{- else }} {{- with $schema.items }}

Items: {{ template "api-ref-type" (dict "api" $api "schema" .) }}

{{- end }} {{- end }}
{{- end }}
{{- end }} {{- end }} {{ end }} {{/* ── Property table for a schema ──────────────────────────────────────── */}} {{ define "api-ref-properties" }} {{- $api := .api -}} {{- $schema := .schema -}} {{- $required := $schema.required | default slice -}} {{- range $propName, $prop := $schema.properties }} {{- 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 -}}
{{ end }}