Break out non-JSON request/response content types as tables (#1756)

* Break out non-JSON request/response content types as tables

Currently we display this as a table like "image/png|image/jpeg" and description on a single line, but we're using a table. This breaks the join out to individual rows.

* changelog
release/v1.10
Travis Ralston 8 months ago committed by GitHub
parent 6700f5ddd1
commit eb22fac5dc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1 @@
Clearly indicate that each `Content-Type` may have distinct behaviour on non-JSON requests/responses.

@ -1,27 +1,30 @@
{{/* {{/*
Render a table showing content type and description, given: Render a table showing content types and their descriptions, given
two arrays with equal length:
* `content_type`: the content type as a string * `content_types`: the content type strings
* `description`: the description as a string * `descriptions`: the description strings
*/}} */}}
{{ $content_type := .content_type }} {{ $content_types := .content_types }}
{{ $description := .description}} {{ $descriptions := .descriptions}}
{{ if $content_type }} {{ if (gt (len $content_types) 0) }}
<table class="content-type-table"> <table class="content-type-table">
<thead> <thead>
<th class="col-name">Content-Type</th> <th class="col-name">Content-Type</th>
<th class="col-description">Description</th> <th class="col-description">Description</th>
</thead> </thead>
{{ range $idx, $content_type := $content_types }}
<tr> <tr>
<td><code>{{ $content_type }}</code></td> <td><code>{{ $content_type }}</code></td>
<td>{{ $description | markdownify -}}</td> <td>{{ index $descriptions $idx | markdownify -}}</td>
</tr> </tr>
{{ end }}
</table> </table>
{{ end }} {{ end }}

@ -54,11 +54,12 @@
Show the content types and description. Show the content types and description.
*/}} */}}
{{ $mimes := slice }} {{ $mimes := slice }}
{{ $descriptions := slice }}
{{ range $mime, $body := $request_body.content }} {{ range $mime, $body := $request_body.content }}
{{ $mimes = $mimes | append $mime }} {{ $mimes = $mimes | append $mime }}
{{ $descriptions = $descriptions | append $request_body.description }}
{{ end }} {{ end }}
{{ $content_type := delimit $mimes "|"}} {{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions) }}
{{ partial "openapi/render-content-type" (dict "content_type" $content_type "description" $request_body.description) }}
{{ end }} {{ end }}
<h3>Request body example</h3> <h3>Request body example</h3>

@ -109,13 +109,12 @@
Show the content types and description. Show the content types and description.
*/}} */}}
{{ $mimes := slice }} {{ $mimes := slice }}
{{ $desc := "" }} {{ $descriptions := slice }}
{{ range $mime, $body := $response.content }} {{ range $mime, $body := $response.content }}
{{ $mimes = $mimes | append $mime }} {{ $mimes = $mimes | append $mime }}
{{ $desc = $body.schema.description }} {{ $descriptions = $descriptions | append $body.schema.description }}
{{ end }} {{ end }}
{{ $content_type := delimit $mimes "|"}} {{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions) }}
{{ partial "openapi/render-content-type" (dict "content_type" $content_type "description" $desc) }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}

Loading…
Cancel
Save