show the full path of the error/warning in iter_errors

Đang mở
#152 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
api

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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]

Ngôn ngữ chính
Python
Star
409
Fork
73
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python-openapi/openapi-spec-validator

Tất cả issue của python-openapi/openapi-spec-validator

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.