@@ -48,13 +48,13 @@ then it **MUST** be specified by including its name in the `ext` media type
48
48
parameter with the ` Content-Type ` header. The value of the ` ext ` media type
49
49
parameter ** MUST** be formatted as a comma-separated (U+002C COMMA, ",")
50
50
list of extension names and ** MUST** be limited to a subset of the
51
- extensions supported by the server, which are listed in ` supported-ext `
51
+ extensions supported by the server, which are listed in ` supported-ext `
52
52
of every response.
53
53
54
54
For example: a response that includes the header `Content-Type:
55
55
application/vnd.api+json; ext=ext1,ext2; supported-ext=ext1,ext2,ext3`
56
56
indicates that the response document is formatted according to the
57
- extensions "ext1" and "ext2". Another example: a request that includes
57
+ extensions "ext1" and "ext2". Another example: a request that includes
58
58
the header ` Content-Type: application/vnd.api+json; ext=ext1,ext2 `
59
59
indicates that the request document is formatted according to the
60
60
extensions "ext1" and "ext2".
@@ -295,11 +295,12 @@ document, it **MUST** include resource linkage to those resource objects.
295
295
Resource linkage ** MUST** be represented as one of the following:
296
296
297
297
* ` null ` for empty to-one relationships.
298
- * an object containing ` "type" ` and ` "id" ` members for non-empty to-one
299
- relationships.
298
+ * a "linkage object" (defined below) for non-empty to-one relationships.
300
299
* an empty array (` [] ` ) for empty to-many relationships.
301
- * an array of objects each containing ` "type" ` and ` "id" ` members for non-empty
302
- to-many relationships.
300
+ * an array of linkage objects for non-empty to-many relationships.
301
+
302
+ A "linkage object" is an object that identifies an individual related resource.
303
+ It ** MUST** contain ` type ` and ` id ` members.
303
304
304
305
> Note: Resource linkage in a compound document allows a client to link
305
306
together all of the included resource objects without having to ` GET ` any
@@ -903,11 +904,20 @@ Accept: application/vnd.api+json
903
904
"data": {
904
905
"type": "photos",
905
906
"title": "Ember Hamster",
906
- "src": "http://example.com/images/productivity.png"
907
+ "src": "http://example.com/images/productivity.png",
908
+ "links": {
909
+ "photographer": {
910
+ "linkage": { "type": "people", "id": "9" }
911
+ }
912
+ }
907
913
}
908
914
}
909
915
```
910
916
917
+ If a relationship is provided in the ` links ` section of the resource object, its
918
+ value ** MUST** be a link object with a ` linkage ` member. The value of this key
919
+ represents the linkage the new resource is to have.
920
+
911
921
#### Client-Generated IDs <a href =" #crud-creating-client-ids " id =" crud-creating-client-ids " class =" headerlink " ></a >
912
922
913
923
A server ** MAY** accept a client-generated ID along with a request to create
@@ -1066,13 +1076,11 @@ Accept: application/vnd.api+json
1066
1076
}
1067
1077
```
1068
1078
1069
- #### Updating a Resource's To-One Relationships <a href =" #crud-updating-resource-to-one-relationships " id =" crud-updating-resource-to-one-relationships " class =" headerlink " ></a >
1070
-
1071
- If a to-one relationship is provided in the ` links ` section of a resource
1072
- object in a ` PATCH ` request, its value ** MUST** be either:
1079
+ #### Updating a Resource's Relationships <a href =" #crud-updating-resource-relationships " id =" crud-updating-resource-relationships " class =" headerlink " ></a >
1073
1080
1074
- * an object with ` type ` and ` id ` members corresponding to the related resource
1075
- * ` null ` , to remove the relationship
1081
+ If a relationship is provided in the ` links ` section of a resource object in a
1082
+ ` PATCH ` request, its value ** MUST** be a link object with a ` linkage ` member.
1083
+ The relationship's value will be replaced with the value specified in this member.
1076
1084
1077
1085
For instance, the following ` PATCH ` request will update the ` title ` attribute
1078
1086
and ` author ` relationship of an article:
@@ -1088,22 +1096,15 @@ Accept: application/vnd.api+json
1088
1096
"id": "1",
1089
1097
"title": "Rails is a Melting Pot",
1090
1098
"links": {
1091
- "author": { "type": "people", "id": "1" }
1099
+ "author": {
1100
+ "linkage": { "type": "people", "id": "1" }
1101
+ }
1092
1102
}
1093
1103
}
1094
1104
}
1095
1105
```
1096
1106
1097
- #### Updating a Resource's To-Many Relationships <a href =" #crud-updating-resource-to-many-relationships " id =" crud-updating-resource-to-many-relationships " class =" headerlink " ></a >
1098
-
1099
- If a to-many relationship is included in the ` links ` section of a resource
1100
- object, it ** MUST** be either:
1101
-
1102
- * an array of objects each containing ` type ` and ` id ` members to replace all
1103
- members of the relationship.
1104
- * an empty array (` [] ` ) to clear the relationship.
1105
-
1106
- For instance, the following ` PATCH ` request performs a complete replacement of
1107
+ Likewise, the following ` PATCH ` request performs a complete replacement of
1107
1108
the ` tags ` for an article:
1108
1109
1109
1110
``` text
@@ -1117,10 +1118,12 @@ Accept: application/vnd.api+json
1117
1118
"id": "1",
1118
1119
"title": "Rails is a Melting Pot",
1119
1120
"links": {
1120
- "tags": [
1121
- { "type": "tags", "id": "2" },
1122
- { "type": "tags", "id": "3" }
1123
- ]
1121
+ "tags": {
1122
+ "linkage": [
1123
+ { "type": "tags", "id": "2" },
1124
+ { "type": "tags", "id": "3" }
1125
+ ]
1126
+ }
1124
1127
}
1125
1128
}
1126
1129
}
@@ -1131,9 +1134,9 @@ relationship. In such a case, the server **MUST** reject the entire update,
1131
1134
and return a ` 403 Forbidden ` response.
1132
1135
1133
1136
> Note: Since full replacement may be a very dangerous operation, a server
1134
- may choose to disallow it. A server may reject full replacement if it has
1135
- not provided the client with the full list of associated objects, and does
1136
- not want to allow deletion of records the client has not seen.
1137
+ may choose to disallow it. For example, a server may reject full replacement if
1138
+ it has not provided the client with the full list of associated objects, and
1139
+ does not want to allow deletion of records the client has not seen.
1137
1140
1138
1141
#### Responses <a href =" #crud-updating-responses " id =" crud-updating-responses " class =" headerlink " ></a >
1139
1142
@@ -1209,7 +1212,7 @@ described below.
1209
1212
The ` PATCH ` request ** MUST** include a top-level member named ` data ` containing
1210
1213
one of:
1211
1214
1212
- * an object with ` type ` and ` id ` members corresponding to the related resource.
1215
+ * a linkage object (defined above) corresponding to the new related resource.
1213
1216
* ` null ` , to remove the relationship.
1214
1217
1215
1218
For example, the following request updates the author of an article:
@@ -1245,8 +1248,7 @@ A server **MUST** respond to `PATCH`, `POST`, and `DELETE` requests to a
1245
1248
* to-many relationship URL* as described below.
1246
1249
1247
1250
For all request types, the body ** MUST** contain a ` data ` member whose value
1248
- is an object that contains ` type ` and ` id ` members, or an array of objects
1249
- that each contain ` type ` and ` id ` members.
1251
+ is an empty array or an array of linkage objects.
1250
1252
1251
1253
If a client makes a ` PATCH ` request to a * to-many relationship URL* , the
1252
1254
server ** MUST** either completely replace every member of the relationship,
0 commit comments