spring-hateoas

Difference between Swagger & HATEOAS

♀尐吖头ヾ 提交于 2019-11-28 09:44:55
问题 Can anyone explain difference between Swagger & HATEOAS. I can Search many time but no buddy can explain the proper detailed answer this two aspects. 回答1: The main difference between Swagger and HATEOAS IMO, which is not covered in the accepted answer, is, that Swagger is only needed for RPC'esque APIs. Such APIs, however, have actually hardly anything to do with REST. There is a further, widespread misconception that anything exchanged via HTTP is automatically RESTful (~ in accordance with

Different JSON output when using custom json serializer in Spring Data Rest

╄→尐↘猪︶ㄣ 提交于 2019-11-28 08:31:28
After adding a custom Jackson serializer based on the official documenation I've observed a slightly different json output format. This example is based on a fork of spring-restbucks . Extend org.springsource.restbucks.WebConfiguration from RepositoryRestMvcConfiguration and override configureJacksonObjectMapper : @Override protected void configureJacksonObjectMapper(ObjectMapper objectMapper) { final SimpleSerializers serializers = new SimpleSerializers(); serializers.addSerializer(Order.class, new OrderSerializer()); objectMapper.registerModule(new SimpleModule("CustomSerializerModule"){

Spring Data Rest Without HATEOAS

主宰稳场 提交于 2019-11-28 08:24:48
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 stores are set up such that the json returned is just a straight array of items, without all the links and things like that. Does anyone know how to configure this with java config so that I get all the mvc code written for me, but without all the HATEOAS stuff? After reading Oliver's comment (which I agree with) and you still want to remove HATEOAS from

Spring Data REST URI vs. entity ID

爱⌒轻易说出口 提交于 2019-11-28 07:36:41
问题 Spring Data REST (and Spring HATEOAS in particular) decouples RESTful IDs (viz., URIs) from entity IDs, and I'm having trouble linking them back up when saving new objects. See the interesting discussion around this decoupling at https://github.com/SpringSource/spring-data-rest/issues/13. Suppose that a client app wants to create a new Ticket resource with an associated TicketCategory resource. I want to post the Ticket against a remote Spring Data REST endpoint. The Ticket doesn't yet have

Spring Data REST - Consume List of Entities, Java HATEOAS client

╄→尐↘猪︶ㄣ 提交于 2019-11-28 04:58:25
问题 I'm using Spring Data REST 2.5.1, Jackson 2.8.0, Spring Boot 1.3.6. I'm trying to retrieve a simple list of entities from my Repository via RestTemplate. I can hit the end point in a browser, and get the expected HAL data. Retrieving a single Entity works fine as below. These are all using the default SDR endpoints (e.g. localhost:{port}/myEntity). ResponseEntity<Resource<MyEntity>> responseEntity = new RestTemplate() .exchange( uri + "/1", HttpMethod.GET, HttpEntity.EMPTY, new

Spring Data REST custom query integration

我的未来我决定 提交于 2019-11-28 04:12:09
I want to create a REST link for an Employee entity that will basically be a findByAllFields query. Of course this should be combined with Page and Sort . In order to do that I have implemented the following code: @Entity public class Employee extends Persistable<Long> { @Column private String firstName; @Column private String lastName; @Column private String age; @Column @Temporal(TemporalType.TIMESTAMP) private Date hiringDate; } So I would like to have lets say a query where I can do: http://localhost:8080/myApp/employees/search/all?firstName=me&lastName=self&ageFrom=20&ageTo=30

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

梦想的初衷 提交于 2019-11-28 03:42:34
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 records and so forth. Is that possible and if yes how? And directly related to that can I define the mapping of property names? Eg. meaning I would need define how the paging info properties are named in JSON (differently than in page). Is this possible and how? Oliver Drotbohm There's support for a scenario like this upcoming in Spring HATEOAS and

Spring HATEOAS embedded resource support

自闭症网瘾萝莉.ら 提交于 2019-11-28 03:27:46
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 provide an example how to use Spring HATEOAS to include embedded resources? linqu Make sure to read Spring's documentation about HATEOAS , it helps to get the basics. In this answer a core developer points out the concept of Resource , Resources and PagedResources , something essential which is is not covered by the documentation. It took me some time

When to use @RestController vs @RepositoryRestResource

半城伤御伤魂 提交于 2019-11-28 03:26:23
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 @RepositoryRestResource within a Repository The thing I am struggling to find is why would you use one over the other. When trying to implement HAL which is best? Our database backend is Neo4j . zpontikas Ok, so the short story is that you want to use the @RepositoryRestResource since this creates a HATEOAS service with Spring JPA . As you can see here adding this

Resolving entity URI in custom controller (Spring HATEOAS)

南楼画角 提交于 2019-11-27 23:30:15
问题 I have a project based on spring-data-rest and also it has some custom endpoints. For sending POST data I'm using json like { "action": "REMOVE", "customer": "http://localhost:8080/api/rest/customers/7" } That is fine for spring-data-rest, but does not work with a custom controller. for example: public class Action { public ActionType action; public Customer customer; } @RestController public class ActionController(){ @Autowired private ActionService actionService; @RestController public