Skip to content

linkTo with inheritance - @PathVariable from parent is ignored #1081

Open
@druppelt

Description

@druppelt

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions