spring-hateoas

Consuming Spring Hateoas Pageable

醉酒当歌 提交于 2019-12-04 07:12:11
I have a Rest-Service using HAteoas, what worked before without pageing. Now I am producing pageable Json. I did it with out-of-the box features from Spring-Hateoas. But now I am stucking consuming it and I guess it is really not well documented, if it is. My JSON looks like follows: { "_embedded": { "vertragResourceList": [ { "identifier": 728, "auszubildender": "Rumm", "beruf": "Landwirt/in", "betrieb": "Mitterbauer Johann", "betriebsNummer": "e12d0949-67ae-4134-9dc2-fb67758b6b16", "zustaendigeStelle": "Irgendwo", "beginn": 529887600000, "status": "RECENT", "fachrichtung": null, "schwerpunkt

How do I avoid content fields in Joda objects?

淺唱寂寞╮ 提交于 2019-12-04 04:21:20
问题 I'm using Joda objects (DateTime and DateTimeZone) in a document and whenever I access it via the REST interface I get entries with fields like this lastAggregationDate: { content: "2016-07-12T17:58:43.643Z" } instead of lastAggregationDate: "2016-07-12T17:58:43.643Z" I have the Joda Jackson dependencies declared and I see the de/serializers for these types so I'm puzzled as to what's at work here. I've duplicated this behavior in a slightly modified Spring sample project but using Java's

Spring HATEOAS versus Spring Data Rest

醉酒当歌 提交于 2019-12-03 18:22:11
问题 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 alive. https://github.com/spring-projects/spring-hateoas https://github.com/spring-projects/spring-data-rest When would you use one or the other? 回答1: Spring HATEOAS provides common abstractions (representational models, a Link class, API to build links pointing to Spring MVC controllers, etc.) to ease building

Spring Data Rest - Add link to search endpoint

假如想象 提交于 2019-12-03 15:39:29
In our Spring-Data-Rest Project we have a custom (fuzzy) search on a /buergers/search/findBuergerFuzzy?searchString="..." endpoint. Is it possible to add a link for it on the /buergers/search endpoint (Without overriding the automatically exposed Repository findBy Methods)? The Controller exposing the search: @BasePathAwareController @RequestMapping("/buergers/search/") public class BuergerSearchController { @Autowired QueryService service; @RequestMapping(value = "/findBuergerFuzzy", method = RequestMethod.GET) public @ResponseBody ResponseEntity<?> findBuergerFuzzy

Spring Data Rest / Spring Hateoas Custom Controller - PersistentEntityResourceAssembler

南楼画角 提交于 2019-12-03 15:04:29
I'm attempting to add some additional business logic to the auto-generated endpoints from the RepositoryRestResource. Please see the code below: Resource: @RepositoryRestResource(collectionResourceRel="event", path="event") public interface EventRepository extends PagingAndSortingRepository<Event, Long> { } Controller: @RepositoryRestController @RequestMapping(value = "/event") public class EventController { @Autowired private EventRepository eventRepository; @Autowired private PagedResourcesAssembler<Event> pagedResourcesAssembler; @RequestMapping(method = RequestMethod.GET, value = "")

Document HAL “_links” from Spring Hateoas (with swagger)? [closed]

狂风中的少年 提交于 2019-12-03 12:01:52
I have a REST service I want to document for my client developing team. So I added some Links from Spring-Hateoas to my resources API, and plugged into it swagger-springmvc @Api... annotations to document everything and make a good API reference for my Angular team to be able to understand my REST service. The problem is that swagger is unable to discover what links are possible, and just give me a big array of Links without saying their possible values. Here is a (simple) example. Swagger detects : Model Schema CollectionListResource { collections (array[CollectionResource]): All available

Meaning and usage of “_embedded” in HATEOAS

扶醉桌前 提交于 2019-12-03 11:47:12
问题 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 specification? Or part of HATEOAS specification? Or is it specific for the Spring implementation of them? This is an example of JSON result for GET http://localhost:8080/mywebservice/features : { "_links": { "search": { "href": "http://localhost:8080

Spring HATEOAS ControllerLinkBuilder methodOn increasing response times significantly

…衆ロ難τιáo~ 提交于 2019-12-03 10:17:24
问题 The setup: So I have a RESTfull API written in java, using spring-boot and spring-hates for adding links to the resource (Hypermedia-Driven RESTful Web Service). Everything I have is standard and no additional settings or changes are made The problem Case: no links on resource - Chrome TTFB avg. (10 runs) 400ms for 1000 items Case: 1 self reference link on resource - Chrome TTFB avg. (10 runs) 1500ms for 1000 items I am using this official guide The question Why adding only 1 link to my

Filling entity links in custom @RepositoryRestController methods

痴心易碎 提交于 2019-12-03 07:50:02
问题 I am using Spring-data-rest to provide read APIs over some JPA entities. For writes I need to issue Command objects rather than directly write to the DB, so I added a custom controller using @RepositoryRestController and various command handling methods: @RequestMapping(method = RequestMethod.POST) public @ResponseBody MyEntity post(@RequestBody MyEntity entity) { String createdId = commands.sendAndWait(new MyCreateCommand(entity)); return repo.findOne(createdId); } I would like the output to

Spring Data Rest PUT v.s PATCH LinkableResources

人盡茶涼 提交于 2019-12-03 06:59:29
I'm using Spring Data REST to expose my Entity's and their relationships. I have a OneToOne relationship between two Entity's and I'm trying to update/change the relationship with PUT and PATCH. I noticed that Spring Data REST will only allow you to update linked resources - JPA mapped Entity's (OneToMany, ManyToOne, etc) which are also AggregateRoots (has a Repository) - via a PATCH and are ignored with a PUT . This can be seen in the LinkedAssociationSkippingAssociationHandler class: if (associationLinks.isLinkableAssociation(association)) { return; } Why is this? What is the reasoning