phramework / jsonapi

jsonapi implementation for phramework
https://phramework.github.io/jsonapi/
Apache License 2.0
4 stars 2 forks source link

Implement support for relationship on PATCH request #21

Closed nohponex closed 8 years ago

nohponex commented 8 years ago

See http://jsonapi.org/format/#crud-updating-resource-relationships

For instance, the following PATCH request will update the author relationship of an article:

PATCH /articles/1 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "articles",
    "id": "1",
    "relationships": {
      "author": {
        "data": { "type": "people", "id": "1" }
      }
    }
  }
}

Likewise, the following PATCH request performs a complete replacement of the tags for an article:

PATCH /articles/1 HTTP/1.1
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
  "data": {
    "type": "articles",
    "id": "1",
    "relationships": {
      "tags": {
        "data": [
          { "type": "tags", "id": "2" },
          { "type": "tags", "id": "3" }
        ]
      }
    }
  }
}
tchronis commented 8 years ago

A bit of code in the preview tab please :-)

nohponex commented 8 years ago

Implemented at 1.0.0-RC2