Questions tagged [spring-hateoas]

Spring HATEOAS provides some APIs to ease creating REST representations that follow the HATEOAS principle when working with Spring and especially Spring MVC. The core problem it tries to address is link creation and representation assembly.

HATEOAS (Hypertext As The Engine of Application State)

Resources

Clarification by Roy Fielding that HATEOAS is required for REST.

Building REST services with Spring explains what HATEOAS is, why it is required for REST and how to implement it using Spring MVC and Spring HATEOAS.

779 questions
97
votes
4 answers

When to use @RestController vs @RepositoryRestResource

I have been looking at various examples of how to use Spring with REST. Our end target is a Spring HATEOAS/HAL setup I have seen two distinct methods for rendering REST within Spring Via @RestController within a Controller Via…
code
  • 4,073
  • 3
  • 27
  • 47
63
votes
2 answers

Using spring HATEOAS with spring webflux Functional Web Framework (reactor-netty)

Can we use spring HATEOAS on top of RouterFunction ? I imagine that we can specify the resource but what will be the equivalent of the linkto(Controller.class) ? or is there any equivalent to specify the link and use composition of RouterFunction
hba
  • 751
  • 6
  • 4
54
votes
8 answers

Spring HATEOAS embedded resource support

I want to use the HAL format for my REST API to include embedded resources. I'm using Spring HATEOAS for my APIs and Spring HATEOAS seems to support embedded resources; however, there's no documentation or example on how to use this. Can someone…
Glide
  • 20,235
  • 26
  • 86
  • 135
46
votes
3 answers

Spring HATEOAS versus Spring Data Rest

Question is, what's the difference between Spring HATEOAS versus Spring Data Rest ? I feel both can do the same, and Spring Data Rest (as part of Spring Data) seems a bit more…
HighTML
  • 613
  • 1
  • 6
  • 12
45
votes
3 answers

How to correctly use PagedResourcesAssembler from Spring Data?

I'm using Spring 4.0.0.RELEASE, Spring Data Commons 1.7.0.M1, Spring Hateoas 0.8.0.RELEASE My resource is a simple POJO: public class UserResource extends ResourceSupport { ... } My resource assembler converts User objects to UserResource…
Benjamin M
  • 23,599
  • 32
  • 121
  • 201
44
votes
1 answer

Meaning and usage of "_embedded" in HATEOAS

I'm using Spring Data REST, which supports HATEOAS. I'm new to this paradigm. In GET responses from my RESTful web service I often receive results inside a node named _embedded. I'm wondering: what is _embedded node for? Is it part of REST…
bluish
  • 26,356
  • 27
  • 122
  • 180
41
votes
16 answers

Why HATEOAS starts creating issue for spring-boot version >= 2.2.x during startup with Swagger 2.x?

I moved my project from spring-boot 2.1.9 to 2.2.0. While starting the project, I am facing the below error messages. Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type…
VIJ
  • 1,516
  • 1
  • 18
  • 34
38
votes
4 answers

Date format in the json output using spring boot

I am working on spring boot for creating a REST application. And I have a DTO as shown below: public class Subject { private String uid; private String number; private String initials; private Date dateOfBirth; And I use Spring-Hateos and the…
Pramod
  • 731
  • 2
  • 10
  • 24
30
votes
2 answers

Spring Data Rest Without HATEOAS

I really like all the boilerplate code Spring Data Rest writes for you, but I'd rather have just a 'regular?' REST server without all the HATEOAS stuff. The main reason is that I use Dojo Toolkit on the client side, and all of its widgets and…
Matt
  • 823
  • 1
  • 8
  • 17
29
votes
2 answers

Custom response for root request int the Spring REST HATEOAS with both RepositoryRestResource-s and regular controllers

Let's say I have two repositories: @RepositoryRestResource(collectionResourceRel = "person", path = "person") public interface PersonRepository extends PagingAndSortingRepository { List findByLastName(@Param("name") String…
jcoig
  • 303
  • 1
  • 4
  • 8
28
votes
1 answer

Spring server.forward-headers-strategy NATIVE vs FRAMEWORK

I recently upgraded spring boot from 1.x to 2.y and was facing this issue where hateoas links were generated with http scheme instead of https. Later I discovered that with spring boot 2.2+, it is mandatory to use the following…
Arun Gowda
  • 2,721
  • 5
  • 29
  • 50
28
votes
7 answers

How to remove the "_embedded" property in Spring HATEOAS

I'm using Spring Boot and HATEOAS to build a REST API and when my API returns a collection, it is wrapped inside a "_embedded" property, like so: { "_links":{ "self":{ "href":"http://localhost:8080/technologies" } }, …
jose_p
  • 624
  • 1
  • 8
  • 12
27
votes
3 answers

Can I make a custom controller mirror the formatting of Spring-Data-Rest / Spring-Hateoas generated classes?

I'm trying to do something I think should be really simple. I have a Question object, setup with spring-boot, spring-data-rest and spring-hateoas. All the basics work fine. I would like to add a custom controller that returns a List in…
JBCP
  • 13,109
  • 9
  • 73
  • 111
26
votes
3 answers

Spring MVC 3: return a Spring-Data Page as JSON

I have a data access layer made with Spring-Data. I'm now creating a web application on top of it. This one controller method should return a Spring-Data Page formatted as JSON. Such a Page is a List with additional Paging info like total amount of…
beginner_
  • 7,230
  • 18
  • 70
  • 127
25
votes
2 answers

How do I avoid n+1 queries with Spring Data Rest?

Question. How do I avoid n+1 queries with Spring Data REST? Background. When querying Spring Data REST for a list of resources, each of the resulting top-level resources has links to the associated resources, as opposed to having the associated…
user41871
1
2 3
51 52