-
Notifications
You must be signed in to change notification settings - Fork 301
query validation filter #481
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
query validation filter #481
Conversation
Not sure it's needed, but the docmentation says to do it.
- allow the example app to still run, just failing any JSONAPIDjangoFilter tests. - split the two filters into separate files for easier maintenance.
- Had a mistake (unquoted '.') and missing '-' as an allowed character. Also '_' already in '\w' - Don't be so exhaustive in testing for invalid filters; let JSONAPIQueryValidationFilter (when available) deal with that.
…ing lots of older tests that use non-standard query params like page_size
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR came quicker than I have anticipated. Great. 😉
I like how it's implemented now where just all possible JSON API query parameters are listed and not trying to guess query params by different classes. 👍
In general it looks good. See some comments above.
…lter query parameter. This makes a consistent error message irrespective of whether QueryParameterValidation is used.
…ery param validation (not queryset)
@sliverc Thanks for letting me sneak this into 2.6.0! |
Description of the Change
Rounds out the suite of JSON:API backend filters with one that checks for mandatory query parameter names and returns a 400 if one that doesn't match is seen, or if a param like
sort
is repeated. This makes for a more positive client developer experience in that incorrect query params (typos, etc.) are reported as errors rather than being silently ignored.Checklist
CHANGELOG.md
AUTHORS
Changelog is already covered by "Add optional jsonapi-style filter backends. See usage docs" from prior filters.
Commit history is pretty ugly because this was authored a while ago and then a bunch of new master commits were merged. This should be squashed when merged.