{{/* Render the request part of a single HTTP API operation, given: * `parameters`: OpenAPI/Swagger data specifying the parameters * `path`: the path where this definition was found, to enable us to resolve "$ref" This template renders: * the "simple parameters" (header, path, query parameters) * body parameters, which may be more complex, containing nested objects * response body examples */}} {{ $parameters := .parameters }} {{ $path := .path }}

Request

{{ if $parameters }} {{ $simple_parameters := where $parameters "in" "!=" "body"}} {{ if $simple_parameters }}

Request parameters

{{ partial "openapi/render-parameters" (dict "parameters" $simple_parameters "type" "header" "caption" "header parameters") }} {{ partial "openapi/render-parameters" (dict "parameters" $simple_parameters "type" "path" "caption" "path parameters") }} {{ partial "openapi/render-parameters" (dict "parameters" $simple_parameters "type" "query" "caption" "query parameters") }} {{ end }} {{ $body_parameters := where $parameters "in" "body"}} {{ if $body_parameters }}

Request body

{{/* at most one body param is allowed by the spec */}} {{ $body_parameter := index $body_parameters 0 }} {{ $schema := partial "json-schema/resolve-refs" (dict "schema" $body_parameter.schema "path" $path) }} {{ $schema := partial "json-schema/resolve-allof" $schema }} {{ $additional_types := partial "json-schema/resolve-additional-types" $schema }} {{ $additional_types = uniq $additional_types }} {{ range $additional_types }} {{ partial "openapi/render-object-table" (dict "caption" .title "properties" .properties "required" .required) }} {{ end }}

Request body example

{{ $example := partial "json-schema/resolve-example" $schema }} {{ if $example }} {{ $example_json := jsonify (dict "indent" " ") $example }} {{ $example_json = replace $example_json "\\u003c" "<" }} {{ $example_json = replace $example_json "\\u003e" ">" | safeHTML }} ```json {{ $example_json }} ``` {{ else }} {{ partial "alert" (dict "type" "warning" "omit_title" "true" "color" "warning" "content" "Specification error: Example invalid or not present") }} {{ end }} {{ end }} {{ else }}

No request parameters or request body.

{{ end }}