Krzysztof Mazur
Krzysztof Mazur

Reputation: 608

Spring HATEOAS - two same links

lately I've been doing some projekt with Spring Data and Rest with HATEOAS.

My question is, is it normal, that in entity links secion, I have 2 same links?

enter image description here

Here is repository:

Repository

Upvotes: 1

Views: 257

Answers (1)

Marc Tarin
Marc Tarin

Reputation: 3169

Yes it is. But it's not always the case: the 'user' link is actually a templated link that gets enriched in certain cases.

For instance, should you define the following projection:

@Projection(name = "summary", types = { User.class }) 
interface Summary { 

  String getUsername(); 
  String getEmail();

}

then the user link would show the projection parameter:

...
"_links" : {
  "self" : {
    "href" : "http://localhost:8080/users/1"
  },
  "user" : {
    "href" : "http://localhost:8080/users/1{?projection}"
    "templated" : true
  }

And you could be able to get a summary of user 1 by GETting http://localhost:8080/users/1?projection=summary.

Upvotes: 1

Related Questions