What is this?

Outline for a complementary REST API to our Restful Objects one, that is targetted at tools such as Angular UI

also:

  • see HAL and Collection+JSON for their latest ideas

NB: I drafted this back in 2014, just recovered the file.  Since that time the RO viewer supports pluggable representations, so what's listed here is somewhat implemented already.

Tools to support:

- angular-ui.github.io/bootstrap

- angular xeditable

Sketch

Assuming:


@RestAlias("todos")
public class ToDoItem {
public String getDescription() { ... }
public void setDescription(String d) { ... }

@Optional
public ToDo getDependsUpon() { ... }
public void setDependsUpon(ToDoItem tdi) { ... }

public Collection<ToDoItem> getRelatedTo() { ... }
}

Object Collection

http://localhost:8080/:objectType

eg: http://localhost:8080/todos

Supports:

  • GET
  • POST

Object Resource

http://localhost:8080/:objectType/:id

eg: http://localhost:8080/todos/4

Supports:

  • GET
  • DELETE
  • POST
  • PUT? or PATCH (but perhaps do put/post should behave like patch)

 

Headers ??:

 

LINK: ...? "relatedTo"

Representation:

{
 "description": "Buy bread",
"status": "notComplete"
"dependUpons": { "id": 3, and eagerly render the other properties of related object too ... }
"dependencies": { "href": "http://...todos/4/dependencies" },
"numberOfDependencies": { "href": "http://...todos/4/numberOfDependencies" } // a scalar
}
 

Or perhaps inline

{ 
"description": "Buy bread",
"status": "notComplete"
"dependUpons": { "id": 3, and eagerly render the other properties of related object too ... }
"dependencies": [ { ... }, { .... }, { ... } ]
}

 

 

B) http://localhost:8080/:objectType/:id/:property GET, PUT, DELETE?


eg: http://localhost:8080/todos/1/description

{ "description": "foo" }


C) http://localhost:8080/:objectType/:id/:collection?offset=:offset&limit=:limit GET

eg: http://localhost:8080/todos/1/dependencies

LINK: next
LINK: prev

[
{ ... },
{ ... },
{ ... }
]

C2) http://localhost:8080/:objectType/:id/:collection POST 200 (put) or 201 (post)


(not mandatory)
D) http://localhost:8080/:objectType/:id/:collection/:id GET, PUT, POST, DELETE

- same repr as (A)


eg: http://localhost:8080/todos/1/dependencies/1

 

D) http://localhost:8080/:objectType/:id/:action GET - prompt info, POST - invoke

eg: http://localhost:8080/todos/1/addAddress


E) http://localhost:8080/:objectType/:id/:action/:actionParamName

eg http://localhost:8080/todos/1/addAddress/location GET

{ id: 123 value: Foo }

 

 

Other ideas:
? perhaps support OPTIONS
~~~~~~

  • No labels