diff --git a/changelogs/internal/newsfragments/1876.clarification b/changelogs/internal/newsfragments/1876.clarification new file mode 100644 index 000000000..9f8409140 --- /dev/null +++ b/changelogs/internal/newsfragments/1876.clarification @@ -0,0 +1 @@ +Render added/changed in info on request and response content types. diff --git a/layouts/partials/openapi/render-content-type.html b/layouts/partials/openapi/render-content-type.html index 036522ded..7c58ea6b8 100644 --- a/layouts/partials/openapi/render-content-type.html +++ b/layouts/partials/openapi/render-content-type.html @@ -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 }} {{ $content_type }} - {{ index $descriptions $idx | markdownify -}} + + {{ 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 -}} + {{ end }} diff --git a/layouts/partials/openapi/render-request.html b/layouts/partials/openapi/render-request.html index 5fa0c2559..1fbfc96c5 100644 --- a/layouts/partials/openapi/render-request.html +++ b/layouts/partials/openapi/render-request.html @@ -52,11 +52,15 @@

Request body

*/}} {{ $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 }}

Request body example

diff --git a/layouts/partials/openapi/render-responses.html b/layouts/partials/openapi/render-responses.html index 0ffc48844..683d2c6c1 100644 --- a/layouts/partials/openapi/render-responses.html +++ b/layouts/partials/openapi/render-responses.html @@ -123,11 +123,15 @@

{{$code}} response

*/}} {{ $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 }}