spring-projects / spring-projects/spring-hateoas
Pageable not generated when link to method with Pageable param
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.1k
- Forks
- 476
- PR merge metrics
- No merged PRs in 30d
Description
Given
Spring boot starter 2.0.1.RELEASE with hateoas, data-jpa
@SpringBootApplication
@EnableSpringDataWebSupport
public class Application { //}
@Component
public class PersonPublicReleaseAssembler extends ResourceAssemblerSupport<PersonPublicRelease, PersonPublicReleaseResource> {
@Override
public PersonPublicReleaseResource toResource(PersonPublicRelease personPublicRelease) {
/..........
personPublicReleaseResource.add(links);
return personPublicReleaseResource;
}
}
@Autowired
PagedResourcesAssembler<PersonPublicRelease> assembler;
@GetMapping("/search/finadAllWithPagnation")
public ResponseEntity<PagedResources<PersonPublicReleaseResource>> findAllWithPagnation(@PageableDefault Pageable pageable) {
Page<PersonPublicRelease> collection = personPublicReleaseRepository.findAll(pageable);
return ResponseEntity.ok(assembler.toResource(collection, new PersonPublicReleaseAssembler()));
}
Link to findAllWithPagnation() in search mapping(below)
@GetMapping("/search")
public ResponseEntity<ResourceSupport> getSearch() {
ResourceSupport resourceSupport = new ResourceSupport();
Link pageLink = linkTo(methodOn(PersonPublicReleaseController.class)
.findAllWithPagnation(null)).withRel("findAllByPagnation");
// Assemble the resource with links
resourceSupport.add(pageLink );
return ResponseEntity.ok(resourceSupport);
}
Self link returned in the finallAll gets generated fine with first, next, last etc, however
/search would render
{"_links":{"finadAllWithPagnation":{"href":"http://localhost:8080/edw-rest/api/personpr/search/finadAllWithPagnation"}}}
Was Expecting
{"_links":{"finadAllWithPagnation":{"href":"http://localhost:8080/edw-rest/api/personpr/search/finadAllWithPagnation{?page,size,sort}"}}}
Contributor guide
No contributing guide indexed for this repository
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.
Research direction
Reproduce the example with Spring HATEOAS using the linkTo(methodOn(...).findAllWithPagnation(null)) entry point and compare it with the links generated by PagedResourcesAssembler. Trace how the Pageable parameter is handled when the method link is created. Done means the /search link includes the expected {?page,size,sort} template without breaking the existing pagination links.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100