-
Notifications
You must be signed in to change notification settings - Fork 677
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
HateoasSortHandlerMethodArgumentResolver should append * to the 'sort' parameter template variable. #2531
Comments
Since the introduction of 6e22ffd, the sort parameter has been rendered as composite parameter which will cause the comma used to delimit property from direction potentially be encoded by clients following the URI template RFC. Thus, we need to defensively decode the source parameter value before parsing. Related ticket: GH-2531.
I've reverted the back ports as the change has too many side effects to the URI handling to introduce it in bugfix releases. The switch to a composite parameter causes clients adhering to the URI template RFC to now encode the comma, which effectively breaks the API. I've put measures in place in |
Since the introduction of 6e22ffd, the sort parameter has been rendered as composite parameter which will cause the comma used to delimit property from direction potentially be encoded by clients following the URI template RFC. Thus, we need to defensively decode the source parameter value before parsing. Related ticket: GH-2531.
Fix Javadoc reference. Reorder tags. See #2531
Fix Javadoc reference. Reorder tags. See #2531
…olver. Fixes GH-2339. Related ticket: spring-projects/spring-data-commons#2531.
Adapt the affected smoke test to the changes made for spring-projects/spring-data-commons#2531. See gh-211
The Spring docs (see Table 1) specify that multiple sort parameters should be present in the request params for Pageable instances when sorting by multiple fields. (e.g. sort=field1,asc&sort=field2,desc).
Spring HATEOAS via the data commons HateoasSortHandlerMethodArgumentResolver class generates a URI template variable for the 'sort' param without the URI template explode modifier (*).
For client side libraries performing URI expansion based on rfc6570, in conditions where there are multiple sort parameters, the template provided by Spring without the modifier will generate URLs of the following format:
This URL isn't in the correct format outlined in the Spring docs (see Table 1), and a format not expected by the handlers resulting in incorrect parsing (results in two order by's, but direction is DESC for both).
The explode modifier added to sort would allow rfc6570 compliant libraries to generate the correct URLs expected by Spring and allow correct sorting criteria to be generated:
There is an existing related issue #1242, which deals with multiple values and generated query method templates... which i can see needs addressing deeper in the HATEOAS codebase, but to fix sorting properly by anything Pageable, it seems like a simple fix would be to append "*" to the sort param generated by this class.
org.springframework.data.web.HateoasSortHandlerMethodArgumentResolver#getSortTemplateVariables
The text was updated successfully, but these errors were encountered: