factset/quart-openapi

Validate responses as well as requests

Opened this issue · 3 comments

It would be nice for quart-openapi to validate responses against the response schema as well as requests against the request schema. Right now, response validators can be added for documentation purposes only. Ideally, the server would 500 upon validation error.

Hmm, I don't know how much I like this idea solely that I believe it would be the responsibility of the person building the service to ensure their responses follow their own schema but probably don't want to have their service suddenly 500 or otherwise fail if they screwed up their schema or their response in a given scenario. I'd rather err towards flexibility on that end.

That said, maybe adding an option in which a consumer can turn on this sort of validation against responses so a user can enable it understanding the risks might make sense. I'll see what I can come up with (or you're welcome to contribute if you like!)

One of the possible use-cases is testing purpose (ensuring that documentation is correct).

PS: flask-restplus validates both requests and responses when validate=True is configured.

Fair point, I'll put it on my list and try to get to adding this functionality in the next couple weeks. If anyone wants, feel free to file a PR adding it yourself :)