show the full path of the error/warning in iter_errors
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 35/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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]
- Dominant language
- Python
- Stars
- 409
- Forks
- 73
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python-openapi/openapi-spec-validator
-
Difficulty 4/5 3-5 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
Difficulty 3/5 1-2 days Newbie friendliness 30/100
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
python-openapi/openapi-spec-validator#400 · 1 comment ·
-
kind/bug/confirmed
Difficulty 5/5 Over a week Newbie friendliness 25/100
python-openapi/openapi-spec-validator#373 · 1 comment ·
All issues in python-openapi/openapi-spec-validator
Similar issues
-
Add: hunch Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
openml/openml-python#1749 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
sipyourdrink-ltd/bernstein#6191 ·