{{/* Hugo-Native Responses Renderer Renders the responses section for an API operation. Shows status codes, descriptions, and response schemas. Params: - responses: Map of status codes to response objects - spec: The full OpenAPI spec object for resolving $ref */}} {{ $responses := .responses }} {{ $spec := .spec }}

Responses

{{ range $statusCode, $response := $responses }} {{/* Resolve $ref if present */}} {{ $resolvedResponse := $response }} {{ if isset $response "$ref" }} {{ $refPath := index $response "$ref" }} {{ $refParts := split $refPath "/" }} {{ if ge (len $refParts) 4 }} {{ $responseName := index $refParts 3 }} {{ with index $spec.components.responses $responseName }} {{ $resolvedResponse = . }} {{ end }} {{ end }} {{ end }} {{ $description := $resolvedResponse.description | default "" }} {{ $content := $resolvedResponse.content | default dict }} {{/* Determine status category for styling */}} {{ $statusCategory := "info" }} {{ if hasPrefix $statusCode "2" }} {{ $statusCategory = "success" }} {{ else if hasPrefix $statusCode "3" }} {{ $statusCategory = "redirect" }} {{ else if hasPrefix $statusCode "4" }} {{ $statusCategory = "client-error" }} {{ else if hasPrefix $statusCode "5" }} {{ $statusCategory = "server-error" }} {{ end }}
{{ $statusCode }} {{ $description }}
{{/* Response body schema if present */}} {{ with $content }} {{ $jsonContent := index . "application/json" | default dict }} {{ with $jsonContent.schema }} {{/* Resolve schema $ref if present */}} {{ $resolvedSchema := . }} {{ if isset . "$ref" }} {{ $refPath := index . "$ref" }} {{ $refParts := split $refPath "/" }} {{ if ge (len $refParts) 4 }} {{ $schemaName := index $refParts 3 }} {{ with index $spec.components.schemas $schemaName }} {{ $resolvedSchema = . }} {{ end }} {{ end }} {{ end }}
{{ partial "api/schema.html" (dict "schema" $resolvedSchema "spec" $spec "level" 0) }}
{{ end }} {{ end }}
{{ end }}