spring-projects / spring-projects/spring-data-rest
Wrong pagination links when baseURI() is set [DATAREST-191]
Open
@odrotbohm is already working on this.
Since Dec 31, 2020.
status: feedback-provided
type: bug
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Sri opened DATAREST-191 and commented
Setting baseURI() fails to generate proper pagination links
@Override
protected void configureRepositoryRestConfiguration(
try {
URI base = new URI("/api/v1");
if (base != null) {
config.setBaseUri();
}
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
With about setting I see pagination links as
"links": [
{
"rel": "next",
"href": "http://localhost:8080/dc/employees?page=1&size=20"
},
{
"rel": "search",
"href": "/api/vi/employees/search"
}
],
However digging in code found that PagedResourcesAssembler has its baseURI, so tried to override it as
@Override
@Bean
public PagedResourcesAssembler<Object> pagedResourcesAssembler() {
UriComponents uriComponents = null;
try {
uriComponents = baseURI() == null ? null : UriComponentsBuilder
.fromUri(baseURI()).build();
} catch (URISyntaxException e) {
e.printStackTrace();
}
return new PagedResourcesAssembler<Object>(pageableResolver(),
uriComponents);
}
but this didn't help either...
"links": [
{
"rel": "next",
"href": "/api/vi/?page=1&size=20"
},
{
"rel": "search",
"href": "/api/vi/employees/search"
}
]
Affects: 2.0 M1 (Codd)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.