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

"nullable: True" ignored if used together with allOf or oneOf

Open
#277 5 comments 7 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

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

Research direction

Reproduce the reported OpenAPI schema with nullable combined with oneOf or allOf and validate an instance containing None. Trace the validator entry point that handles nullable and composition keywords. Done means None is accepted when nullable is true without breaking oneOf or allOf validation, with regression coverage for the reported schema.

Written by the indexing model from the issue text.

Description

I have the following issue. drf-spectacular generates the following spec for enums (for example, for a building_type field which can be either "house" or "apartment" or null):

    WhateverObject:
      type: object
      properties:
        building_type:
          nullable: true
          oneOf:
          - $ref: '#/components/schemas/BuildingTypeEnum'
          - $ref: '#/components/schemas/NullEnum'
 
    BuildingTypeEnum:
      enum:
      - house
      - apartment
      type: string

    NullEnum:
      enum:
      - null

but when trying to validate data containing None for the building_type field I get this error:

Failed validating 'oneOf' in schema['properties']['building_type']:
    {'nullable': True,
     'oneOf': [{'$ref': '#/components/schemas/BuildingTypeEnum',
                'nullable': False,
                'x-scope': ['', '#/components/schemas/HomeProfile']},
               {'$ref': '#/components/schemas/NullEnum',
                'nullable': False,
                'x-scope': ['', '#/components/schemas/HomeProfile']}]}

On instance['building_type']:
    None
None is not valid under any of the given schemas

I think that None should be allowed if nullable: True is specified.

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.