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

[Schema Inaccuracy] Should GET /user/repos be paginated? #4048

Open
tonyarnold opened this issue Oct 7, 2024 · 9 comments
Open

[Schema Inaccuracy] Should GET /user/repos be paginated? #4048

tonyarnold opened this issue Oct 7, 2024 · 9 comments
Labels

Comments

@tonyarnold
Copy link

tonyarnold commented Oct 7, 2024

Schema Inaccuracy

GET /user/repos does not include pagination information in the returned header responses, despite taking page/per_page in the query.

Expected

The response should include headers containing the standard set of links to the previous, next, first and last pages.

I've found that if I manually add these to the schema I'm using that this endpoint does return the expected pagination details.

@tonyarnold tonyarnold changed the title [Schema Inaccuracy] Should /user/repos be paginated? [Schema Inaccuracy] Should GET /user/repos be paginated? Oct 7, 2024
@becco becco added the feature label Oct 7, 2024
@calvinchilds
Copy link

Thanks for your report @tonyarnold ! Could you clarify what you mean by

I've found that if I manually add these to the schema I'm using that this endpoint does return the expected pagination details.

that is, what schema and what did you add to make the pagination details show up when they weren't before?

@tonyarnold
Copy link
Author

Hi @calvinchilds - no worries at all!

I have tried both the JSON and the YAML schema, but I found if I located the section for /user/repos, and added the following under the existing content block, the Link properties come through in the response:

headers:
    Link: *37

@calvinchilds
Copy link

Thanks for replying! What are you plugging that schema into i.e. what are you using to call the API, is it a client library, CLI, curl?

@tonyarnold
Copy link
Author

I'm generating Swift sources using Apple's Swift OpenAPI Generator, and compiling them into a desktop app that I've been building for monitoring workflow changes on my Mac.

@calvinchilds
Copy link

I tried this with curl -I "https://api.github.com/user/repos" and found the link header which looked like

link: <https://api.github.com/user/repos?page=2>; rel="next", <https://api.github.com/user/repos?page=35>; rel="last"

and did not show up for my other account with few repositories (as the documentation mentions).

I'm not familiar with Swift OpenAPI Generator - is the purpose of that configuration to allow certain headers through? Does the same thing happen with other GitHub API endpoints?

@tonyarnold
Copy link
Author

I tried this with curl -I "https://api.github.com/user/repos" and found the link header […]

The issue I'm trying to report here is that the Link header is not in the Open API spec that's been published for api.github.com for this endpoint, so it's not being decoded by tooling that uses the spec to generate code around this.

I'm not familiar with Swift OpenAPI Generator […]

From the repository:

"Generate Swift client and server code from an OpenAPI document."

"Swift OpenAPI Generator is a Swift package plugin that can generate the ceremony code required to make API calls, or implement API servers."

@calvinchilds
Copy link

Ah I think I get you now. In https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/api.github.com/api.github.com.yaml search for repos/list-for-authenticated-user and the responses section doesn't have

headers:
    Link:
        "$ref": "#/components/headers/link"

as some others do. I imagine this is the issue - we'll get on this 👍 (and this is something we should more actively check against our API documentation)

@tonyarnold
Copy link
Author

That's exactly the issue. Sorry I wasn't able to be clearer in explaining it.

@calvinchilds
Copy link

No worries, glad we got there in the end 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants