"nullable: True" ignored if used together with allOf or oneOf
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
- Domain
- api, backend-api-design
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-openapi/openapi-core
-
kind/bug
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
python-openapi/openapi-core#1188 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1225 · 2 comments ·
-
kind/bug
Difficulty 3/5 1-2 days Newbie friendliness 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Openkind/bug
Difficulty 3/5 1-2 days Newbie friendliness 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Difficulty 3/5 1-2 days Newbie friendliness 58/100
python-openapi/openapi-core#1180 · 3 comments ·
All issues in python-openapi/openapi-core
Similar issues
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 90/100
learningequality/ricecooker#747 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
run-llama/llama_index#23199 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
KhronosGroup/glTF-Blender-IO#2769 ·