As the title says, I have a resource object Product
extending ResourceSupport
. However, the responses I receive have the property "_links" instead of "links" and have a different structure.
{
"productId" : 1,
"name" : "2",
"_links" : {
"self" : {
"href" : "http://localhost:8080/products/1"
}
}
}
Based on the HATEOAS Reference, the expected is:
{
"productId" : 1,
"name" : "2",
"links" : [
{
"rel" : "self"
"href" : "http://localhost:8080/products/1"
}
]
}
Was this intended? Is there a way to change it, or at leas the "link" if not the structure?
I added the selfLink through the following snippet:
product.add(linkTo(ProductController.class).slash(product.getProductId()).withSelfRel());
I am using spring boot with the following build file:
dependencies {
compile ("org.springframework.boot:spring-boot-starter-data-rest") {
exclude module: "spring-boot-starter-tomcat"
}
compile "org.springframework.boot:spring-boot-starter-data-jpa"
compile "org.springframework.boot:spring-boot-starter-jetty"
compile "org.springframework.boot:spring-boot-starter-actuator"
runtime "org.hsqldb:hsqldb:2.3.2"
testCompile "junit:junit"
}
_links
portion is referenced, in the CurieProvider API. Are you certain you're always supposed to receive links the way you think you are? – Distrust