Validation of required fields inconsistent

Abierto
#373 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
5/5
Tiempo estimado
Más de una semana
Aptitud para principiantes
25/100
Tipo de issue
Error
Claridad
Necesita aclaración
Estado de actividad
Estancado
Stack tecnológico
python
Área
api, testing-qa

Línea de trabajo

The issue names no files or tests. First read the linked discussions and referenced issues #154, #312, #97, and #266 to determine the intended required-field validation policy, then locate the corresponding validator and tests. Done means the project has a decided, consistent behavior for standard, allOf, and referenced schemas, with coverage for that behavior.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

kind/bug/confirmed

The validation of the required keyword does not make sense as it is implemented right now, IMHO.

  1. It really does not make any sense to list properties in required that do not exist.
  2. If you want to use it with allOf and therefore have properties in required that do not exist, there are already precautions (#154).
  3. Currently, there is no validation error in the standard case but as soon as I have allOf in my schema, there is a validation error. That is inconsistent. The PR that breaks it: #312
  4. In $referenced schemas, the validation does not take effect either.

One of the main reasons why this should urgently be validated (as was in version 0.7.0) is that validators (that use the specification to validate requests/responses) will fail if there is e.g. a typo in one of the entries in required. And now there is no way to detect that.

In general, the OpenAPI/JsonSchema specification is quite relaxed. If only the bare minimum should be validated, this is probably not the only validation that can basically be removed completely.

My take on this:

  1. Best case: Throw validation errors for things that are obvious errors (like specifying a field as required that does not even exist).
  2. Second best option: make it configurable ("strict mode") or filterable (error IDs to exclude, filter levels, ...).
  3. Absolutely necessary minium: make it consistent.

I'd be willing to provide a PR. But since this has been going back and forth I'd like a decision first, where this is going.

Lenguaje dominante
Python
Estrellas
409
Forks
73
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-spec-validator

Todos los issues de python-openapi/openapi-spec-validator

Issues similares

Más issues de Python

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.