Skip to content

Commit c1b320f

Browse files
author
Tyler Kellen
committed
reserve attributes in top level of resource object
This walls off implementation specific keys for resource objects under the namespace `attributes`. With this adjustment, all top level members of resource objects are reserved by JSON-API. This greatly improves our ability make additive changes that fit with the current style of the specification in a post 1.0 world. This proposal was met with wide acceptance by implementors in both #573 and #588.
1 parent e646bd9 commit c1b320f

File tree

4 files changed

+143
-80
lines changed

4 files changed

+143
-80
lines changed

extensions/bulk/index.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,16 @@ Accept: application/vnd.api+json; ext=bulk
4040
{
4141
"data": [{
4242
"type": "photos",
43-
"title": "Ember Hamster",
44-
"src": "http://example.com/images/productivity.png"
43+
"attributes": {
44+
"title": "Ember Hamster",
45+
"src": "http://example.com/images/productivity.png"
46+
}
4547
}, {
4648
"type": "photos",
47-
"title": "Mustaches on a Stick",
48-
"src": "http://example.com/images/mustaches.png"
49+
"attributes": {
50+
"title": "Mustaches on a Stick",
51+
"src": "http://example.com/images/mustaches.png"
52+
}
4953
}]
5054
}
5155
```
@@ -69,11 +73,15 @@ Accept: application/vnd.api+json; ext=bulk
6973
"data": [{
7074
"type": "articles",
7175
"id": "1",
72-
"title": "To TDD or Not"
76+
"attributes": {
77+
"title": "To TDD or Not"
78+
}
7379
}, {
7480
"type": "articles",
7581
"id": "2",
76-
"title": "LOL Engineering"
82+
"attributes": {
83+
"title": "LOL Engineering"
84+
}
7785
}]
7886
}
7987
```

extensions/jsonpatch/index.md

Lines changed: 32 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,10 @@ Accept: application/vnd.api+json; ext=jsonpatch
5858
"path": "/-",
5959
"value": {
6060
"type": "photos",
61-
"title": "Ember Hamster",
62-
"src": "http://example.com/images/productivity.png"
61+
"attributes": {
62+
"title": "Ember Hamster",
63+
"src": "http://example.com/images/productivity.png"
64+
}
6365
}
6466
}
6567
]
@@ -130,7 +132,7 @@ A server **MUST** respond to Patch operations that target a *to-many
130132
relationship URL* as described below.
131133

132134
For all operations, the `"value"` **MUST** contain an object that contains
133-
an array of linkage objects or an empty array, to remove all elements
135+
an array of linkage objects or an empty array, to remove all elements
134136
of the relationship.
135137

136138
If a client requests a `"replace"` operation to a *to-many relationship URL*, the
@@ -147,12 +149,12 @@ Content-Type: application/vnd.api+json; ext=jsonpatch
147149
Accept: application/vnd.api+json; ext=jsonpatch
148150
149151
[
150-
{
151-
"op": "replace",
152-
"path": "",
152+
{
153+
"op": "replace",
154+
"path": "",
153155
"value": [
154-
{ "type": "tags", "id": "2" },
155-
{ "type": "tags", "id": "3" }
156+
{ "type": "tags", "id": "2" },
157+
{ "type": "tags", "id": "3" }
156158
]
157159
}
158160
]
@@ -171,9 +173,9 @@ Content-Type: application/vnd.api+json; ext=jsonpatch
171173
Accept: application/vnd.api+json; ext=jsonpatch
172174
173175
[
174-
{
175-
"op": "add",
176-
"path": "/-",
176+
{
177+
"op": "add",
178+
"path": "/-",
177179
"value": [
178180
{ "type": "comments", "id": "123" }
179181
]
@@ -193,9 +195,9 @@ Content-Type: application/vnd.api+json; ext=jsonpatch
193195
Accept: application/vnd.api+json; ext=jsonpatch
194196
195197
[
196-
{
197-
"op": "remove",
198-
"path": "",
198+
{
199+
"op": "remove",
200+
"path": "",
199201
"value": [
200202
{ "type": "comments", "id": "5" },
201203
{ "type": "comments", "id": "13" }
@@ -255,17 +257,21 @@ Accept: application/vnd.api+json; ext=jsonpatch
255257
"path": "/-",
256258
"value": {
257259
"type": "photos",
258-
"title": "Ember Hamster",
259-
"src": "http://example.com/images/productivity.png"
260+
"attributes": {
261+
"title": "Ember Hamster",
262+
"src": "http://example.com/images/productivity.png"
263+
}
260264
}
261265
},
262266
{
263267
"op": "add",
264268
"path": "/-",
265269
"value": {
266270
"type": "photos",
267-
"title": "Mustaches on a Stick",
268-
"src": "http://example.com/images/mustaches.png"
271+
"attributes": {
272+
"title": "Mustaches on a Stick",
273+
"src": "http://example.com/images/mustaches.png"
274+
}
269275
}
270276
}
271277
]
@@ -283,15 +289,19 @@ Content-Type: application/vnd.api+json; ext=jsonpatch
283289
"data": [{
284290
"type": "photos",
285291
"id": "123",
286-
"title": "Ember Hamster",
287-
"src": "http://example.com/images/productivity.png"
292+
"attributes": {
293+
"title": "Ember Hamster",
294+
"src": "http://example.com/images/productivity.png"
295+
}
288296
}]
289297
}, {
290298
"data": [{
291299
"type": "photos",
292300
"id": "124",
293-
"title": "Mustaches on a Stick",
294-
"src": "http://example.com/images/mustaches.png"
301+
"attributes": {
302+
"title": "Mustaches on a Stick",
303+
"src": "http://example.com/images/mustaches.png"
304+
}
295305
}]
296306
}
297307
]

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy