Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Discriminator for oneOf schemas ignored

Open
#66 2 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
openapi, python
Domain
api

Research direction

Start by locating the oneOf and discriminator validation entry points in the Python library, then reproduce the issue with the provided schema and request. Trace how the discriminator mapping selects a schema and compare the current generic error with the requested property-specific validation error. Done means the mapped schema is validated and invalid requests receive useful errors.

Written by the indexing model from the issue text.

Description

area/schema kind/enhancement

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.

Dominant language
Python
Stars
368
Forks
140
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-openapi/openapi-core

All issues in python-openapi/openapi-core

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.