spring-projects / spring-projects/spring-hateoas

linkTo with inheritance - @PathVariable from parent is ignored

Open
#1,081 1 comment 2 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Jan 12, 2023.

in: core process: waiting for feedback
Dominant language
Java
Stars
1.1k
Forks
476
PR merge metrics
No merged PRs in 30d

Description

Given the following classes, ControllerLinkBuilder.linkTo(methodOn(FooApiImpl.class).getFoo("someId")) ignores the path param.

public interface FooApi {
  @RequestMapping(value = "/foos/{foo-id}", method = RequestMethod.GET)
  ResponseEntity<Foo> getFoo(@PathVariable(value="foo-id") String fooId);
}

@Controller
@RequestMapping("/basePath")
public class FooApiImpl implements FooApi {
  public ResponseEntity<Foo> getFoo(String fooId){
    // ...
  }
}

The generated Link looks like http://localhost:8080/basePath/foos/{foo-id}

If I copy the @PathVariable to the param in FooApiImpl, the link looks like it should: http://localhost:8080/basePath/foos/someId

Calling linkTo on the FooApi class also works, but obviously ignores the basePath from the @RequestMapping from FooApiImpl.

I'm using spring-hateoas 0.25.2.RELEASE.

Contributor guide

No contributing guide indexed for this repository

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.