Skip to content

Commit c7c7042

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 c7c7042

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

_format/1.1/index.md

Lines changed: 26 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 each resource
197+
within the document.
196198

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

@@ -228,8 +230,17 @@ 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 that uniquely identifies the resource
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+
other resource objects and [resource identifier objects][resource identifier
241+
object]. The values of `lid` members **MUST** be unique across resource types.
242+
243+
The values of the `id`, `type`, and `lid` members **MUST** be strings.
233244

234245
Within a given API, each resource object's `type` and `id` pair **MUST**
235246
identify a single, unique resource. (The set of URIs controlled by a server,
@@ -400,7 +411,13 @@ response that includes the resource as the primary data.
400411
A "resource identifier object" is an object that identifies an individual
401412
resource.
402413

403-
A "resource identifier object" **MUST** contain `type` and `id` members.
414+
A "resource identifier object" **MUST** contain `type` and `id` members, except
415+
when it represents a new resource to be created on the server. In this case, a
416+
`lid` member **MUST** be included and `type` **MAY** be included. As discussed
417+
above, the value of the `lid` member **MUST** be identical for every
418+
representation of the resource in the document.
419+
420+
The values of the `id`, `type`, and `lid` members **MUST** be strings.
404421

405422
A "resource identifier object" **MAY** also include a `meta` member, whose value is a [meta] object that
406423
contains non-standard meta-information.
@@ -510,6 +527,10 @@ each `type` and `id` pair.
510527
composite key that uniquely references [resource objects] in another part of
511528
the document.
512529

530+
> Note: For resources that do not contain an `id` member but do contain a `lid`,
531+
the `lid` is sufficient to establish resource identity and thus linkage between
532+
resource objects and resource identifier objects throughout the document.
533+
513534
> Note: This approach ensures that a single canonical [resource object][resource objects] is
514535
returned with each response, even when the same resource is referenced
515536
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