spring-projects / spring-projects/spring-data-rest

Resource root listing links should have templated link to a resource [DATAREST-444]

Open
#823 0 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

type: enhancement
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

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.