Skip to content

Commit de3aff9

Browse files
committed
Introduce Local IDs, or lids, to v1.1
A client may include a "local ID" as a `lid` member in a resource object to uniquely identify the resource within the request document. Every representation of that resource, whether as a resource object or resource identifier object, must then include the matching `lid` member and value. This addition paves the way for requests of all kinds that may need to establish linkage between resources that have not yet been assigned a server-generated ID.
1 parent 26ea2a6 commit de3aff9

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

_format/1.1/index.md

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,10 @@ A resource object **MUST** contain at least the following top-level members:
191191
* `id`
192192
* `type`
193193

194-
Exception: The `id` member is not required when the resource object originates at
195-
the client and represents a new resource to be created on the server.
194+
Exception: The `id` member is not required when the resource object originates
195+
at the client and represents a new resource to be created on the server. In that
196+
case, a client **MAY** include a `lid` member to uniquely identify the resource
197+
by `type` _locally_ within the document.
196198

197199
In addition, a resource object **MAY** contain any of these top-level members:
198200

@@ -228,8 +230,16 @@ Here's how an article (i.e. a resource of type "articles") might appear in a doc
228230

229231
#### <a href="#document-resource-object-identification" id="document-resource-object-identification" class="headerlink"></a> Identification
230232

231-
Every [resource object][resource objects] **MUST** contain an `id` member and a `type` member.
232-
The values of the `id` and `type` members **MUST** be strings.
233+
As noted above, every [resource object][resource objects] **MUST** contain a
234+
`type` member. Every resource object **MUST** also contain an `id` member,
235+
except when the resource object originates at the client and represents a new
236+
resource to be created on the server. If `id` is omitted due to this exception,
237+
a `lid` member **MAY** be included to uniquely identify the resource by `type`
238+
_locally_ within the document. The value of the `lid` member **MUST** be
239+
identical for every representation of the resource in the document, including
240+
[resource identifier objects][resource identifier object].
241+
242+
The values of the `id`, `type`, and `lid` members **MUST** be strings.
233243

234244
Within a given API, each resource object's `type` and `id` pair **MUST**
235245
identify a single, unique resource. (The set of URIs controlled by a server,
@@ -400,7 +410,12 @@ response that includes the resource as the primary data.
400410
A "resource identifier object" is an object that identifies an individual
401411
resource.
402412

403-
A "resource identifier object" **MUST** contain `type` and `id` members.
413+
A "resource identifier object" **MUST** contain a `type` member. It **MUST**
414+
also contain an `id` member, except when it represents a new resource to be
415+
created on the server. In this case, a `lid` member **MUST** be included that
416+
identifies the new resource.
417+
418+
The values of the `id`, `type`, and `lid` members **MUST** be strings.
404419

405420
A "resource identifier object" **MAY** also include a `meta` member, whose value is a [meta] object that
406421
contains non-standard meta-information.
@@ -510,6 +525,10 @@ each `type` and `id` pair.
510525
composite key that uniquely references [resource objects] in another part of
511526
the document.
512527

528+
> Note: For resources that do not contain an `id` member but do contain a `lid`,
529+
the `lid` is sufficient to establish resource identity and thus linkage between
530+
resource objects and resource identifier objects throughout the document.
531+
513532
> Note: This approach ensures that a single canonical [resource object][resource objects] is
514533
returned with each response, even when the same resource is referenced
515534
multiple times.

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