Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

mr-tabasco
Copy link

@mr-tabasco mr-tabasco commented May 10, 2025

Checklist:

  • Run pytest tests and no failed.
  • Run ruff check flask_openapi3 tests examples and no failed.
  • Run mypy flask_openapi3 and no failed.
  • Run mkdocs serve and no failed.

fix: #220

@luolingchun
Copy link
Owner

@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.

@mr-tabasco
Copy link
Author

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.

@luolingchun
Copy link
Owner

@mr-tabasco I fixed some errors and made some optimizations.
@wconrad265 @ddorian Sorry to bother you, I hope you have time to test your own needs.

@@ -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:
Copy link
Contributor

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?

_validate_response = validate_response

if _validate_response and responses:
run_validate_response(response, responses)
Copy link
Contributor

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?

@luolingchun
Copy link
Owner

@ddorian Thanks for your suggestion, I quickly submitted a version.

@ddorian
Copy link
Contributor

ddorian commented May 23, 2025

@luolingchun looking good!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Response Data Validation in flask-openapi3
3 participants