Skip to content

Discriminator for oneOf schemas ignored #66

Open
@smarlowucf

Description

@smarlowucf

If a discriminator is set for a list of oneOf schemas only the matching schema should be validated against and therefore useful errors can be provided:

schema

requestBody:
  content:
    application/json:
      schema:
        oneOf:
          - $ref: '#/components/schemas/cat_type'
          - $ref: '#/components/schemas/dog_type'
        discriminator:
          propertyName: type
          mapping:
            cat: '#/components/schemas/cat_type'
            dog: '#/components/schemas/dog_type'

request

{'type': 'dog' ...}

If the request is invalid the validator raises: "Exactly one valid schema should be valid, None found."

But if there's a discriminator we know which schema to validate against and could provide a useful error message. Such as what property is missing or invalid.

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