-
Notifications
You must be signed in to change notification settings - Fork 63
Description
If flask-pydantic is used in conjunction with other frameworks that inject values into the routes arguments then validate must be the first decorator or else it will try to validate input for those other injected routes.
E.g. If you have a decorator @authenticated that injects a authentication_payload into routes
@validate
@authenticated
def my_route(body_param: MyModel, authentication_payload: AuthenticationPayload) -> MyResponse:
...This works because the @authenticated has a chance to inject the authentication_payload value before @validate tries to find a value.
However
@authenticated
@validate
def my_route(body_param: MyModel, authentication_payload: AuthenticationPayload) -> MyResponse:
...Does not work because @validate tries to find a value for authentication_payload before @authenticated gets a chance.
It would be nice to be able to
do @validate(ignore_path_params=["authentication_payload"])
or set a global configuration FLASK_PYDANTIC_VALIDATION_IGNORE_PARAMS which is a list of path_params to ignore.