How to customize API validation error response in Flask
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 25/100
Hướng nghiên cứu
Start with the Flask integration instructions linked in the issue and trace how incoming validation errors are turned into the generic response. Determine how an application could customize the response while accessing the status code, validation message, and title; done should include documented, working behavior for custom responses.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Actual Behavior
Getting generic resposne on validation error
{
"errors": [
{
"class": "<class 'openapi_core.validation.schemas.exceptions.InvalidSchemaValue'>",
"status": 400,
"title": "Value {'flag': 'testF'} not valid for schema of type object: (<ValidationError: \"'testF' is too short\">,)"
}
]
}
Expected Behavior
We should be able to generate custom responses, and should be able to capture the validation error info e.g. status code, validation error message, and title
Steps to Reproduce
I set up a flask server and followed the instructions provided here
Currently openapi-core is validating the incoming requets properly, however the response generated is as follows
{
"errors": [
{
"class": "<class 'openapi_core.validation.schemas.exceptions.InvalidSchemaValue'>",
"status": 400,
"title": "Value {'flag': 'testF'} not valid for schema of type object: (<ValidationError: \"'testF' is too short\">,)"
}
]
}
I want to customize the response body as per my application,
I wanted to know if is there any provision using which we can provide custom responses.
or even if we somehow capture the validation error info e.g. status code, validation error message, and title then we can generate our own response with the available information.
Thanks in advance
OpenAPI Core Version
0.17.1
OpenAPI Core Integration
Flask
Affected Area(s)
No response
References
No response
Anything else we need to know?
No response
Would you like to implement a fix?
None
- Ngôn ngữ chính
- Python
- Star
- 368
- Fork
- 140
- 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
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của python-openapi/openapi-core
-
kind/bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1188 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1225 · 2 bình luận ·
-
kind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value Đang mởkind/bug
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
python-openapi/openapi-core#1180 · 3 bình luận ·
Tất cả issue của python-openapi/openapi-core
Issue tương tự
-
documentation help wanted
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 90/100
simonw/sqlite-utils#872 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100