show the full path of the error/warning in iter_errors
还没有人认领这个 Issue。
评估
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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]
- 主要语言
- Python
- 星标
- 409
- 派生
- 73
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
python-openapi/openapi-spec-validator 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 55/100
-
难度 3/5 1-2 天 新手友好度 55/100
-
难度 3/5 1-2 天 新手友好度 30/100
-
难度 4/5 3-5 天 新手友好度 42/100
python-openapi/openapi-spec-validator#400 · 1 条评论 ·
-
kind/bug/confirmed
难度 5/5 一周以上 新手友好度 25/100
python-openapi/openapi-spec-validator#373 · 1 条评论 ·
查看 python-openapi/openapi-spec-validator 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 90/100
learningequality/ricecooker#747 ·
-
难度 2/5 1-3 小时 新手友好度 68/100
BSData/horus-heresy-3rd-edition#3171 ·
-
enhancement
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 76/100
run-llama/llama_index#23199 ·
-
难度 2/5 1-3 小时 新手友好度 84/100
KhronosGroup/glTF-Blender-IO#2769 ·