Skip to content

Commit

Permalink
Use phrasing "Notes on additional properties"
Browse files Browse the repository at this point in the history
Ignore `true` values for additionalProperties. Error on `false` values.
  • Loading branch information
David Robertson committed Jul 21, 2022
1 parent 9bc952e commit 3398cf0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions layouts/partials/openapi/render-object-table.html
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,21 @@

{{ end }}

{{/* NB: the OpenAPI spec says "Consistent with JSON Schema, additionalProperties
defaults to true." Our schemas tend to omit additionalProperties; I think we
effectively assume it defaults to false. Therefore: we only output regarding
additionalProperties if it is explicitly set (i.e. is non-nil). */}}
{{/* Additional properties should either be an OpenAPI schema object, or a
boolean. If it's the former, look for a `description` and render it as a note.
If it's `true`, do nothing. If it's `false`, raise a build-time error:
"Everything is extensible in Matrix unless otherwise noted". */}}
{{ if (ne $additionalProperties nil )}}
<tr class="row-additional-properties">
<td colspan="3">
{{ if (and (reflect.IsMap $additionalProperties)) -}}
{{ if (index $additionalProperties "description") -}}
May have additional properties: {{ $additionalProperties.description }}
Notes on additional properties: {{ $additionalProperties.description }}
{{ end }}
{{/* TODO: should we handle the case where additional properties are permitted,
but must follow an explicit schema? */}}
{{ else if $additionalProperties -}}
May have additional properties.
{{/* TODO: should we handle the case where additional properties are
permitted, but must follow an explicit schema? */}}
{{ else if (not $additionalProperties) -}}
{{/* At present we don't have any schema with additionalProperties: false.
But if we ever do, let's support it. */}}
{{ errorf "Unexpected additionalProperties=false for %s" $caption }}
May **not** have additional properties.
{{ end }}
</td>
Expand Down

0 comments on commit 3398cf0

Please sign in to comment.