Skip to content

Commit b0f0231

Browse files
committed
Attributes of to-many relationships #415 #431
1 parent ed7fad4 commit b0f0231

File tree

2 files changed

+173
-48
lines changed

2 files changed

+173
-48
lines changed

extensions/jsonpatch/index.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ operations allowed in this top level array.
2727
### Request URLs and Patch Paths <a href="#patch-urls" id="patch-urls" class="headerlink"></a>
2828

2929
The request URL and each Patch operation's `"path"` are complementary and
30-
**MUST** combine to target a particular resource, collection, attribute, or
30+
**MUST** combine to target a particular resource, collection, resource attribute, or
3131
relationship.
3232

3333
If a server supports the Patch extension, it **MUST** allow Patch operations at
@@ -65,9 +65,9 @@ Accept: application/vnd.api+json; ext=jsonpatch
6565
]
6666
```
6767

68-
### Updating Attributes <a href="#patch-updating-attributes" id="patch-updating-attributes" class="headerlink"></a>
68+
### Updating Resource Attributes <a href="#patch-updating-attributes" id="patch-updating-attributes" class="headerlink"></a>
6969

70-
To update an attribute, perform a `"replace"` operation with the attribute's
70+
To update a resource attribute, perform a `"replace"` operation with the attribute's
7171
name specified by the `"path"`.
7272

7373
For instance, the following request should update just the `src` property of the
@@ -96,8 +96,7 @@ target a particular relationship's URL.
9696
#### Updating To-One Relationships <a href="#patch-updating-to-one-relationships" id="patch-updating-to-one-relationships" class="headerlink"></a>
9797

9898
To update a to-one relationship, perform a `"replace"` operation with a URL and
99-
`"path"` that targets the relationship. The `"value"` should be a link object
100-
that contains `"type"` and `"id"` members.
99+
`"path"` that targets the relationship. The `"value"` should be a linkage object.
101100

102101
For instance, the following request should update the `author` of an article:
103102

@@ -129,9 +128,8 @@ Accept: application/vnd.api+json; ext=jsonpatch
129128
A server **MUST** respond to Patch operations that target a *to-many
130129
relationship URL* as described below.
131130

132-
For all operations, the `"value"` **MUST** contain an object that contains
133-
`type` and `id` members, or an array of objects that each contain `type`
134-
and `id` members.
131+
For all operations, the `"value"` **MUST** be a linkage object,
132+
or an array of linkage objects.
135133

136134
If a client requests a `"replace"` operation to a *to-many relationship URL*, the
137135
server **MUST** either completely replace every member of the relationship,
@@ -162,11 +160,12 @@ To add an element to a to-many relationship, request an `"add"` operation that
162160
targets the relationship's URL. Because the operation is targeting the end of a
163161
collection, the `"path"` must end with `"/-"`.
164162

165-
In the following example, the comment with ID `123` is added to the list of
166-
comments for the article with ID `1`:
163+
In the following example, the new reprint with ID `123` is added to the list of
164+
+publications of the article with ID `1` ():
165+
167166

168167
```text
169-
PATCH /articles/1/links/comments
168+
PATCH /articles/1/links/publications
170169
Content-Type: application/vnd.api+json; ext=jsonpatch
171170
Accept: application/vnd.api+json; ext=jsonpatch
172171
@@ -175,7 +174,7 @@ Accept: application/vnd.api+json; ext=jsonpatch
175174
"op": "add",
176175
"path": "/-",
177176
"value": [
178-
{ "type": "comments", "id": "123" }
177+
{ "type": "magazines", "id": "123", "publication_type": "reprint" }
179178
]
180179
}
181180
]
@@ -226,8 +225,8 @@ Accept: application/vnd.api+json; ext=jsonpatch
226225
#### 204 No Content <a href="#patch-responses-204" id="patch-responses-204" class="headerlink"></a>
227226

228227
A server **MUST** return a `204 No Content` status code in response to a
229-
successful Patch operation in which the client's current attributes remain up to
230-
date.
228+
successful Patch operation in which the client's current resource attributes
229+
remain up to date.
231230

232231
#### 200 OK <a href="#patch-responses-200" id="patch-responses-200" class="headerlink"></a>
233232

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