How to remove hypermedia elements from views created by Spring Data REST?

When using Spring Data for my REST API, the answers currently received include the _links field:

 { "_embedded": { "users": [ { "imageUrl": "some_image_url", "name": "some name", "id": "57420b2a0d31bb6cef4ee8e9", "_links": { "self": { "href": "http://localhost:8080/users/57420b2a0d31bb6cef4ee8e9" }, "user": { "href": "http://localhost:8080/users/57420b2a0d31bb6cef4ee8e9{?projection}", "templated": true } } }, ... 

Is there a way to create output so the _links field _links hidden? eg:.

 { "_embedded": { "users": [ { "imageUrl": "some_image_url", "name": "some name", "id": "57420b2a0d31bb6cef4ee8e9", }, ... 

I find that since I am exposing the id field, _links not needed and basically just clutter up my answers.

+6
source share
1 answer

Not. Hypermedia is a fundamental feature of the REST API, and Spring Data REST makes great use of it so you can create clients that can use the links in the answers to navigate to related resources.

Of course, you can disconnect your clients in order not to use this information, but this will lead to a much tougher connection (since you can no longer change the server-side URIs, your clients expect to talk to a dedicated server, while with hypermedia you can simply point it to another server, etc.).

Unlike many other self-proclaimed REST structures, one of the key aspects of structure design is to respect the fundamental principles in REST and use them explicitly. Or at least don't create incentives to break them down easily. This is clearly expressed in the background documentation and on the project website. Learn more about key design decisions in this presentation in Spring Data REST and in the "Domain Management" and REST sections .

+12
source

All Articles