Skip to content
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

Restrict responses with only documented types (@api.response(code=...)) #27

Open
frol opened this issue Sep 23, 2016 · 2 comments
Open

Comments

@frol
Copy link
Owner

frol commented Sep 23, 2016

#26 showed that there might be a situation when all tests pass, the response is expected, but it was not explicitly covered with @api.response() decorator. I think we will need to override Api.output from flask_restplus/api.py (note, there is already customization on Api class in flask_restplus_patched, so you can just add this patch there), so we can check what responses are defined on the resource, and the current response is expected (don't forget about special care around HTTP/500 internal error, this can happen anywhere and shouldn't be shadowed).

@khorolets
Copy link
Collaborator

May I ask you to provide a little details or just explain what do you want? :)

@frol
Copy link
Owner Author

frol commented Sep 26, 2016

Actually, I don't think we need to address this now.

The point of the issue is that I wanted to make sure that all possible responses are documented in Swagger and if it is not, I wanted to raise an exception (only in the Debug mode). Since you cannot inspect the code for all possible return values, I thought to make a check for what is going to be returned somewhere and check if it was documented and then tests would fail even if a resource returns a correct response.

Example, we had DELETE handlers, which returned HTTP/200, and tests passed, but HTTP/200 was not documented in the Swagger UI (nobody cared about it). I want so this won't ever repeat again, if resource returns some data with HTTP/200 and it is not documented, some sort of exception should be raised instead of silently getting response out (even if it is completely legitimate and expected).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants