Allow lists to be used as models for validate_request and validate_response #67
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.
Addresses Issue #16.
Change how
validate_request
andvalidate_response
validate if the provided model is the same as the model provided in the decorator. ForBaseModel
andRootModel
instances, we can use thevalidate_python
method to do the validation. In all other cases, we'll instead use a pydanticTypeAdapter
which will attempt to build a validator for the requested model.These changes allow us to use the following methods for declaring a method that expects a list of items:
Additional tests have been added to validate cases where lists or RootModels are passed to validate_request and validate_response.
Note that this PR doesn't make any changes to the header validation or query string validation. I wanted to get an idea if this altered way of validating makes sense before making too many changes.