oxidecomputer / third-party-api-clients

A place for keeping all our generated third party API clients.
https://docs.rs/octorust
MIT License
133 stars 56 forks source link

Feature request: Support weird GitHub pagination formats #88

Open samkearney opened 11 months ago

samkearney commented 11 months ago

The GitHub API has two patterns for endpoints that return lists. One is just to return an array, and the other is to return an object that looks like this:

{
  "total_count": 42,
  "[entities]": [
    // ...
  ]
}

Where [entities] can be something different per-endpoint, usually semantically related to the name of the endpoint. For example, the format for GET /orgs/{org}/actions/runners is:

{
  "total_count": 2,
  "runners": [
    // ...
  ]
}

These endpoints require pagination, even though they do not return root arrays, but the heuristic used to determine whether to generate a "get all pages" function misses them: https://github.com/oxidecomputer/third-party-api-clients/blob/31f85e8f995761c178aa134de37b74c8e52bc6c0/generator/src/functions.rs#L390

It would be nice if "get all pages" helper functions could be generated for these GitHub API models.

I looked into implementing this in a PR, but it got a bit more complicated than I was ready to devote time to, so I am just filing an issue for now. This is the root cause of #81.