Skip to content

Allow configuration to ignore injection of certain path parameters. #97

@tedo-benchling

Description

@tedo-benchling

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions