mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-04-28 21:34:09 +02:00
Fix OpenAPI definition for request body of upload endpoints and eliminate slices by passing the whole content into the partial
This commit is contained in:
parent
eeca7afc3c
commit
23393ad849
|
|
@ -712,8 +712,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:
|
||||||
|
|
|
||||||
|
|
@ -3,17 +3,11 @@
|
||||||
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:
|
two arrays with equal length:
|
||||||
|
|
||||||
* `content_types`: the content type strings
|
* `content_types`: OpenAPI data specifying the content types
|
||||||
* `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}}
|
|
||||||
{{ $added_in := .added_in}}
|
|
||||||
{{ $changed_in := .changed_in}}
|
|
||||||
|
|
||||||
{{ if (gt (len $content_types) 0) }}
|
{{ if (gt (len $content_types) 0) }}
|
||||||
|
|
||||||
|
|
@ -22,13 +16,13 @@
|
||||||
<th class="col-name">Content-Type</th>
|
<th class="col-name">Content-Type</th>
|
||||||
<th class="col-description">Description</th>
|
<th class="col-description">Description</th>
|
||||||
</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>
|
<td>
|
||||||
{{ index $descriptions $idx | markdownify -}}
|
{{ $body.schema.description | markdownify -}}
|
||||||
{{ if (index $added_in $idx) }}{{ partial "added-in" (dict "v" (index $added_in $idx)) }}{{ end -}}
|
{{ if (index $body.schema "x-addedInMatrixVersion") }}{{ partial "added-in" (dict "v" (index $body.schema "x-addedInMatrixVersion")) }}{{ end -}}
|
||||||
{{ if (index $changed_in $idx) }}{{ partial "changed-in" (dict "changes_dict" (index $changed_in $idx)) }}{{ end -}}
|
{{ if (index $body.schema "x-changedInMatrixVersion") }}{{ partial "changed-in" (dict "changes_dict" (index $body.schema "x-changedInMatrixVersion")) }}{{ end -}}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
|
|
@ -50,17 +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 }}
|
|
||||||
{{ $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) }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<h3>Request body example</h3>
|
<h3>Request body example</h3>
|
||||||
|
|
|
||||||
|
|
@ -121,17 +121,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 }}
|
|
||||||
{{ $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) }}
|
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue