winery / winery

Eclipse Winery project
http://winery.github.io/winery/
Apache License 2.0
44 stars 66 forks source link

[FR] Winery Responses should contain links #394

Open nyuuyn opened 5 years ago

nyuuyn commented 5 years ago

Every response of the REST API should(/must) return links to subresources etc.

For example:

A GET on http://localhost:8089/winery/servicetemplates/ returns the following JSON:

[
  {
    "id": "MyTinyToDo-MySql_OpenStack-w1-wip1",
    "name": "MyTinyToDo-MySql_OpenStack-w1-wip1",
    "namespace": "http://opentosca.org/servicetemplates",
    "qName": "{http://opentosca.org/servicetemplates}MyTinyToDo-MySql_OpenStack-w1-wip1"
  }
]

So now to get to the example Service Template the user must somehow magically guess how to get there, which is basically a GET to the URL:

http://localhost:8089/winery/servicetemplates/http%3A%2F%2Fopentosca.org%2Fservicetemplates/MyTinyToDo-MySql_OpenStack-w1-wip1

That this is a bit weird from a design perspective, it would be quite nice if the response would look something like this:

[
  {
    "id": "MyTinyToDo-MySql_OpenStack-w1-wip1",
    "name": "MyTinyToDo-MySql_OpenStack-w1-wip1",
    "namespace": "http://opentosca.org/servicetemplates",
    "qName": "{http://opentosca.org/servicetemplates}MyTinyToDo-MySql_OpenStack-w1-wip1",
    "_link" : {
             "href" : "http://localhost:8089/winery/servicetemplates/http%3A%2F%2Fopentosca.org%2Fservicetemplates/MyTinyToDo-MySql_OpenStack-w1-wip1",
             "type" : "self"
          }
  }
]

Atleast with the _link object in the response people could navigate the API based on the responses, which would make the API a bit RESTy.

P.S.: Just whoever may have time to do this, don't forget the application/xml support :)

koppor commented 5 years ago

We started to work on that with https://github.com/mikekelly/hal_specification and http://www.gotohal.net/halbuilder.html (via https://github.com/mikekelly/hal_specification/wiki/Libraries#java) some time ago... Supports JSON and XML ^^.

IMHO the level 3 of REST (Richardson Majurity Model) should be separated from the content itself. WDYT?

nyuuyn commented 5 years ago

IMHO the level 3 of REST (Richardson Majurity Model) should be separated from the content itself.

Seems okay to me, the only question we could think about is, whether we want the API of winery to 'feel' like the OpenTOSCA runtime (which I think we don't?) as the links are within the responses there 💃