@@ -164,6 +164,8 @@ In addition, a resource object **MAY** contain any of these top-level members:
164
164
* ` links ` : a [ links object] [ links ] containing links related to the resource.
165
165
* ` meta ` : a [ meta object] [ meta ] containing non-standard meta-information about a
166
166
resource that can not be represented as an attribute or relationship.
167
+ * ` lid ` : a local identifier that, together with ` type ` , uniquely
168
+ identifies a resource within the document.
167
169
168
170
Here's how an article (i.e. a resource of type "articles") might appear in a document:
169
171
@@ -190,8 +192,18 @@ Here's how an article (i.e. a resource of type "articles") might appear in a doc
190
192
191
193
#### <a href =" #document-resource-object-identification " id =" document-resource-object-identification " class =" headerlink " ></a > Identification
192
194
193
- Every [ resource object] [ resource objects ] ** MUST** contain an ` id ` member and a ` type ` member.
194
- The values of the ` id ` and ` type ` members ** MUST** be strings.
195
+ As noted above, every [ resource object] [ resource objects ] ** MUST** contain a
196
+ ` type ` member. Every resource object ** MUST** also contain an ` id ` member,
197
+ except when the resource object originates at the client and represents a new
198
+ resource to be created on the server. The values of the ` id ` and ` type ` members
199
+ ** MUST** be strings.
200
+
201
+ A [ resource object] [ resource objects ] ** MAY** contain a ` lid ` member that,
202
+ together with ` type ` , uniquely identifies the resource _ locally_ within the
203
+ document. If a [ resource object] [ resource objects ] contains a ` lid ` member, then
204
+ every representation of that resource, including other [ resource objects] and
205
+ [ resource identifier objects] , ** MUST** also contain the ` lid ` member with the
206
+ same value. The value of the ` lid ` member ** MUST** be a string.
195
207
196
208
Within a given API, each resource object's ` type ` and ` id ` pair ** MUST**
197
209
identify a single, unique resource. (The set of URIs controlled by a server,
@@ -360,10 +372,21 @@ response that includes the resource as the primary data.
360
372
A "resource identifier object" is an object that identifies an individual
361
373
resource.
362
374
363
- A "resource identifier object" ** MUST** contain ` type ` and ` id ` members.
375
+ A "resource identifier object" ** MUST** contain a ` type ` member. A resource
376
+ identifier object ** MUST** also contain an ` id ` member, except when it contains
377
+ a ` lid ` that identifies it as matching a new resource to be created on the
378
+ server.
379
+
380
+ A "resource identifier object" ** MAY** contain a ` lid ` member. If ` id ` is
381
+ omitted due to the exception described above, a ` lid ` member ** MUST** be
382
+ included. A ` lid ` member ** MUST** also be included if the referenced resource is
383
+ represented elsewhere in the document with a ` lid ` . The value of a ` lid ` member
384
+ ** MUST** be identical for every representation of the resource in the document.
385
+
386
+ The values of the ` id ` , ` lid ` , and ` type ` members ** MUST** be strings.
364
387
365
- A "resource identifier object" ** MAY** also include a ` meta ` member, whose value is a [ meta ] object that
366
- contains non-standard meta-information.
388
+ A "resource identifier object" ** MAY** also include a ` meta ` member, whose value
389
+ is a [ meta ] object that contains non-standard meta-information.
367
390
368
391
### <a href =" #document-compound-documents " id =" document-compound-documents " class =" headerlink " ></a > Compound Documents
369
392
@@ -470,6 +493,11 @@ each `type` and `id` pair.
470
493
composite key that uniquely references [ resource objects] in another part of
471
494
the document.
472
495
496
+ > Note: For resources that do not contain an ` id ` member but do contain a ` lid ` ,
497
+ the ` type ` and ` lid ` are sufficient to establish resource identity and thus
498
+ linkage between resource objects and resource identifier objects throughout the
499
+ document.
500
+
473
501
> Note: This approach ensures that a single canonical [ resource object] [ resource objects ] is
474
502
returned with each response, even when the same resource is referenced
475
503
multiple times.
@@ -510,7 +538,7 @@ Each member of a links object is a "link". A link **MUST** be represented as
510
538
either:
511
539
512
540
* a string containing the link's URL.
513
- * <a id =" document-links-link-object " ></a >an object ("link object") which can
541
+ * <a id =" document-links-link-object " ></a >an object ("link object") which can
514
542
contain the following members:
515
543
* ` href ` : a string containing the link's URL.
516
544
* ` meta ` : a meta object containing non-standard meta-information about the
@@ -1156,6 +1184,11 @@ also allow existing resources to be modified or deleted.
1156
1184
A request ** MUST** completely succeed or fail (in a single "transaction"). No
1157
1185
partial updates are allowed.
1158
1186
1187
+ If a [ resource object] [ resource objects ] or [ resource identifier object] in a
1188
+ request document includes a ` lid ` member, then the server ** MUST** include the
1189
+ matching ` lid ` member and value in every representation of that resource or
1190
+ resource identifier in the response document.
1191
+
1159
1192
> Note: The ` type ` member is required in every [ resource object] [ resource objects ] throughout requests and
1160
1193
responses in JSON API. There are some cases, such as when ` POST ` ing to an
1161
1194
endpoint representing heterogenous data, when the ` type ` could not be inferred
0 commit comments