Only include a table row for additionalProperties with a description

This commit is contained in:
David Robertson 2022-11-22 18:31:17 +00:00
parent 6487e84c4e
commit 87ded3b25c
No known key found for this signature in database
GPG key ID: 903ECE108A39DEDD

View file

@ -107,26 +107,27 @@
{{ end }} {{ end }}
{{/* additionalProperties should either be an OpenAPI schema object, or a {{/* If additionalProperties is true, do nothing.
boolean. If it's the former, look for a `description` and render it as a note. If additionalProperties is nil, treat is as the default (true) and do nothing.
If it's `true`, do nothing. If it's `false`, raise a build-time error: If additionalProperties is false, raise a build-time error:
"Everything is extensible in Matrix unless otherwise noted". */}} "Everything is extensible in Matrix unless otherwise noted".
{{ if (ne $additionalProperties nil )}} Otherwise, it should be an OpenAPI schema object. Include the description
of that schema object, if it exists. */}}
{{ if (and (ne $additionalProperties nil) (ne $additionalProperties true)) }}
{{ if (and (reflect.IsMap $additionalProperties)) -}}
{{ if (index $additionalProperties "description") -}}
<tr class="row-additional-properties"> <tr class="row-additional-properties">
<td colspan="3"> <td colspan="3">
{{ if (and (reflect.IsMap $additionalProperties)) -}} <em>Notes on additional properties:</em> {{ $additionalProperties.description }}
{{ if (index $additionalProperties "description") -}}
<em>Notes on additional properties:</em> {{ $additionalProperties.description }}
{{ end }}
{{/* TODO: should we handle the case where additional properties are
permitted, but must follow an explicit schema? */}}
{{ else if (not $additionalProperties) -}}
{{ errorf "Unexpected additionalProperties=false for %s" $title }}
May **not** have additional properties.
{{ end }}
</td> </td>
</tr> </tr>
{{ end }} {{ end }}
{{/* TODO: should we handle the case where additional properties are
permitted, but must follow an explicit schema? */}}
{{ else if (not $additionalProperties) -}}
{{ errorf "Unexpected additionalProperties=false for %s" $title }}
{{ end }}
{{ end }}
</table> </table>
{{ end }} {{ end }}