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

Abierto
#277 5 comentarios 7 reacciones 0 asignados Ver en GitHub

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

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

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de python-openapi/openapi-core

Todos los issues de python-openapi/openapi-core

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.