-
-
Notifications
You must be signed in to change notification settings - Fork 74
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Question] Skip validation for real? #291
Comments
hi, can you please provide more details? Is it a request or a response validation you intend to skip? Can you show some minimal-reproducible example where it's not working as intended? |
Ideally I'd like to have the option to skip both request & response validation. I tried to strip it down as much as possible. I've got a view function like this:
Then I import the view into a blueprint.py file like this:
Then app.py imports & registers the blueprint:
The generated spec looks good so I assume I have done this correctly. However the spec includes this 422 response:
This test passes, as I would expect it to:
However if I change it to:
...it fails with a 422:
|
So May I know why you don't want to have the request validation? |
That makes a lot more sense, thank you for clarifying it only skips the response validation. Skipping the request validation is not a hill I will die on. On reflection I think it's fine as-is -- I was wary about coupling API docs with validation, wanted to stay flexible & keep the code simple & explicit & easily traceable. I'm testing this out for a microservice that is already very complex. But on second thought the validation decorator tells future devs everything they need to know, and it seems likely we will always want at least simple type checking when there is request json. I've run into a new problem: Although the API tests behave as expected, when I actually hit the endpoint with Postman the request json doesn't get validated. The response validation does work, but no matter what I pass in the request, there is no error and the Context object is always empty: Do you have any idea what could cause this? |
most likely you're not sending |
facepalm yeah that was it. Thanks a million, guys. BTW would you accept a PR to rename |
I guess we can add some documentation to make it more clearly. Changing the name may break some users. What do you think? |
Sure! I can help with that. Sorry, been busy. BTW FWIW there was a lot of pushback on my team against using spectree, concerns about adopting a less-well-established library into critical infrastructure. It would have helped a lot to ease their concerns if it were possible to fully disable validation & just use it for generating docs. I hope you'll consider adding this option in the future. |
The validation is a great feature, but I just want an OpenAPI spec generator for Flask+Pydantic & would prefer to be explicit about the validation & error responses in the body of the view function.
I added
skip_validation=True
to the decorator as per the README, but it doesn't seem to affect anything; at least theFlaskPlugin
request_validation
method proceeds unaffected. Have I misunderstood something?The text was updated successfully, but these errors were encountered: