hateoas

Creating per-request controller/action based formatters in ASP.NET 5

人走茶凉 提交于 2020-05-26 04:20:13
问题 I'm trying to implement HATEOAS in my ASP rest API, changing the ReferenceResolverProvider . The problem is, that depending on which controller I use, I'd like to use different ReferenceResolvers , because I need to behave differently for each Controller. Now I have universal options: services.AddMvc() .AddJsonOptions(option => option.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver()) .AddJsonOptions(options => options.SerializerSettings

Consuming Spring Hateoas Pageable

烂漫一生 提交于 2020-02-20 08:21:47
问题 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",

Consuming Spring Hateoas Pageable

有些话、适合烂在心里 提交于 2020-02-20 08:19:08
问题 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",

JSON Hypermedia Api with forms and links

无人久伴 提交于 2020-01-10 07:58:08
问题 I am in the early stages of planning a REST api, and I would like for it to adhere to the HATEOAS constraint of REST. But I would also like to provide a JSON format. So my question is if there are conventions out there to represent links and forms in JSON. I have found examples of links, and it looks like this is a pretty common way of representing links: "links": [ {"rel": "self", "href":"http://example.org/entity/1"}, {"rel": "friends", "href":"http://example.org/entity/1/friends"}]

Spring-Hateoas: exception in creating a new link

二次信任 提交于 2020-01-04 05:35:13
问题 Overview: I am going to add a new link based on Spring-Hateoas-Doc to the JSON response by using the following command: linkTo(methodOn(ProductRepository.class).findOne(10L)).withRel("product"); Problem: However I got the following exception: java.lang.IllegalArgumentException: 'uriTemplate' must not be null So I would be grateful if anyone could suggest me a genuine solution. 回答1: I found the issue. As I my processor class is not a rest controller, this issue has been raised. To solve it , I

REST API - How to query for links discovery?

老子叫甜甜 提交于 2019-12-24 00:24:42
问题 Suppose I have a RESTful HATEOAS API which has /posts endpoint which lists posts with a query shortcut /posts/new . How do I query the API to discover /posts/new ? My ideas: 1) Query /posts and get links from _links attribute (and the entities listed are necessary overhead): GET /posts { "docs": [ ... ] "_links": { "new": { "rel": "posts", "href": "/posts/new" } } } 2) Provide this in the API root together with list of resources: GET / { "resources": { "posts": { "_links": { "self": { "rel":

Embed object instead of collection in Spring HATEOAS

一世执手 提交于 2019-12-24 00:12:46
问题 A very quick question ,to which there seems to be no easy answer. Is it possible to put an object directly under the embedded resources using Spring HATEOAS? The desired output format in JSON should look like { ... _embedded: { myObject: { ... } } } Using the code below, I always end up with a colletion for any resource I want to embed. ArrayList<Resource<?>> embeddedContent = new ArrayList<>(); Resource<MyObject> myObjectResource = new Resource<MyObject>(new MyObject()); embeddedContent.add

HATEOAS and forms driven by the API

半城伤御伤魂 提交于 2019-12-23 12:26:54
问题 I'm trying to apply HATEOAS to the existing application and I'm having trouble with modeling a form inputs that would be driven by the API response. The app is allowing to search & book connections between two places. First endpoint allows for searching the connections GET /connections?from={lat,lon}&to={lat,lon}&departure={dateTime} and returns following payload (response body). [ { "id": "aaa", "carrier": "Fast Bus", "price": 3.20, "departure": "2019-04-05T12:30" }, { "id": "bbb", "carrier"

spring HATEOAS links issue for HTTP and HTTPS

六月ゝ 毕业季﹏ 提交于 2019-12-22 06:02:23
问题 I am using Spring HATEOAS in my web application. My application runs behind a Nginx webserver. I am sending following url with HTTPS header GET https://national.usa.com/testapp-rest/api/user/654rtrtet-5grt-fgsdf-dfgs-765ytrtsdhshfgsh/newAuthentication Status Code:200 OK Response Headersview sourceAccess-Control-Allow-Headers:x-requested-with, Accept, Content-Type, Origin, Authorization, X-Auth-Token Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE Access-Control-Allow-Origin:*

spring HATEOAS links issue for HTTP and HTTPS

爱⌒轻易说出口 提交于 2019-12-22 06:01:37
问题 I am using Spring HATEOAS in my web application. My application runs behind a Nginx webserver. I am sending following url with HTTPS header GET https://national.usa.com/testapp-rest/api/user/654rtrtet-5grt-fgsdf-dfgs-765ytrtsdhshfgsh/newAuthentication Status Code:200 OK Response Headersview sourceAccess-Control-Allow-Headers:x-requested-with, Accept, Content-Type, Origin, Authorization, X-Auth-Token Access-Control-Allow-Methods:POST, GET, OPTIONS, PUT, DELETE Access-Control-Allow-Origin:*