Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Understanding links generated by Spring Data Rest #2388

Closed
micama opened this issue May 23, 2024 · 1 comment
Closed

[Question] Understanding links generated by Spring Data Rest #2388

micama opened this issue May 23, 2024 · 1 comment
Assignees
Labels
status: invalid An issue that we don't feel is valid

Comments

@micama
Copy link

micama commented May 23, 2024

Hi

This is no issue but rather a question to understand the behaviour of Spring Data Rest.

Let's say I have an entity Person with the respective Repository extending JpaRepository.
When acccessing the API's root URI, e.g.

http://localhost:8080/api

There is a link of the form for the person's resource

{
    "_links": {
        "persons": {
            "href": "http://localhost:8080/api/persons{?page,size,sort}",
            "templated": true
        }
    }
}

How is a client (web frontend or another backend service) supposed to handle the person's href?
Should it be parsed, interpreted, cleaned up?

RESTful APIs are supposed to be self-describing and discoverable. So why is the curly braces part of the link's href?
Should this not just be a valid, addressable URI, without having to parse or extract the actual usable part?
Am I missing something here? How is the discoverability supposed to work here?

Furthermore the information on what is available is already present in the alps description.
There, an interested client can read up on what's possible, etc.

Thanks

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label May 23, 2024
@odrotbohm
Copy link
Member

The format SD REST returns is HAL. Clients would usually use a library that understands that format. The templated field indicates that the href value is a URI template. The variant you show contains optional request parameters, so – again – a library that understands URI templates would know how to expand that template into a traversable URI with parameter values given or not.

Going forward, please use StackOverflow for such general questions. Chances are much higher you find someone answering as it's drawing a much bigger audience than the tracker here.

@odrotbohm odrotbohm added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants