Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions data/api/client-server/content-repo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -712,8 +712,9 @@ components:
bytes:
content:
application/octet-stream:
example: <bytes>
description: The content to be uploaded.
schema:
description: The content to be uploaded.
example: <bytes>
required: true
responses:
uploadTooLarge:
Expand Down
18 changes: 6 additions & 12 deletions layouts/partials/openapi/render-content-type.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,11 @@
Render a table showing content types and their descriptions, given
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`: OpenAPI data specifying the content types

*/}}

{{ $content_types := .content_types }}
{{ $descriptions := .descriptions}}
{{ $added_in := .added_in}}
{{ $changed_in := .changed_in}}

{{ if (gt (len $content_types) 0) }}

Expand All @@ -22,13 +16,13 @@
<th class="col-name">Content-Type</th>
<th class="col-description">Description</th>
</thead>
{{ range $idx, $content_type := $content_types }}
{{ range $mime, $body := $content_types }}
<tr>
<td><code>{{ $content_type }}</code></td>
<td><code>{{ $mime }}</code></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 -}}
{{ $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>
{{ end }}
Expand Down
12 changes: 1 addition & 11 deletions layouts/partials/openapi/render-request.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,7 @@ <h3>Request body</h3>
{{/*
Show the content types and description.
*/}}
{{ $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 "added_in" $added_in "changed_in" $changed_in) }}
{{ partial "openapi/render-content-type" (dict "content_types" $request_body.content) }}
{{ end }}

<h3>Request body example</h3>
Expand Down
12 changes: 1 addition & 11 deletions layouts/partials/openapi/render-responses.html
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,7 @@ <h3>{{$code}} response</h3>
{{/*
Show the content types and description.
*/}}
{{ $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 "added_in" $added_in "changed_in" $changed_in) }}
{{ partial "openapi/render-content-type" (dict "content_types" $response.content) }}
{{ end }}
{{ end }}
{{ end }}