8000 unify id and ids by tkellen · Pull Request #392 · json-api/json-api · GitHub
[go: up one dir, main page]

Skip to content

unify id and ids #392

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 1 commit into from
Mar 4, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
unify id and ids
This distinction is unnecessary. Checking if `id` is a string, an
array or null is trivial for clients.
  • Loading branch information
Tyler Kellen committed Mar 4, 2015
commit 31400b617d9a79e00044592b3284ec25e2af5803
4 changes: 2 additions & 2 deletions extensions/bulk/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ Multiple resources can be deleted by sending a `DELETE` request to a URL that
represents a collection of resources to which they all belong.

The body of the request **MUST** contain a `data` member whose value is an
object that contains `type` and `ids`, or an array of objects that each
object that contains `type` and `id`, or an array of objects that each
contain a `type` and `id`.

For example:
Expand All @@ -100,6 +100,6 @@ Content-Type: application/vnd.api+json; ext=bulk
Accept: application/vnd.api+json; ext=bulk

{
"data": { "type": "articles", "ids": ["1", "2"] }
"data": { "type": "articles", "id": ["1", "2"] }
}
```
8 changes: 4 additions & 4 deletions extensions/patch/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ A server **MUST** respond to Patch operations that target a *to-many
relationship URL* as described below.

For all operations, the `"value"` **MUST** contain an object that contains
`type` and `ids` members, or an array of objects that each contain `type`
`type` and `id` members, or an array of objects that each contain `type`
and `id` members.

If a client requests a `"replace"` operation to a *to-many relationship URL*, the
Expand All @@ -155,7 +155,7 @@ Content-Type: application/vnd.api+json; ext=patch
Accept: application/vnd.api+json; ext=patch

[
{ "op": "replace", "path": "", "value": {"type": "tags", "ids": ["2", "3"]} }
{ "op": "replace", "path": "", "value": {"type": "tags", "id": ["2", "3"]} }
]
```

Expand All @@ -172,7 +172,7 @@ Content-Type: application/vnd.api+json; ext=patch
Accept: application/vnd.api+json; ext=patch

[
{ "op": "add", "path": "/-", "value": { "type": "comments", "ids": ["123"] } }
{ "op": "add", "path": "/-", "value": { "type": "comments", "id": ["123"] } }
]
```

Expand All @@ -188,7 +188,7 @@ Content-Type: application/vnd.api+json; ext=patch
Accept: application/vnd.api+json; ext=patch

[
{ "op": "remove", "path": "", "value": {"type": "comments", "ids": ["5", "13"]} }
{ "op": "remove", "path": "", "value": {"type": "comments", "id": ["5", "13"]} }
]
```

Expand Down
20 changes: 10 additions & 10 deletions format/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ one of the following:
relationship URLs. Linkage **MUST** be expressed as:
* `type` and `id` members for to-one relationships. `type` is not required
if the value of `id` is `null`.
* `type` and `ids` members for homogeneous to-many relationships. `type` is
not required if the value of `ids` is an empty array (`[]`).
* `type` and `id` members for homogeneous to-many relationships. `type` is
not required if the value of `id` is an empty array (`[]`).
* A `data` member whose value is an array of objects each containing `type`
and `id` members for heterogeneous to-many relationships.
* A `"meta"` member that contains non-standard meta-information about the
Expand Down Expand Up @@ -316,7 +316,7 @@ A complete example document with multiple included relationships:
"self": "http://example.com/articles/1/links/comments",
"resource": "http://example.com/articles/1/comments",
"type": "comments",
"ids": ["5", "12"]
"id": ["5", "12"]
}
}
}],
Expand Down Expand Up @@ -798,8 +798,8 @@ Accept: application/vnd.api+json
If a to-many relationship is included in the `links` section of a resource
object, it **MUST** be an object containing:

* `type` and `ids` members for homogeneous to-many relationships; to clear the
relationship, set the `ids` member to `[]`
* `type` and `id` members for homogeneous to-many relationships; to clear the
relationship, set the `id` member to `[]`
* a `data` member whose value is an array of objects each containing `type` and
`id` members for heterogeneous to-many relationships; to clear the
relationship, set the `data` member to `[]`
Expand All @@ -818,7 +818,7 @@ Accept: application/vnd.api+json
"id": "1",
"title": "Rails is a Melting Pot",
"links": {
"tags": { "type": "tags", "ids": ["2", "3"] }
"tags": { "type": "tags", "id": ["2", "3"] }
}
}
}
Expand Down Expand Up @@ -943,7 +943,7 @@ A server **MUST** respond to `PUT`, `POST`, and `DELETE` requests to a *to-many
relationship URL* as described below.

For all request types, the body **MUST** contain a `data` member whose value
is an object that contains `type` and `ids` members, or an array of objects
is an object that contains `type` and `id` members, or an array of objects
that each contain `type` and `id` members.

If a client makes a `PUT` request to a *to-many relationship URL*, the
Expand All @@ -960,7 +960,7 @@ Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
"data": { "type": "tags", "ids": ["2", "3"] }
"data": { "type": "tags", "id": ["2", "3"] }
}
```

Expand Down Expand Up @@ -990,7 +990,7 @@ Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

{
"data": { "type": "comments", "ids": ["123"] }
"data": { "type": "comments", "id": ["123"] }
}
```

Expand All @@ -1014,7 +1014,7 @@ Content-Type: application/vnd.api+json
Accept: application/vnd.api+json

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

Expand Down
2 changes: 1 addition & 1 deletion index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Here's an example response from a blog that implements JSON API:
"self": "http://example.com/posts/1/links/comments",
"resource": "http://example.com/posts/1/comments",
"type": "comments",
"ids": ["5", "12"]
"id": ["5", "12"]
}
}
}],
Expand Down
0