spring-projects / spring-projects/spring-data-rest
Path should properly handle Query Parameters [DATAREST-1013]
@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
Ander Ruiz opened DATAREST-1013 and commented
Spring Data REST creates several links while serializing the Resource. I've been able to track to entities that are creating those links:
org.springframework.data.rest.webmvc.mapping.LinkCollector
org.springframework.data.rest.webmvc.mapping.AssociationLinks.getLinksFor()
The problem I'm facing is that "self" links already have a query parameter, in this case something like this:
http://localhost:9000/employees/5?HDIV_STATE=B3555AA7-23-5-C0F5764F5E0D47D3837238A9686D6B2E
When any of those classes handler that resource they try to include additional Links resulting in links like this:
http://localhost:9000/employees/5?HDIV_STATE=B3555AA7-23-5-C0F5764F5E0D47D3837238A9686D6B2E/billableTimes
I was able to replace the first LinkCollector as it is a bean and I used a post processor to replace it so that it handles properly the query parameter. I don't see a way to do the same for the second case.
Ideally I would like to be able to post process every link that is sent to the client, however at least in my opinion org.springframework.data.rest.core.Path should be able to distinguish between path and query parameters when .slash() method is called to create a proper link:
http://localhost:9000/employees/5/billableTimes?HDIV_STATE=B3555AA7-23-5-C0F5764F5E0D47D3837238A9686D6B2E
No further details from DATAREST-1013
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.