Skip to content

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

Merged
merged 30 commits into from
Sep 19, 2018

Conversation

n2ygk
Copy link
Contributor

@n2ygk n2ygk commented Sep 17, 2018

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

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • changelog entry added to CHANGELOG.md
  • author name in 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.

n2ygk added 25 commits August 23, 2018 17:10
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
@n2ygk n2ygk requested a review from sliverc September 17, 2018 17:02
Copy link
Member

@sliverc sliverc left a 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.

@sliverc sliverc added this to the 2.6.0 milestone Sep 18, 2018
…lter query parameter.

This makes a consistent error message irrespective of whether QueryParameterValidation is used.
@n2ygk
Copy link
Contributor Author

n2ygk commented Sep 18, 2018

@sliverc Thanks for letting me sneak this into 2.6.0!

@n2ygk n2ygk mentioned this pull request Sep 18, 2018
4 tasks
@sliverc sliverc merged commit 16f3c97 into django-json-api:master Sep 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants