Skip to content

additionalProperties at a composed schema level, interpretation guidance for v3.0.0 spec? #2478

@spacether

Description

@spacether

Hi there,
I am unsure of how to interpret this v3.0.0 specification and would appreciate expert guidance.
Given this spec:

    ShapeInterface:
      properties:
        shapeType:
          type: string
      required:
        - shapeType
    TriangleInterface:
      properties:
        triangleType:
          type: string
      required:
        - triangleType
    IsoscelesTriangle:
      allOf:
        - $ref: '#/components/schemas/ShapeInterface'
        - $ref: '#/components/schemas/TriangleInterface'
      additionalProperties: false

additionalProperties is True by default in ShapeInterface + TriangleInterface
but we set it to False in IsoscelesTriangle

Some questions:

  1. Is this a valid spec?
  2. Will validating this payload as an IsoscelesTriangle succeed?
{
    'shape_type': 'Triangle',
    'triangle_type': 'EquilateralTriangle',
    'unknown_property': 'a-value'
}
  1. If validation will not succeed then this also has implications to validating oneOf/anyOf composed schemas, right? First one would need to validate to all oneOf/anyOf schemas, then if additionalProperties is False at the composed schema level only, one would need to check that all the assigned properties exist as properties in the chosen oneOf/anyOf schemas.

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