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

Fixes: #1774
Signed-off-by: Johannes Marbach <n0-0ne+github@mailbox.org>
This commit is contained in:
Johannes Marbach 2024-06-18 15:20:12 +02:00
parent 5f47b96240
commit eeca7afc3c
4 changed files with 20 additions and 4 deletions

View file

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

View file

@ -4,13 +4,16 @@
two arrays with equal length:
* `content_types`: the content type strings
* `descriptions`: the description strings
* `added_in`: the "added in" version
* `changed_in`: the "changed in" dictionary
*/}}
{{ $content_types := .content_types }}
{{ $descriptions := .descriptions}}
{{ $added_in := .added_in}}
{{ $changed_in := .changed_in}}
{{ if (gt (len $content_types) 0) }}
@ -22,7 +25,11 @@
{{ range $idx, $content_type := $content_types }}
<tr>
<td><code>{{ $content_type }}</code></td>
<td>{{ index $descriptions $idx | markdownify -}}</td>
<td>
{{ index $descriptions $idx | markdownify -}}
{{ if (index $added_in $idx) }}{{ partial "added-in" (dict "v" (index $added_in $idx)) }}{{ end -}}
{{ if (index $changed_in $idx) }}{{ partial "changed-in" (dict "changes_dict" (index $changed_in $idx)) }}{{ end -}}
</td>
</tr>
{{ end }}
</table>

View file

@ -52,11 +52,15 @@
*/}}
{{ $mimes := slice }}
{{ $descriptions := slice }}
{{ $added_in := slice }}
{{ $changed_in := slice }}
{{ range $mime, $body := $request_body.content }}
{{ $mimes = $mimes | append $mime }}
{{ $descriptions = $descriptions | append $request_body.description }}
{{ $added_in = $added_in | append (index $request_body "x-addedInMatrixVersion") }}
{{ $changed_in = $changed_in | append (index $request_body "x-changedInMatrixVersion") }}
{{ end }}
{{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions) }}
{{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions "added_in" $added_in "changed_in" $changed_in) }}
{{ end }}
<h3>Request body example</h3>

View file

@ -123,11 +123,15 @@
*/}}
{{ $mimes := slice }}
{{ $descriptions := slice }}
{{ $added_in := slice }}
{{ $changed_in := slice }}
{{ range $mime, $body := $response.content }}
{{ $mimes = $mimes | append $mime }}
{{ $descriptions = $descriptions | append $body.schema.description }}
{{ $added_in = $added_in | append (index $body.schema "x-addedInMatrixVersion") }}
{{ $changed_in = $changed_in | append (index $body.schema "x-changedInMatrixVersion") }}
{{ end }}
{{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions) }}
{{ partial "openapi/render-content-type" (dict "content_types" $mimes "descriptions" $descriptions "added_in" $added_in "changed_in" $changed_in) }}
{{ end }}
{{ end }}
{{ end }}