octokit / openapi-types.ts

Generated TypeScript definitions based on GitHub's OpenAPI spec
MIT License
40 stars 10 forks source link

[BUG]: Missing requestBody properties for checks/create operation #313

Closed eliasbrange closed 1 year ago

eliasbrange commented 1 year ago

What happened?

The checks/create operation is missing a ton of properties in the requestBody:

"checks/create": {
    parameters: {
      path: {
        owner: components["parameters"]["owner"];
        repo: components["parameters"]["repo"];
      };
    };
    requestBody: {
      content: {
        "application/json": OneOf<
          [
            {
              /** @enum {unknown} */
              status: "completed";
              [key: string]: unknown;
            },
            {
              /** @enum {unknown} */
              status?: "queued" | "in_progress";
              [key: string]: unknown;
            }
          ]
        >;
      };
    };
    responses: {
      /** @description Response */
      201: {
        content: {
          "application/json": components["schemas"]["check-run"];
        };
      };
    };
  };

Looking at the schema here, it looks like it has all the fields. For example, the schema defines name and head_sha as required properties, but they are missing from the type above.

Versions

@octokit/openapi-types v17.1.2

Relevant log output

No response

Code of Conduct

eliasbrange commented 1 year ago

It last looked OK in this commit: https://github.com/octokit/openapi-types.ts/commit/e6d30e6b315e05e350932fb9d2e2e6ca5a228a9f

"checks/create": {
    parameters: {
      path: {
        /** The account owner of the repository. The name is not case sensitive. */
        owner: components["parameters"]["owner"];
        /** The name of the repository. The name is not case sensitive. */
        repo: components["parameters"]["repo"];
      };
    };
    responses: {
      /** Response */
      201: {
        content: {
          "application/json": components["schemas"]["check-run"];
        };
      };
    };
    requestBody: {
      content: {
        "application/json": (
          | ({
              /** @enum {undefined} */
              status: "completed";
            } & {
              conclusion: unknown;
            } & { [key: string]: unknown })
          | ({
              /** @enum {undefined} */
              status?: "queued" | "in_progress";
            } & { [key: string]: unknown })
        ) & {
          /** @description The name of the check. For example, "code-coverage". */
          name: string;
          /** @description The SHA of the commit. */
          head_sha: string;
          /** @description The URL of the integrator's site that has the full details of the check. If the integrator does not provide this, then the homepage of the GitHub app is used. */
          details_url?: string;
          /** @description A reference for the run on the integrator's system. */
          external_id?: string;
          /**
           * @description The current status.
           * @default queued
           * @enum {string}
           */
          status?: "queued" | "in_progress" | "completed";
          /**
           * Format: date-time
           * @description The time that the check run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
           */
          started_at?: string;
          /**
           * @description **Required if you provide `completed_at` or a `status` of `completed`**. The final conclusion of the check.
           * **Note:** Providing `conclusion` will automatically set the `status` parameter to `completed`. You cannot change a check run conclusion to `stale`, only GitHub can set this.
           * @enum {string}
           */
          conclusion?:
            | "action_required"
            | "cancelled"
            | "failure"
            | "neutral"
            | "success"
            | "skipped"
            | "stale"
            | "timed_out";
          /**
           * Format: date-time
           * @description The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`.
           */
          completed_at?: string;
          /** @description Check runs can accept a variety of data in the `output` object, including a `title` and `summary` and can optionally provide descriptive details about the run. */
          output?: {
            /** @description The title of the check run. */
            title: string;
            /** @description The summary of the check run. This parameter supports Markdown. **Maximum length**: 65535 characters. */
            summary: string;
            /** @description The details of the check run. This parameter supports Markdown. **Maximum length**: 65535 characters. */
            text?: string;
            /** @description Adds information from your analysis to specific lines of code. Annotations are visible on GitHub in the **Checks** and **Files changed** tab of the pull request. The Checks API limits the number of annotations to a maximum of 50 per API request. To create more than 50 annotations, you have to make multiple requests to the [Update a check run](https://docs.github.com/rest/reference/checks#update-a-check-run) endpoint. Each time you update the check run, annotations are appended to the list of annotations that already exist for the check run. For details about how you can view annotations on GitHub, see "[About status checks](https://docs.github.com/articles/about-status-checks#checks)". */
            annotations?: {
              /** @description The path of the file to add an annotation to. For example, `assets/css/main.css`. */
              path: string;
              /** @description The start line of the annotation. Line numbers start at 1. */
              start_line: number;
              /** @description The end line of the annotation. */
              end_line: number;
              /** @description The start column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. Column numbers start at 1. */
              start_column?: number;
              /** @description The end column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. */
              end_column?: number;
              /**
               * @description The level of the annotation.
               * @enum {string}
               */
              annotation_level: "notice" | "warning" | "failure";
              /** @description A short description of the feedback for these lines of code. The maximum size is 64 KB. */
              message: string;
              /** @description The title that represents the annotation. The maximum size is 255 characters. */
              title?: string;
              /** @description Details about this annotation. The maximum size is 64 KB. */
              raw_details?: string;
            }[];
            /** @description Adds images to the output displayed in the GitHub pull request UI. */
            images?: {
              /** @description The alternative text for the image. */
              alt: string;
              /** @description The full URL of the image. */
              image_url: string;
              /** @description A short image description. */
              caption?: string;
            }[];
          };
          /** @description Displays a button on GitHub that can be clicked to alert your app to do additional tasks. For example, a code linting app can display a button that automatically fixes detected errors. The button created in this object is displayed after the check run completes. When a user clicks the button, GitHub sends the [`check_run.requested_action` webhook](https://docs.github.com/webhooks/event-payloads/#check_run) to your app. Each action includes a `label`, `identifier` and `description`. A maximum of three actions are accepted. To learn more about check runs and requested actions, see "[Check runs and requested actions](https://docs.github.com/rest/reference/checks#check-runs-and-requested-actions)." */
          actions?: {
            /** @description The text to be displayed on a button in the web UI. The maximum size is 20 characters. */
            label: string;
            /** @description A short explanation of what this action would do. The maximum size is 40 characters. */
            description: string;
            /** @description A reference for the action on the integrator's system. The maximum size is 20 characters. */
            identifier: string;
          }[];
        };
      };
    };
  };
wolfy1339 commented 1 year ago

I'll have a look.

The only thing that changed is that we upgraded to openapi-typescript V6

It's more strict regarding the schemas than it was previously. This means that some quirks that might have worked previously don't generate properly now.

wolfy1339 commented 1 year ago

This seems to be something akin to octokit/types.ts#534 again...

I'll have a patch for this soon

wolfy1339 commented 1 year ago

This may show up again for other operations.

Here is an issue filed with openapi-typescript with someone in the same situation https://github.com/drwpow/openapi-typescript/issues/1020

There is a good explanation on why this is happening, and how it's invalid

eliasbrange commented 1 year ago

This may show up again for other operations.

Here is an issue filed with openapi-typescript with someone in the same situation drwpow/openapi-typescript#1020

There is a good explanation on why this is happening, and how it's invalid

That issue was closed since "it is working as intended". Any progress on this?

wolfy1339 commented 1 year ago

Sorry about this. I thought I had pushed the patch.

wolfy1339 commented 1 year ago

This will get fixed by https://github.com/octokit/openapi/pull/361 once it lands in this repo

wolfy1339 commented 1 year ago

This should be fixed now