Skip to content

additionalProperties not set correctly if omitted or a boolean #1369

@spacether

Description

@spacether

Per the openapi v2 and greater spec definitions, additionalProperties should be set to empty schema {} if it is omitted. It is currently being set to null.

v2.0 points us to the https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md JSON schema Draft 4 definition, and OpenAPI does not tell us a default value.
Per here it sounds like an omitted additionalProperties should be an empty schema.

v3.0.0 points us to the https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md JSON Schema Specification Wright Draft 00 definition.
Wright Draft 00 mentions
If "additionalProperties" is absent, it may be considered present with an empty schema as a value.
v3.0.3 explicitly says that it defaults to true here: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md

Specifically from https://tools.ietf.org/html/draft-wright-json-schema-validation-00#page-10:

If "additionalProperties" is absent, it may be considered present with an empty schema as a value.

When additionalProperties is omited, how about we set it to {} for:

  • object type schemas
  • composed schemas
    So that we conform to the specs

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions