Skip to content

Discriminators (not) changing the JSON Schema Validator behavior #2516

@FWiesner

Description

@FWiesner

As discussed on the TSC on March 25th, discriminator is supposed to not affect JSON Schema validation.

https://github.com/OAI/OpenAPI-Specification/blame/master/versions/3.1.0.md#L2703

and the following examples puzzle me here, as to me it clearly reads that properties/required in combination with polymorphic use of allOf are to be ignored, if they are not on a nested object definition underneath allOf themselves

foo required with otherSchema carrying the discriminator:

allOf:
  - $ref: otherSchema
  - type: object
    properties:
      foo:
        type: string
    required: ["foo"]

foo ignored/not required:

properties:
  foo:
    type: string
required: ["foo"]
allOf:
  - $ref: otherSchema

This to me is not compatible with the intention to have discriminator to only be a hint.

https://github.com/OAI/OpenAPI-Specification/blame/master/versions/3.1.0.md#L2701 also specifically lists deserialization, serialization and validation

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions