Skip to content
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

No TemplateVariable generated for null Pageable [DATACMNS-1752] #2168

Open
spring-projects-issues opened this issue Jun 23, 2020 · 1 comment · May be fixed by spring-projects/spring-hateoas#1312
Assignees
Labels
in: mapping type: bug

Comments

@spring-projects-issues
Copy link

spring-projects-issues commented Jun 23, 2020

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 spring-projects/spring-hateoas#706

How to fix that?


Affects: 2.3.1 (Neumann SR1)

@reda-alaoui
Copy link
Contributor

reda-alaoui commented Apr 18, 2022

Please note that spring-projects/spring-hateoas#706 can be fixed by applying spring-projects/spring-hateoas#1312 . After that, a pull request inspired by Cosium@b9600b1 fixes the current issue.

reda-alaoui added a commit to Cosium/spring-data-commons that referenced this issue Apr 18, 2022
reda-alaoui added a commit to Cosium/spring-data-commons that referenced this issue Aug 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping type: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants