{{ define "main" }} {{- $spec := site.Data.openapi -}} {{- $methods := slice "get" "post" "put" "patch" "delete" -}} {{- /* Build sorted list of unique tags */ -}} {{- $allTags := slice -}} {{- range $path, $ops := sort $spec.paths -}} {{- range $method := $methods -}} {{- with index $ops $method -}} {{- $op := . -}} {{- with $op.tags -}} {{- range . -}}{{- $allTags = $allTags | append . -}}{{- end -}} {{- else -}} {{- $allTags = $allTags | append "default" -}} {{- end -}} {{- end -}} {{- end -}} {{- end -}} {{- $tags := $allTags | uniq | sort -}}

API Reference

{{ $spec.info.title }} v{{ $spec.info.version }} — manage assets, device settings, backups, and integrations over HTTP.

{{- range $tags -}} {{ . }} {{- end -}}
{{- range $tag := $tags -}}

{{ replace $tag "_" " " }}

{{- range $path, $ops := sort $spec.paths -}} {{- range $method := $methods -}} {{- with index $ops $method -}} {{- $op := . -}} {{- $opTags := default (slice "default") $op.tags -}} {{- if in $opTags $tag -}}
{{- $methodColors := dict "get" "bg-blue-100 text-blue-800" "post" "bg-green-100 text-green-800" "put" "bg-amber-100 text-amber-800" "patch" "bg-orange-100 text-orange-800" "delete" "bg-red-100 text-red-800" -}} {{ $method }} {{ $path }} {{- with $op.summary -}} {{- end -}}
{{- with $op.description -}}

{{ . }}

{{- end -}} {{- with $op.parameters -}}

Parameters

{{- range . -}} {{- end -}}
Name In Type Required
{{ .name }} {{ .in }} {{ default "string" .schema.type }} {{ if .required }}yes{{ else }}no{{ end }}
{{- end -}} {{- with $op.requestBody -}} {{- /* Pick the best content type to render. JSON first; otherwise fall back to the first one in the spec (e.g. multipart/form-data for upload endpoints). */ -}} {{- $body := index .content "application/json" -}} {{- $contentType := "application/json" -}} {{- if not $body -}} {{- $content := .content -}} {{- range $ct, $entry := sort $content -}} {{- if not $body -}}{{- $body = $entry -}}{{- $contentType = $ct -}}{{- end -}} {{- end -}} {{- end -}}

Request body {{ $contentType }}

{{ partial "api-schema.html" (dict "schema" $body.schema "spec" $spec) }}
{{- end -}} {{- with $op.responses -}} {{- $responses := . -}}

Responses

{{- range $status, $resp := sort $responses -}}
{{- $statusColor := "bg-zinc-100 text-zinc-700" -}} {{- if hasPrefix $status "2" }}{{ $statusColor = "bg-green-100 text-green-800" }}{{ end -}} {{- if hasPrefix $status "4" }}{{ $statusColor = "bg-amber-100 text-amber-800" }}{{ end -}} {{- if hasPrefix $status "5" }}{{ $statusColor = "bg-red-100 text-red-800" }}{{ end -}} {{ $status }} {{ default "" $resp.description }} {{- with $resp.content -}} {{- with index . "application/json" -}}
{{ partial "api-schema.html" (dict "schema" .schema "spec" $spec) }}
{{- end -}} {{- end -}}
{{- end -}}
{{- end -}}
{{- end -}} {{- end -}} {{- end -}} {{- end -}}
{{- end -}}
{{ end }}