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

Missing assignees field in SearchIssuesAndPullRequestsResponseData["items"][0] #148

Closed
cliffkoh opened this issue Aug 6, 2020 · 6 comments · Fixed by #197
Closed

Missing assignees field in SearchIssuesAndPullRequestsResponseData["items"][0] #148

cliffkoh opened this issue Aug 6, 2020 · 6 comments · Fixed by #197
Labels
Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only

Comments

@cliffkoh
Copy link

cliffkoh commented Aug 6, 2020

What happened?

Incorrect type for SearchIssuesAndPullRequestsResponseData (associated with RestEndpointMethodTypes["search"]["issuesAndPullRequests"]["response"]["data"]["items"])

What did you expect to happen?

Given the following minimal reproduction:

const { Octokit } = require("@octokit/rest");

async function run() {
  const octokit = new Octokit();

  try {
    const searches =  await octokit.search.issuesAndPullRequests({
      q: "repo:test-organization-kkjeer/cliff-test+is:open"
    });
    console.dir(searches);
    debugger;
    
  } catch (e) {
    debugger;

    console.dir(e);
  }
}

run();

The response includes "assignees" field while the type (see below) does not.
image

Present buggy generated type (dist-types/generated/Endpoint.d.ts, @nodes/types@5.2.0):

export interface SearchIssuesAndPullRequestsResponseData {
    total_count: number;
    incomplete_results: boolean;
    items: {
        url: string;
        repository_url: string;
        labels_url: string;
        comments_url: string;
        events_url: string;
        html_url: string;
        id: number;
        node_id: string;
        number: number;
        title: string;
        user: {
            login: string;
            id: number;
            node_id: string;
            avatar_url: string;
            gravatar_id: string;
            url: string;
            html_url: string;
            followers_url: string;
            following_url: string;
            gists_url: string;
            starred_url: string;
            subscriptions_url: string;
            organizations_url: string;
            repos_url: string;
            events_url: string;
            received_events_url: string;
            type: string;
        };
        labels: {
            id: number;
            node_id: string;
            url: string;
            name: string;
            color: string;
        }[];
        state: string;
        assignee: string;
        milestone: string;
        comments: number;
        created_at: string;
        updated_at: string;
        closed_at: string;
        pull_request: {
            html_url: string;
            diff_url: string;
            patch_url: string;
        };
        body: string;
        score: number;
    }[];
}
@cliffkoh cliffkoh added the Type: Bug Something isn't working as documented, or is being fixed label Aug 6, 2020
@gr2m gr2m added the typescript Relevant to TypeScript users only label Aug 7, 2020
@gr2m
Copy link
Contributor

gr2m commented Aug 7, 2020

We currently derive the types from the examples in the documentation, in this case it's https://docs.github.com/en/rest/reference/search#search-issues-and-pull-requests

However, we do have JSON schemas now that would be a much better source to generate the types from, we just didn't get to it yet. I hope to find time to work on this soon

@cliffkoh
Copy link
Author

cliffkoh commented Aug 7, 2020

Is there anything short term that can be done, such as fixing the documentation?

@gr2m
Copy link
Contributor

gr2m commented Aug 7, 2020

The documentation team is working on that right now I think, they are aware of the discrepancies between the documented example payloads and the JSON API schema that was recently published at https://github.com/github/rest-api-description/. They all work very hard right now and I'd rather not distract them. It's unfortunately not an easy fix to just change the payload example in this one case.

I expect to start working on the better TypeScript types on my side next week, so stay tuned. For now I'd be best if you work around it on your side

@cliffkoh
Copy link
Author

Thank you so much for all these info :) I will work around it for now like you suggested.

@gr2m
Copy link
Contributor

gr2m commented Nov 11, 2020

I'm still working on #161, but I confirmed that this problem will be resolved. The types are defined here: https://github.com/octokit/openapi-types.ts/blob/36baf50bddd8b3baecd6601ea3301e82e6b225d7/generated/types.ts#L26433

@gr2m gr2m mentioned this issue Nov 30, 2020
6 tasks
@gr2m gr2m closed this as completed in #197 Nov 30, 2020
@octokitbot
Copy link
Collaborator

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Something isn't working as documented, or is being fixed typescript Relevant to TypeScript users only
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants