danielgtaylor / openapi-cli-generator

Generate a CLI from an OpenAPI 3 specification
MIT License
179 stars 49 forks source link

Handle Pagination #9

Open danielgtaylor opened 5 years ago

danielgtaylor commented 5 years ago

For APIs with paginated responses, the cli package should include utilities for handling the response and fetching subsequent pages automatically up to some limit.

For example, the GitHub API v3 uses Link headers with hypermedia relations to provide pagination.

In general there seem to be three models in use:

  1. Passing a page size and page number to get items. Maybe also some way to get a total page count.
  2. Passing an iterator value to get the next set of items. When no iterator is (or no items are) returned you are done.
  3. Using link relations to provide full URLs to fetch more items.

There should be a new OpenAPI extension to hint to the CLI which of these cases it is, how to handle it (e.g. parameter names), and whether to fetch all or expose limits via parameters in the CLI.