github-java-client icon indicating copy to clipboard operation
github-java-client copied to clipboard

how to use AsyncPage with a response type that is not a JSON array?

Open mattnworb opened this issue 5 years ago • 0 comments

Some Github API responses will be paginated and return a JSON object like:

{
  "total_count": 50,
  "repositories: [ ... ]
}

for example: https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation

It seems like these cannot be represented as GithubPage<T> since the constructor requires a TypeReference<List<T>>:

https://github.com/spotify/github-java-client/blob/d00da14769ab49b723e0a46e2fed02186a6a835f/src/main/java/com/spotify/github/v3/clients/GithubPage.java#L60-L61

which would mean that if I want to add a method to e.g. GithubAppClient to list the repos accessible to a Github app installation, I'd have to return just the single JSON response (as a Java type) - which would risk only being able to return as much data as the Github API fits into the initial page (which I think maxes out at 100 items).

... or maybe I am missing something?

mattnworb avatar Oct 28 '20 20:10 mattnworb