Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
mattnworb opened this issue Oct 28, 2020 · 0 comments
Open

Comments

@mattnworb
Copy link
Member

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>>:

GithubPage(
final GitHubClient github, final String path, final TypeReference<List<T>> typeReference) {

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 added a commit that referenced this issue Oct 28, 2020
this change implements support for
https://docs.github.com/en/free-pro-team@latest/rest/reference/apps#list-repositories-accessible-to-the-app-installation

I believe though, that in this initial form, the response is limited to
only the first page of results returned by the Github API:
#41
henriquetruta pushed a commit that referenced this issue Oct 29, 2020
#42)

* add method to list repos accessible to a Github App

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

I believe though, that in this initial form, the response is limited to
only the first page of results returned by the Github API:
#41

* add GithubAppClientTest#listAccessibleRepositories and refactor other tests

This commit refactors GithubAppClientTest so that it tests the actual
methods in GithubAppClient and adds a test of the new method
`listAccessibleRepositories()`.

Previously the test did not actually test any logic in GithubAppClient
but rather the tests were of the deserialization logic for some of the
types used in the class.

I moved the test related to deserializing an AccessToken to a new
AccessTokenTest, and replaced the other tests so that they use a
MockWebServer to actually be able to test the HTTP requests/responses.

* minor: unnecessary type arguments

* forgot to teardown MockWebServer

use it as a Rule instead to make things a little simpler

* squash: remove redundant toCompletableFuture() calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant