-
Notifications
You must be signed in to change notification settings - Fork 38
ISSUE-220 allow for response validation #225
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
base: master
Are you sure you want to change the base?
ISSUE-220 allow for response validation #225
Conversation
@mr-tabasco Thank you for your contribution! But there are some issues here. I've made some fixes and optimizations, but the code push was rejected. Please ensure that the option "Allow edits and access to secrets by maintainers" (located in the bottom-right corner) is selected. |
I've updated the PR to allow for edits. as for following up, I've been super busy and then got the flu. I'll try and look at following up either this weekend or some time soon after, just need to catch up on work first. |
@mr-tabasco I fixed some errors and made some optimizations. |
flask_openapi3/utils.py
Outdated
@@ -592,6 +592,39 @@ def make_validation_error_response(e: ValidationError) -> FlaskResponse: | |||
return response | |||
|
|||
|
|||
def run_validate_response(response: Any, responses: Optional[ResponseDict] = None) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it can be a method that can be overridden?
flask_openapi3/scaffold.py
Outdated
_validate_response = validate_response | ||
|
||
if _validate_response and responses: | ||
run_validate_response(response, responses) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer that run_validate_response() be able to modify the response and then you return it. What do you think?
@ddorian Thanks for your suggestion, I quickly submitted a version. |
@luolingchun looking good! |
Checklist:
pytest tests
and no failed.ruff check flask_openapi3 tests examples
and no failed.mypy flask_openapi3
and no failed.mkdocs serve
and no failed.fix: #220