"nullable: True" ignored if used together with allOf or oneOf
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Estancado
- Stack tecnológico
- python
- Área
- api, backend-api-design
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Python
- Estrellas
- 368
- Forks
- 140
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de python-openapi/openapi-core
-
kind/bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
python-openapi/openapi-core#1188 · 2 comentarios ·
-
kind/bug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
python-openapi/openapi-core#1225 · 2 comentarios ·
-
kind/bug
Dificultad 3/5 1-2 días Aptitud para principiantes 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Abiertokind/bug
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Dificultad 3/5 1-2 días Aptitud para principiantes 58/100
python-openapi/openapi-core#1180 · 3 comentarios ·
Todos los issues de python-openapi/openapi-core
Issues similares
-
Add: hunch Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
DiamondLightSource/dodal#2211 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
openml/openml-python#1749 ·
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 88/100
sipyourdrink-ltd/bernstein#6191 ·