Fix path parameter validation to work with dependency injection #110
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
validate_path_params()to only validate actual path parameters from Flask routes, not injected dependenciesProblem
The
validate_path_params()function was attempting to validate all function parameters inkwargs, including dependencies injected by other decorators. This caused errors when using@validate()with dependency injection patterns, as the injected parameters couldn't be validated by Pydantic.See #49
Solution
Modified
validate_path_params()to userequest.view_argsto identify which parameters are actual path parameters from the Flask route. This ensures only URL path parameters are validated, while injected dependencies and other parameters are left untouched.Changes
validate_path_params()inflask_pydantic/core.pyto checkrequest.view_argsapp_with_path_param_route_and_injectorto test DI compatibilityTestPathIntParameterAndInjectortest class with two testsTest plan