alex94cp / jsonapify

Middleware for easy development of JSON-API compatible APIs
Apache License 2.0
62 stars 3 forks source link

JSON Patch spec compliance #9

Open hkosiacki opened 8 years ago

hkosiacki commented 8 years ago

Correct me if I'm wrong, but it seems to me that the modify middleware expects request body in a different form than the one described in the extension specification.

The example from the spec (there is no object wrapping the op array):

[
  { "op": "replace", "path": "/src", "value": "http://example.com/hamster.png" }
]

The way modify expects it:

{
  "data": [
    { "op": "replace", "path": "/attributes/src", "value": "http://example.com/hamster.png" }
  ]
}

As far as I understood, prefixing modified field's path with "/attributes" shouldn't be required, as attributes and relationships cannot have identically named fields. Extension spec also mentions that the request URL and operation's path combined must form a valid path to a collection or a (sub)resource.

alex94cp commented 8 years ago

@hkosiacki You're right. This will be fixed in next version