-
Notifications
You must be signed in to change notification settings - Fork 890
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
Changes from 1 commit
8db6729
e19b2a3
2837f8a
613996e
1cd710f
a42b61d
936e1f8
4d98838
6973ee9
dca96b9
ea1431e
25606b9
6133ac1
ee12f88
7912e42
e8f0401
ea35fff
1ff22df
59b2ee3
1e23b89
e60ccec
1307997
91876ae
061a8f4
825d466
8dac29a
b4d6873
90d898a
c2a325a
2ceafea
35ee064
622a755
43eec5c
edd2c10
21e9bad
8af5e05
2293aa1
043adb0
c7fa63a
4a2c55a
b2649b1
25b5823
eae7512
0dbb804
d9729e4
5865f15
ddb2fdb
4ee9bad
0138885
b35d887
2924a6e
87d2828
eece87f
2fa6265
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,23 +453,24 @@ fields in the response. | |
A server **MAY** choose to support requests to sort resource collections | ||
according to one or more criteria. | ||
|
||
An endpoint **MAY** support requests to sort the primary resource type with a | ||
`sort` parameter. | ||
An endpoint **MAY** support requests to sort the primary data with a `sort` | ||
query parameter. | ||
|
||
```text | ||
GET /people?sort=age | ||
``` | ||
|
||
An endpoint **MAY** support multiple sort criteria by allowing comma-separated | ||
fields as the value for `sort`. Sort criteria should be applied in the order | ||
specified. | ||
An endpoint **MAY** support multiple sort criteria by allowing | ||
comma-separated (U+002C COMMA, ",") fields as the value for `sort`. Sort | ||
criteria should be applied in the order specified. | ||
|
||
```text | ||
GET /people?sort=age,name | ||
``` | ||
|
||
The default sort order **SHOULD** be ascending. A `-` prefix on any sort field | ||
specifies a descending sort order. | ||
The default sort order **SHOULD** be ascending. A minus (U+002D: | ||
HYPHEN-MINUS, "-") prefix on any sort field specifies a descending sort | ||
order. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not clear to me why this is a good trade-off. I don't see that it's particularly bad, either, but does put the added burden on the client to explicitly state a sort order every time. If JSON API were to set requirements for the first character in field names, it seems like they would tend to match existing programming language requirements. Requiring that field names not start with PLUS, MINUS, or other non-numerical characters doesn't seem like a huge overreach. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's a legitimate take on this - and I can't say that I haven't been on the fence here. We decided on this trade-off so that names would have no restrictions, and to keep sorting requirements only affecting implementations that choose to support sorting. In other words, we wanted to avoid having an optional aspect of the spec driving requirements in a very core part of the spec. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For history there's a long discussion on this in #324. |
||
```text | ||
GET /posts?sort=-created,title | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this "should" be a SHOULD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch - fixed. Thanks @bobholt!