show the full path of the error/warning in iter_errors

Aberta
#152 0 comentários 1 reação 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
35/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Estagnada
Stack de tecnologia
python
Domínio
api

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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]

Linguagem predominante
Python
Estrelas
409
Forks
73
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Abrir o guia de contribuição

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de python-openapi/openapi-spec-validator

Todas as issues de python-openapi/openapi-spec-validator

Issues semelhantes

Mais issues de Python

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.