spring-projects / spring-projects/spring-data-commons

No TemplateVariable generated for null Pageable [DATACMNS-1752]

Open
#2,168 1 comment 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 30, 2020.

in: mapping type: bug
Dominant language
Java
Stars
838
Forks
730
PR merge metrics
No merged PRs in 30d

Description

Réda Housni Alaoui opened DATACMNS-1752 and commented

We use:

  • Spring Data Commons 2.3.0
  • Spring Data JPA 2.3.0
  • Spring HATEOAS 1.1.0

HateoasPageableHandlerMethodArgumentResolver is registered in the Spring context.

Given the following controller:

 @Controller
  @RequestMapping("/")
  public static class MyController {

    private final WebMvcLinkBuilderFactory webMvcLinkBuilderFactory;

    public MyController(WebMvcLinkBuilderFactory webMvcLinkBuilderFactory) {
      this.webMvcLinkBuilderFactory = webMvcLinkBuilderFactory;
    }

    @GetMapping
    public ResponseEntity<?> links() {
      return ResponseEntity.ok(
          new RepresentationModel<>(
              Collections.singletonList(
                  webMvcLinkBuilderFactory
                      .linkTo(methodOn(MyController.class).pageable(null))
                      .withRel("pageable"))));
    }

    @GetMapping("/pageable")
    public ResponseEntity<?> pageable(Pageable pageable) {
      return ResponseEntity.noContent().build();
    }
}

Querying / with accept: application/hal+json produces:

{
  "_links": {
    "pageable": {
      "href": "http://localhost/pageable"
    }
  }
}

We were expecting the link to be templated with the following optional variables:

  • page
  • size

The issue on the Spring HATEOAS side is https://github.com/spring-projects/spring-hateoas/issues/706

How to fix that?


Affects: 2.3.1 (Neumann SR1)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.