show the full path of the error/warning in iter_errors

Abierto
#152 0 comentarios 1 reacción 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
35/100
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Estancado
Stack tecnológico
python
Área
api

Línea de trabajo

Start at openapi_v3_spec_validator.iter_errors and reproduce the reported output with the OpenAPI document and snippet in the issue. Trace how validation errors are formatted and verify that each emitted error includes the requested absolute path, including the shown parameters[4] location.

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

Descripción

Hi everyone

I'm validating this open API: https://api.apis.guru/v2/specs/exlibrisgroup.com/tasklists/1.0/openapi.json and I need it to show me the absolute path of the error/warning instead, not only: {'default': '10', 'type': 'integer', 'nullable': False}
because the API is a little big and I want an easy way to trace the error/warning.

the code:

import json
import requests
from openapi_spec_validator import openapi_v3_spec_validator

with open('openapi.json', 'w') as file:
    file.write(requests.get('https://api.apis.guru/v2/specs/exlibrisgroup.com/tasklists/1.0/openapi.json').text)
    file.close()

with open('openapi.json', 'r') as file:
    schema = json.load(file)
    file.close()

errors = openapi_v3_spec_validator.iter_errors(schema)
for error in errors:
    print(error)
    print(error.schema, error.path, error.absolute_schema_path)
    print(error.relative_path, error.relative_schema_path, error.schema_path)
    break    

the output:

'10' is not of type integer

Failed validating 'type' in schema:
    {'default': '10', 'nullable': False, 'type': 'integer'}

On instance:
    '10'
{'default': '10', 'type': 'integer', 'nullable': False} deque([]) deque(['type'])
deque([]) deque(['type']) deque(['type'])

it would be nice if this output is also added to the message:
#/paths//almaws/v1/task-lists/printouts/get/parameters[4]

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.