More improvements in the REST API documentation index

- Rewrite the output format section to remove repeated information
  about pretty-printed JSON.

- Replace another instance of "is used" with "is returned".

- Minor fixes in the 405 and 409 response sections.

Change-Id: I150e24d4d39744120f478b912b34e5061f6c93fb
This commit is contained in:
David Pursehouse
2014-05-01 21:50:18 +09:00
parent 37a071a1a0
commit 0ddcb08dd7

View File

@@ -50,17 +50,22 @@ with HTTP 412 Precondition Failed.
[[output]] [[output]]
=== Output Format === Output Format
Most APIs return pretty printed JSON by default. Compact JSON can be JSON responses are encoded using UTF-8 and use content type
requested by setting the `Accept` HTTP request header to include `application/json`.
`application/json`, for example:
By default most APIs return pretty-printed JSON, which uses extra
whitespace to make the output more readable for humans.
Compact JSON can be requested by setting the `pp=0` query parameter,
or by setting the `Accept` HTTP request header to include `application/json`:
---- ----
GET /projects/ HTTP/1.0 GET /projects/ HTTP/1.0
Accept: application/json Accept: application/json
---- ----
JSON responses are encoded using UTF-8 and use content type Producing (and parsing) the non-pretty compact format is more efficient,
`application/json`. so tools should request it whenever possible.
To prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON To prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON
response body starts with a magic prefix line that must be stripped before response body starts with a magic prefix line that must be stripped before
@@ -71,12 +76,6 @@ feeding the rest of the response body to a JSON parser:
[ ... valid JSON ... ] [ ... valid JSON ... ]
---- ----
The default JSON format is pretty, which uses extra whitespace to make
the output more readable for a human. Producing (and parsing) the
non-pretty compact format is more efficient so tools should request it
by using the `Accept: application/json` header or `pp=0` query
parameter whenever possible.
Responses will be gzip compressed by the server if the HTTP Responses will be gzip compressed by the server if the HTTP
`Accept-Encoding` request header is set to `gzip`. This may `Accept-Encoding` request header is set to `gzip`. This may
save on network transfer time for larger responses. save on network transfer time for larger responses.
@@ -84,7 +83,7 @@ save on network transfer time for larger responses.
[[timestamp]] [[timestamp]]
=== Timestamp === Timestamp
Timestamps are given in UTC and have the format Timestamps are given in UTC and have the format
"'yyyy-mm-dd hh:mm:ss.fffffffff'" where "'ffffffffff'" indicates the "'yyyy-mm-dd hh:mm:ss.fffffffff'" where "'ffffffffff'" represents
nanoseconds. nanoseconds.
[[encoding]] [[encoding]]
@@ -133,7 +132,7 @@ cannot be found if the URL contains a non-existing ID or view.
support the operation. support the operation.
E.g. some of the `/groups/` endpoints are only supported for Gerrit E.g. some of the `/groups/` endpoints are only supported for Gerrit
internal groups, if they are invoked for an external group the response internal groups; if they are invoked for an external group the response
is `405 Method Not Allowed`. is `405 Method Not Allowed`.
==== 409 Conflict ==== 409 Conflict
@@ -144,7 +143,7 @@ E.g. if you try to submit a change that is abandoned, this fails with
`409 Conflict` because the state of the change doesn't allow the submit `409 Conflict` because the state of the change doesn't allow the submit
operation. operation.
`409 Conflict` is also used if you try to create a resource but the `409 Conflict` is also returned if you try to create a resource but the
name is already occupied by an existing resource. name is already occupied by an existing resource.
==== 412 Precondition Failed ==== 412 Precondition Failed