Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Draft : Adding provision to pass inputs to custom error handler class#919

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
rohan-97 wants to merge1 commit intopython-openapi:master
base:master
Choose a base branch
Loading
fromrohan-97:issue_910
Open
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletionopenapi_core/contrib/flask/decorators.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,12 +34,14 @@ def __init__(
errors_handler_cls: Type[
FlaskOpenAPIErrorsHandler
] = FlaskOpenAPIErrorsHandler,
error_handler_params: dict = None
):
super().__init__(openapi)
self.request_cls = request_cls
self.response_cls = response_cls
self.request_provider = request_provider
self.errors_handler_cls = errors_handler_cls
self.error_handler_params = error_handler_params

def __call__(self, view: Callable[..., Any]) -> Callable[..., Any]:
@wraps(view)
Expand All@@ -48,7 +50,10 @@ def decorated(*args: Any, **kwargs: Any) -> Response:
valid_request_handler = self.valid_request_handler_cls(
request, view, *args, **kwargs
)
errors_handler = self.errors_handler_cls()
if self.error_handler_params is None:
errors_handler = self.errors_handler_cls()
else:
errors_handler = self.errors_handler_cls(self.error_handler_params)
response = self.handle_request(
request, valid_request_handler, errors_handler
)
Expand All@@ -69,6 +74,7 @@ def from_spec(
errors_handler_cls: Type[
FlaskOpenAPIErrorsHandler
] = FlaskOpenAPIErrorsHandler,
error_handler_params: dict = None
) -> "FlaskOpenAPIViewDecorator":
openapi = OpenAPI(spec)
return cls(
Expand All@@ -77,4 +83,5 @@ def from_spec(
response_cls=response_cls,
request_provider=request_provider,
errors_handler_cls=errors_handler_cls,
error_handler_params=error_handler_params
)
Loading

[8]ページ先頭

©2009-2025 Movatter.jp