diff --git a/src/main/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolver.java b/src/main/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolver.java index 9ab5089dcb..b0a51487cd 100644 --- a/src/main/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolver.java +++ b/src/main/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolver.java @@ -57,9 +57,11 @@ public TemplateVariables getSortTemplateVariables(MethodParameter parameter, Uri return TemplateVariables.NONE; } - String description = String.format("pagination.%s.description", sortParameter); + String sortParameterExplode = sortParameter + '*'; + + String description = String.format("pagination.%s.description", sortParameterExplode); TemplateVariable.VariableType type = append ? REQUEST_PARAM_CONTINUED : REQUEST_PARAM; - return new TemplateVariables(new TemplateVariable(sortParameter, type, description)); + return new TemplateVariables(new TemplateVariable(sortParameterExplode, type, description)); } @Override diff --git a/src/test/java/org/springframework/data/web/HateoasPageableHandlerMethodArgumentResolverUnitTests.java b/src/test/java/org/springframework/data/web/HateoasPageableHandlerMethodArgumentResolverUnitTests.java index e29e54ec47..c8f6838368 100755 --- a/src/test/java/org/springframework/data/web/HateoasPageableHandlerMethodArgumentResolverUnitTests.java +++ b/src/test/java/org/springframework/data/web/HateoasPageableHandlerMethodArgumentResolverUnitTests.java @@ -73,10 +73,10 @@ void preventsPageSizeFromExceedingMayValueIfConfiguredOnWrite() throws Exception @Test // DATACMNS-418 void appendsTemplateVariablesCorrectly() { - assertTemplateEnrichment("/foo", "{?page,size,sort}"); - assertTemplateEnrichment("/foo?bar=1", "{&page,size,sort}"); - assertTemplateEnrichment("/foo?page=1", "{&size,sort}"); - assertTemplateEnrichment("/foo?page=1&size=10", "{&sort}"); + assertTemplateEnrichment("/foo", "{?page,size,sort*}"); + assertTemplateEnrichment("/foo?bar=1", "{&page,size,sort*}"); + assertTemplateEnrichment("/foo?page=1", "{&size,sort*}"); + assertTemplateEnrichment("/foo?page=1&size=10", "{&sort*}"); assertTemplateEnrichment("/foo?page=1&sort=foo,asc", "{&size}"); assertTemplateEnrichment("/foo?page=1&size=10&sort=foo,asc", ""); } @@ -90,7 +90,7 @@ void returnsCustomizedTemplateVariables() { resolver.setPageParameterName("foo"); var variables = resolver.getPaginationTemplateVariables(null, uriComponents).toString(); - assertThat(variables).isEqualTo("{?foo,size,sort}"); + assertThat(variables).isEqualTo("{?foo,size,sort*}"); } @Test // DATACMNS-563 @@ -128,7 +128,7 @@ void enhanceTemplateVariables() { resolver.setPageParameterName("foo"); String variables = resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString(); - assertThat(variables).isEqualTo("{?foo,size,sort}"); + assertThat(variables).isEqualTo("{?foo,size,sort*}"); } @Override diff --git a/src/test/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolverUnitTests.java b/src/test/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolverUnitTests.java index 218bc41b75..744c9103c7 100755 --- a/src/test/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolverUnitTests.java +++ b/src/test/java/org/springframework/data/web/HateoasSortHandlerMethodArgumentResolverUnitTests.java @@ -56,7 +56,7 @@ void returnCorrectTemplateVariables() { var uriComponents = UriComponentsBuilder.fromPath("/").build(); var resolver = new HateoasSortHandlerMethodArgumentResolver(); - assertThat(resolver.getSortTemplateVariables(null, uriComponents).toString()).isEqualTo("{?sort}"); + assertThat(resolver.getSortTemplateVariables(null, uriComponents).toString()).isEqualTo("{?sort*}"); } @Test // DATACMNS-1752 @@ -65,7 +65,7 @@ void enhanceTemplateVariables(){ UriComponents uriComponents = UriComponentsBuilder.fromPath("/").build(); HateoasSortHandlerMethodArgumentResolver resolver = new HateoasSortHandlerMethodArgumentResolver(); - assertThat(resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString()).isEqualTo("{?sort}"); + assertThat(resolver.enhance(TemplateVariables.NONE, uriComponents, null).toString()).isEqualTo("{?sort*}"); } private void assertUriStringFor(Sort sort, String expected) throws Exception {