pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

scope @validate_request by method #63

Closed catwell closed 11 months ago

catwell commented 11 months ago

Suppose I have a REST API with an endpoint supporting multiple verbs (for instance GET, PUT and DELETE). The request parameters for those verbs are likely different but Flask and Quart treat them as the same route. How can we deal with this in quart-schema?

One possibility I can see is to use the same kind of mechanism as for @validate_response: add an optional methods attribute to the validator and ignore it if the method does not match. That way we can stack multiple validators like with @validate_response.

If there is already another solution to this, please tell me! If not I can try implementing it and making a PR if my solution sounds good to you.

catwell commented 11 months ago

Actually, disregard this. It is just cleaner to define three routes with the same path and a different method rather than passing all three methods to a single route. I am just used to this pattern which does not make sense with quart-schema.