Render added/changed in info on request and response content types (#1876)

* Render added/changed in info on request and response content types

Fixes: #1774
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
Co-authored-by: Kévin Commaille <76261501+zecakeh@users.noreply.github.com>
pull/1881/head
Johannes Marbach 5 months ago committed by GitHub
parent 5fbfdd6821
commit 27e71fff10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1 @@
Render added/changed in info on request and response content types.

@ -715,8 +715,9 @@ components:
bytes: bytes:
content: content:
application/octet-stream: application/octet-stream:
example: <bytes> schema:
description: The content to be uploaded. description: The content to be uploaded.
example: <bytes>
required: true required: true
responses: responses:
uploadTooLarge: uploadTooLarge:

@ -1,16 +1,12 @@
{{/* {{/*
Render a table showing content types and their descriptions, given Render a table showing content types and their descriptions, given:
two arrays with equal length:
* `content_types`: the content type strings * `content_types`: OpenAPI data specifying the content types as a dictionary of the form {string: {"schema": JsonSchema}}
* `descriptions`: the description strings
*/}} */}}
{{ $content_types := .content_types }} {{ $content_types := .content_types }}
{{ $descriptions := .descriptions}}
{{ if (gt (len $content_types) 0) }} {{ if (gt (len $content_types) 0) }}
@ -21,10 +17,14 @@
<th class="col-description">Description</th> <th class="col-description">Description</th>
</tr> </tr>
</thead> </thead>
{{ range $idx, $content_type := $content_types }} {{ range $mime, $body := $content_types }}
<tr> <tr>
<td><code>{{ $content_type }}</code></td> <td><code>{{ $mime }}</code></td>
<td>{{ index $descriptions $idx | markdownify -}}</td> <td>
{{ $body.schema.description | markdownify -}}
{{ if (index $body.schema "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $body.schema "x-addedInMatrixVersion")) }}{{ end -}}
{{ if (index $body.schema "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $body.schema "x-changedInMatrixVersion")) }}{{ end -}}
</td>
</tr> </tr>
{{ end }} {{ end }}
</table> </table>

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

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

Loading…
Cancel
Save