holidayextras / jsonapi-server

A config driven NodeJS framework implementing json:api and GraphQL
MIT License
488 stars 115 forks source link

Removing a to one relationship using PATCH as to the spec errors out #404

Open PieterJanVdb opened 6 years ago

PieterJanVdb commented 6 years ago

Removing a relationship using PATCH as the spec defines here returns the following error:

"errors": [
  {
    "status": "403",
    "code": "EFORBIDDEN",
    "title": "Request validation failed",
    "detail": "Missing \"data\" - have you sent the right http headers?"
  }
]

This happens because for this route, it checks if the data property of the body is either an object or an array, and errors out otherwise.

However the spec specifies that you can unset a relationship by setting data to null like so:

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

{
  "data": null
}

Is this something that warrants a PR or will no route accept null as the value of data as a rule?