mirror of https://github.com/docker/docs.git
109 lines
4.5 KiB
HTML
109 lines
4.5 KiB
HTML
{{ define "left" }}
|
|
{{ partial "sidebar.html" . }}
|
|
{{ end }}
|
|
|
|
{{ define "main" }}
|
|
{{ partial "breadcrumbs-legacy.html" . }}
|
|
<article class="prose max-w-none dark:prose-invert">
|
|
<h1>{{ .Title }}</h1>
|
|
{{ $openapi := index site.Data.api .Params.apidata }}
|
|
{{ printf "## %s version %s" $openapi.info.title $openapi.info.version | .RenderString }}
|
|
{{ .RenderString $openapi.info.description }}
|
|
{{ range $path, $pathKeys := $openapi.paths }}
|
|
{{ range $key, $properties := $pathKeys }}
|
|
{{ if in "get put patch post delete" $key }}
|
|
{{ if isset $properties "operationId" }}
|
|
{{ printf "### %s {#%s}" $properties.summary $properties.operationId | $.RenderString }}
|
|
{{ else }}
|
|
{{ printf "### %s {#%s}" $properties.summary (urlize $properties.summary) | $.RenderString }}
|
|
{{ end }}
|
|
{{ $badgeColors := (dict
|
|
"get" "bg-blue-light-500 dark:bg-blue-dark-300"
|
|
"head" "bg-gray-light-500 dark:bg-gray-dark-300"
|
|
"put" "bg-green-light-500 dark:bg-green-dark-300"
|
|
"post" "bg-violet-light-500 dark:bg-violet-dark-300"
|
|
"delete" "bg-red-light-500 dark:bg-red-dark-300"
|
|
"patch" "bg-amber-light-500 dark:bg-amber-dark-500"
|
|
)
|
|
}}
|
|
<span
|
|
class="p-2 text-white {{ index $badgeColors $key }} rounded uppercase"
|
|
>{{ $key }}</span
|
|
> <code>{{ $path }}</code>
|
|
{{ $curlExample := printf
|
|
`curl -X %s \
|
|
"%sapi%s"` ($key | upper) (index $openapi.servers 0).url $path
|
|
}}
|
|
{{ highlight $curlExample "console" }}
|
|
{{ $properties.description | $.RenderString (dict "display" "block") }}
|
|
{{ with $properties.parameters }}
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>{{ T "apiPropParam" }}</th>
|
|
<th>{{ T "apiPropType" }}</th>
|
|
<th>{{ T "apiPropValue" }}</th>
|
|
<th>{{ T "apiPropReq" }}</th>
|
|
<th>{{ T "apiPropDesc" }}</th>
|
|
</tr>
|
|
</thead>
|
|
{{ range . }}
|
|
{{ $paramData := . }}
|
|
{{ if (index . "$ref") }}
|
|
{{ $refName := index (last 1 (split (index . "$ref") "/")) 0 }}
|
|
{{ $paramData = index $openapi.components.parameters $refName }}
|
|
{{ end }}
|
|
<tr>
|
|
<td>{{ $paramData.name }}</td>
|
|
<td>{{ $paramData.in }}</td>
|
|
<td>
|
|
{{ if isset $paramData.schema "$ref" }}
|
|
{{ $refName := index (last 1 (split (index $paramData.schema "$ref") "/")) 0 }}
|
|
{{ range (index $openapi.components.schemas $refName).enum }}
|
|
<code>{{ . }}</code>
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ $paramData.schema.type }}
|
|
{{ end }}
|
|
</td>
|
|
<td>{{ $paramData.required }}</td>
|
|
<td>{{ $paramData.description | $.RenderString }}</td>
|
|
</tr>
|
|
{{ end }}
|
|
</table>
|
|
{{ end }}
|
|
{{ range $responseCode, $responseDetails := $properties.responses }}
|
|
{{ if isset $responseDetails "content" }}
|
|
{{ range $exampleName, $example := (index $responseDetails.content "application/json").examples }}
|
|
{{ if isset $example "schema" }}
|
|
{{ $refPath := index (index $example "schema") "$ref" }}
|
|
{{ range $index, $component := (split $refPath "/") }}
|
|
{{ if (index $openapi.components.examples $component) }}
|
|
<div>
|
|
<span
|
|
>{{ T "apiExampleResponseCode" }}:
|
|
{{ $responseCode }}</span
|
|
>
|
|
<pre><code>{{ (index $openapi.components.examples $component).value | jsonify (dict "indent" " ") }}</code></pre>
|
|
</div>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ else }}
|
|
{{ T "apiExampleResponse" }}:
|
|
<pre><code>
|
|
{{- $example.value | jsonify (dict "indent" " ") }}
|
|
</code></pre>
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
{{ end }}
|
|
</article>
|
|
{{ end }}
|
|
|
|
{{ define "right" }}
|
|
{{ partial "api-aside.html" . }}
|
|
{{ end }}
|