spring-projects / spring-projects/spring-data-rest
Resource root listing links should have templated link to a resource [DATAREST-444]
@odrotbohm is already working on this.
Since Dec 31, 2020.
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Sri opened DATAREST-444 and commented
Currently resource root listing links only lists "self", "previous", "next" and "search" links. However it does not include a template link to a resource with href /resource/\{id\}.
Below is the code snippet that needed to be added to RespositoryEntityController
TemplateVariables variables = new TemplateVariables(new TemplateVariable("id", VariableType.PATH_VARIABLE));
Link resourceItemLink = new Link(new UriTemplate(entityLinks.linkFor(metadata.getDomainType()).withSelfRel().getHref(),
variables), metadata.getItemResourceRel());
links.add(resourceItemLink);
However above code is not a complete fix since the links rendered is not form /resource/\{id\} but rather /resource. This is because TemplateVariables.toString() does not consider TemplateVariable.VariableType.PATH_VARIABLE in buiding the link.
If interested I could submit the patch in github
Affects: 2.2 RC1 (Evans), 2.2 GA (Evans), 2.2.1 (Evans SR1)
Reference URL: http://stackoverflow.com/questions/27845123/resource-root-listing-links-does-not-include-templated-link-to-a-resource
Contributor guide
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.
Assessment
This issue has not been assessed yet.