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

View file

@ -52,11 +52,15 @@
*/}} */}}
{{ $mimes := slice }} {{ $mimes := slice }}
{{ $descriptions := slice }} {{ $descriptions := slice }}
{{ $added_in := slice }}
{{ $changed_in := 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 }} {{ $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 }} {{ 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 }}
<h3>Request body example</h3> <h3>Request body example</h3>

View file

@ -123,11 +123,15 @@
*/}} */}}
{{ $mimes := slice }} {{ $mimes := slice }}
{{ $descriptions := slice }} {{ $descriptions := slice }}
{{ $added_in := slice }}
{{ $changed_in := slice }}
{{ range $mime, $body := $response.content }} {{ range $mime, $body := $response.content }}
{{ $mimes = $mimes | append $mime }} {{ $mimes = $mimes | append $mime }}
{{ $descriptions = $descriptions | append $body.schema.description }} {{ $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 }} {{ 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 }} {{ end }}
{{ end }} {{ end }}