-
Notifications
You must be signed in to change notification settings - Fork 890
Open
Labels
extensionRelated to existing and proposed extensions as well as extensions in generalRelated to existing and proposed extensions as well as extensions in general
Description
I'm currently working on an implementation of the Atomic Operations extension on both the server and client-side.
I'm wondering if there is a way for an operation to request the inclusion of related resources in its response? For example, if one of my operations is to create
a resource, can I request the inclusion of resources related to the resource that has just been created?
The spec doesn't appear to say anything about it. I haven't thought about this in a huge amount of detail, but as a starting point, perhaps something like this could be allowed:
POST /operations HTTP/1.1
Host: example.org
Content-Type: application/vnd.api+json;ext="https://jsonapi.org/ext/atomic"
Accept: application/vnd.api+json;ext="https://jsonapi.org/ext/atomic"
{
"atomic:operations": [{
"op": "add",
"href": "/blogPosts?include=author",
"data": {
"type": "articles",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"relationships": {
"author": {
"data": { "type": "users", "id": "1" }
}
}
}
}]
}
Or perhaps it would be better to introduce a new member which could be used in combination with both ref
and href
:
{
"atomic:operations": [{
"op": "add",
- "href": "/blogPosts?include=author",
+ "href": "/blogPosts",
+ "include": ["author"],
"data": {
...
}
}]
}
The response could look like this:
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json;ext="https://jsonapi.org/ext/atomic"
{
"atomic:results": [{
"data": {
"links": {
"self": "http://example.com/blogPosts/13"
},
"type": "articles",
"id": "13",
"attributes": {
"title": "JSON API paints my bikeshed!"
},
"relationships": {
"author": {
"data": { "type": "users", "id": "1" }
}
}
},
"included": [
{
"type": "users",
"id": "1",
"...": "..."
}
]
}]
}
jugaadi
Metadata
Metadata
Assignees
Labels
extensionRelated to existing and proposed extensions as well as extensions in generalRelated to existing and proposed extensions as well as extensions in general