Skip to content

Commit 395a83b

Browse files
committed
Add guidance on including api-version in nextLink
1 parent 3445e5c commit 395a83b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

azure/ConsiderationsForServiceDesign.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,37 @@ All responses should include the `x-ms-request-id` header with a unique id for t
374374

375375
Finally, write sample code for your service's workflow and add the code you'd want customers using to gracefully recover from errors. Is it actually graceful? Is it something you'd be comfortable asking most customers to write? We also highly encourage reaching out to customers during private preview and asking them for code they've written against your service. Their error handling might match your expectations, you might find a strong need for better documentation, or you might find important opportunities to improve the errors you're returning.
376376

377+
## Pagination
378+
379+
Operations that return a collection of resources may need should support pagination.
380+
There are hard limits to the payload size of HTTP responses, and when the size of a collection or the resources themselves
381+
can grow arbitrarily large there is the risk of exceeding this limit if the operation does not support pagination.
382+
Further, adding support for pagination is a breaking change so it should be supported in the initial GA of the service
383+
if there is any possibility that it will eventually be needed.
384+
385+
There are two forms of pagination that MAY be supported by RESTful APIs.
386+
Server-driven paging mitigates against denial-of-service attacks by forcibly paginating a request over multiple response payloads.
387+
Client-driven paging enables clients to request only the number of resources that it can use at a given time.
388+
389+
### Server-driven paging
390+
391+
In server-driven paging, the service includes a `nextLink` property in the response to indicate that additional elements
392+
exist in the collection.
393+
The value of the `nextLink` property should be an opaque absolute URL that will return the next page of results.
394+
The absence of a `nextLink` property means that no additional pages are available.
395+
Since `nextLink` is an opaque URL it should include any query parameters required by the service, including `api-version`.
396+
397+
The service determines how many items to include in the response and may choose a different number for different collections and even for different pages of the same collection.
398+
An operation may allow the client to specify a maximum number of items in a response with an optional `maxpagesize` parameter.
399+
Operations that support `maxpagesize` should return no more than the value specified in `maxpagesize` but may return fewer.
400+
401+
### Client-driven paging
402+
403+
An operation may support `skip` and `top` query parameters to allow the client to specify an offset into the collection
404+
and the number of results to return, respectively.
405+
406+
Note that when `top` specifies a value larger than the server-driven paging page size, the response will be paged accordingly.
407+
377408
## Getting Help: The Azure REST API Stewardship Board
378409
The Azure REST API Stewardship board is a collection of dedicated architects that are passionate about helping Azure service teams build interfaces that are intuitive, maintainable, consistent, and most importantly, delight our customers. Because APIs affect nearly all downstream decisions, you are encouraged to reach out to the Stewardship board early in the development process. These architects will work with you to apply these guidelines and identify any hidden pitfalls in your design.
379410

azure/Guidelines.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ Note: To avoid potential collision of actions and resource ids, you should disal
512512

513513
:white_check_mark: **DO** return a `nextLink` field with an absolute URL that the client can GET in order to retrieve the next page of the collection.
514514

515+
:white_check_mark: **DO** include any query parameters required by the service in `nextLink`, including `api-version`.
516+
515517
:ballot_box_with_check: **YOU SHOULD** use `value` as the name of the top-level array field unless a more appropriate name is available.
516518

517519
:no_entry: **DO NOT** return the `nextLink` field at all when returning the last page of the collection.

0 commit comments

Comments
 (0)