Skip to content

Proposal for v1.0 rc2 #341

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Feb 18, 2015
Merged
Changes from 1 commit
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
8db6729
V1.0 RC2 WIP
dgeb Dec 24, 2014
e19b2a3
V1.0 RC2 WIP, continued
dgeb Jan 7, 2015
2837f8a
minor edits
Jan 9, 2015
613996e
Introduce `Extending` section.
dgeb Feb 2, 2015
1cd710f
Clarify requirements for meta-information.
dgeb Feb 2, 2015
a42b61d
Introduce pagination.
dgeb Feb 2, 2015
936e1f8
Require dasherized naming of attributes and associations.
dgeb Feb 2, 2015
4d98838
Introduce note about (lack of) inflection rules.
dgeb Feb 2, 2015
6973ee9
Remove HTTP Caching section.
dgeb Feb 2, 2015
dca96b9
Refine Errors section.
dgeb Feb 2, 2015
ea1431e
Fix line breaks and minor typos.
dgeb Feb 2, 2015
25606b9
Clarify requirements around client-generated IDs
dgeb Feb 2, 2015
6133ac1
Correct column wrapping
dgeb Feb 2, 2015
ee12f88
Add note clarifying that foreign keys aren’t attributes.
dgeb Feb 3, 2015
7912e42
Reword note about foreign key relationships
dgeb Feb 3, 2015
e8f0401
Remove "example" divs.
dgeb Feb 3, 2015
ea35fff
Clarify definition of compound documents.
dgeb Feb 3, 2015
1ff22df
Add Recommendations and remove Overview from navigation
dgeb Feb 4, 2015
59b2ee3
Clarify that related resource URLs should remain constant
dgeb Feb 4, 2015
1e23b89
Translate URL rules into "recommendations"
dgeb Feb 4, 2015
e60ccec
Clarify meta information with example.
dgeb Feb 4, 2015
1307997
Clarify top-level self link definition
dgeb Feb 4, 2015
91876ae
Re-introduce filtering strategy as a recommendation.
dgeb Feb 4, 2015
061a8f4
Clarify sorting section
dgeb Feb 4, 2015
825d466
Fix column wrapping
dgeb Feb 4, 2015
8dac29a
Clarify media type header
dgeb Feb 4, 2015
b4d6873
Clarify note about `type` requirement.
dgeb Feb 4, 2015
90d898a
Revisit relationship updating sections.
dgeb Feb 4, 2015
c2a325a
Rename extending -> extensions
dgeb Feb 4, 2015
2ceafea
Move Deleting Resources below Updating Relationships
dgeb Feb 5, 2015
35ee064
Fix typo - remove extra word
dgeb Feb 5, 2015
622a755
Further clarification of updating resources and relationships.
dgeb Feb 5, 2015
43eec5c
Rework extensions page.
dgeb Feb 5, 2015
edd2c10
Move bulk extension page
dgeb Feb 5, 2015
21e9bad
Move patch extension page
dgeb Feb 5, 2015
8af5e05
Clarify resource creation language.
dgeb Feb 5, 2015
2293aa1
Clarify names and media types of official extensions.
dgeb Feb 5, 2015
043adb0
Clarify primary data reqs for to-many relationship updates.
dgeb Feb 5, 2015
c7fa63a
Completely rework the Bulk extension.
dgeb Feb 5, 2015
4a2c55a
Completely rework the Patch extension.
dgeb Feb 6, 2015
b2649b1
Clarify several responses.
dgeb Feb 6, 2015
25b5823
Refactor Patch extension for consistency with base spec.
dgeb Feb 6, 2015
eae7512
Rework Overview page and compound document example.
dgeb Feb 6, 2015
0dbb804
Correct missing comma.
dgeb Feb 7, 2015
d9729e4
Move field name requirements to recommendations.
dgeb Feb 8, 2015
5865f15
Rename 'post' as 'article'
miguelsan Feb 9, 2015
ddb2fdb
Relationships SHALL NOT be named "self"
miguelsan Feb 9, 2015
4ee9bad
Clarify that the *value* of `type` can be singular or plural.
dgeb Feb 10, 2015
0138885
should -> **SHOULD**
dgeb Feb 10, 2015
b35d887
Correct link wrapping
dgeb Feb 17, 2015
2924a6e
Fix EOL spacing.
dgeb Feb 17, 2015
87d2828
Clarify `data` / `errors` top-level members.
dgeb Feb 17, 2015
eece87f
Further define "sort fields" and their usage.
dgeb Feb 17, 2015
2fa6265
Clarify that `type` is not required for empty relationships.
dgeb Feb 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Further clarification of updating resources and relationships.
  • Loading branch information
dgeb committed Feb 17, 2015
commit 622a755b00b3abe90d52ff619d54a338feb144fd
55 changes: 36 additions & 19 deletions format/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ A server **MUST** respond to a successful resource creation request according to
[`HTTP semantics`]
(http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-22#section-6.3).

> TODO: wycats - is the `Location` header still a MUST? How about a top-level `self` link?

The response **MUST** include a `Location` header identifying the location
of the newly created resource.

Expand Down Expand Up @@ -687,7 +685,10 @@ Accept: application/vnd.api+json
}
```

#### Updating Resource Attributes
#### Updating a Resource's Attributes <a href="#crud-updating-resource-attributes" id="crud-updating-resource-attributes" class="headerlink"></a>

Any or all of a resource's attributes **MAY** be included in the resource
object included in a `PUT` request.

If a request does not include all of the fields for a resource, the server
**MUST** interpret the missing fields as if they were included together with
Expand Down Expand Up @@ -718,7 +719,7 @@ Accept: application/vnd.api+json
}
```

#### Updating To-One Relationships with a Resource
#### 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>

If a to-one relationship is provided in the `links` section of a resource
object in a `PUT` request, it **MUST** be one of:
Expand Down Expand Up @@ -746,7 +747,7 @@ Accept: application/vnd.api+json
}
```

#### Updating Resource To-Many Relationships with a Resource
#### 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>

If a to-many relationship is included in the `links` section of a resource
object, it **MUST** be an object containing:
Expand Down Expand Up @@ -892,9 +893,11 @@ Accept: application/vnd.api+json
A server **MUST** respond to `PUT`, `POST`, and `DELETE` requests to a *to-many
relationship URL* as described below.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the spirit of not requiring the client to stop and consider the differences between updating a to-one vs a to-many relationship, would it make sense for "Updating To-One Relationships" to support POST and DELETE with as equivalent to PUTwhen the existing relationship is null (erroring otherwise) and PUT to set the relationship to null, respectively?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bobholt We explored that approach, but ultimately decided that it was an extra requirement on the server that didn't provide any strong benefits. We're really trying to limit code paths as much as possible at this point to simplify implementations. Plus, the PUT approach is already consistent for both to-one and to-many relationships.

If a client makes a `PUT` request to a *to-many relationship URL*, the server
**MUST** either completely replace every member of the relationship or return
a `403 Forbidden` response if complete replacement is not allowed.
If a client makes a `PUT` request to a *to-many relationship URL*, the
server **MUST** either completely replace every member of the relationship,
return an appropriate error response if some resources can not be found or
accessed, or return a `403 Forbidden` response if complete replacement is
not allowed by the server.

The body of the request **MUST** contain a `data` member, whose value is a
link object that contains `type` and `ids`, or an array of objects that each
Expand All @@ -910,15 +913,26 @@ Accept: application/vnd.api+json
}
```

If the client makes a `POST` request to the *relationship URL*, the server
If a client makes a `POST` request to a *relationship URL*, the server
**MUST** append the specified members to the relationship using set
semantics. This means that if a given `type` and `id` is already in the
relationship, it should not add it again.
relationship, the server **MUST NOT** add it again.

> Note: This matches the semantics of databases that use foreign keys for
has-many relationships. Document-based storage should check the has-many
relationship before appending to avoid duplicates.

If all of the specified resources can be added to, or are already present
in, the relationship then the server **MUST** return a successful `204 No
Content` response.

> Note: This approach ensures that a request is successful if the server's
state matches the requested state, and helps avoid pointless race conditions
caused by multiple clients making the same changes to a relationship.

In the following example, the comment with ID `123` is added to the list of
comments for the article with ID `1`:

```text
POST /articles/1/links/comments
Content-Type: application/vnd.api+json
Expand All @@ -929,22 +943,27 @@ Accept: application/vnd.api+json
}
```

In this example, the comment with id `123` is added to the list of comments
for the article with id `1`.
If the client makes a `DELETE` request to a *relationship URL*, the server
**MUST** delete the specified members from the relationship or return a `403
Forbidden` response. If all of the specified resources are able to be
removed from, or are already missing from, the relationship then the server
**MUST** return a successful `204 No Content` response.

> Note: As described above for `POST` requests, this approach helps avoid
pointless race conditions between multiple clients making the same changes.

If the client makes a `DELETE` request to the *relationship URL*, the server
**MUST** delete the specified members from the relationship or return a
`403 Forbidden` response.
Relationship members are specified in the same way as in the `POST` request.

The members are specified in the same way as in the `POST` request.
In the following example, comments with IDs of `12` and `13` are removed
from the list of comments for the article with ID `1`:

```text
DELETE /articles/1/links/comments
Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
"data": { "type": "comments", "ids": ["1"] }
"data": { "type": "comments", "ids": ["12", "13"] }
}
```

Expand All @@ -964,8 +983,6 @@ successful and the client's current attributes remain up to date.
the appropriate response to a `DELETE` request sent to a *to-many
relationship URL* when that relationship does not exist.

> TODO: wycats - unclear if the above is true for `DELETE` requests

##### 200 OK <a href="#crud-updating-relationship-responses-200" id="crud-updating-relationship-responses-200" class="headerlink"></a>

If a server accepts an update but also changes the resource(s) in other ways
Expand Down
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