How to customize API validation error response in Flask
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Python
- スター
- 368
- フォーク
- 140
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
python-openapi/openapi-core のほかの issue
-
kind/bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
python-openapi/openapi-core#1188 · コメント 2 件 ·
-
kind/bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-openapi/openapi-core#1225 · コメント 2 件 ·
-
kind/bug
難易度 3/5 1〜2日 初心者へのやさしさ 76/100
python-openapi/openapi-core#1212 ·
-
[Bug]: Query parameter validation fails to match empty string when listed as a valid enum value オープンkind/bug
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
python-openapi/openapi-core#1210 ·
-
kind/bug kind/bug/confirmed
難易度 3/5 1〜2日 初心者へのやさしさ 58/100
python-openapi/openapi-core#1180 · コメント 3 件 ·
python-openapi/openapi-core の issue をすべて見る
似ている issue
-
documentation help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
simonw/sqlite-utils#872 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 88/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100