FriendsOfCake / crud-json-api

Build advanced JSON API Servers with almost no code.
https://crud-json-api.readthedocs.io/
MIT License
56 stars 32 forks source link

Support for relationships urls #121

Closed geoidesic closed 4 years ago

geoidesic commented 4 years ago

The JSONAPI spec allows for PATCH, POST and DELETE of URLs of the format {controller}/{id}/relationships/{foreignTable}

Allowing relationships to be added, altered or deleted.

Crud-json-api doesn't support this yet.

This commit adds support for this. However please note that documentation will need to be updated to reflect config and routing requirements to make this work, since these URLS are not part of Cake's resource RESTful routes format.

Config:

$this->loadComponent('Crud.Crud', [
            'actions' => ['CrudJsonApi.Relationships`]);

Route:

$RouteBuilder->connect('/{controller}/{id}/relationships/{foreignTableName}', ['action' => 'Relationships']);

(Not sure if that route is quite right just yet)

dakota commented 4 years ago

DocumentRelationshipValidator seems to be missing