Description
JSON Schema allows for additionalProperties
both a boolean or an object value. true
is interpreted as "additional properties follow no restrictions", false
means "no additional restrictions", and an object is interpreted as a JSON schema applied to the property values (the empty object is thus equivalent to true
).
The Schema object description says:
The following properties are taken from the JSON Schema definition but their definitions
were adjusted to the OpenAPI Specification. Their definition is the same as the one from
JSON Schema, only where the original definition references the JSON Schema definition,
the Schema Object definition is used instead.
- items
- allOf
- properties
- additionalProperties
This would be naively interpreted as additionalProperties
can have a boolean or a schema value (with a schema being interpreted as an OpenAPI schema, not a JSON schema).
In Swagger-Codegen #1318, @webron commented that this was actually meant as "the value of additionalProperties can only be a (Swagger) Schema object", not a boolean.
Some more discussion was in #477 here.
(I just hit an API which used booleans in several places, and fails with swagger-codegen.)
To make this clearer in the next version of the spec, I suggest to add the following sentence to the cited paragraph above (before the list):
Alternative values of other types (boolean) are not allowed.
I'm not totally happy with this wording, feel free to propose a better one. Maybe we should instead simply redefine additionalProperties
generally?