diff --git a/README.md b/README.md index 379ebd7c..4b7a698c 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,7 @@ Options: --disableStrictSSL disabled strict SSL (default: false) --disableProxy disabled proxy (default: false) --axios generate axios http client (default: false) + --ofetch generate ofetch http client (default: false) --unwrap-response-data unwrap the data item from the response (default: false) --disable-throw-on-error Do not throw an error when response.ok is not true (default: false) --single-http-client Ability to send HttpClient instance to Api constructor (default: false) diff --git a/index.d.ts b/index.d.ts index 9f063a38..25b75d54 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,6 +1,6 @@ import {MonoSchemaParser} from "./src/schema-parser/mono-schema-parser"; -type HttpClientType = "axios" | "fetch"; +type HttpClientType = "axios" | "fetch" | "ofetch"; interface GenerateApiParamsBase { /** diff --git a/index.js b/index.js index 9302d910..43024026 100644 --- a/index.js +++ b/index.js @@ -162,6 +162,11 @@ const program = cli({ description: 'generate axios http client', default: codeGenBaseConfig.httpClientType === HTTP_CLIENT.AXIOS, }, + { + flags: 'ofetch', + description: 'generate ofetch http client', + default: codeGenBaseConfig.httpClientType === HTTP_CLIENT.OFETCH, + }, { flags: '--unwrap-response-data', description: 'unwrap the data item from the response', @@ -342,7 +347,6 @@ const main = async () => { } catch (e) { console.error(e); process.exit(1); - return; } process.exit(0); }; diff --git a/package-lock.json b/package-lock.json index 33ecee8e..036cc2e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,7 +6,7 @@ "packages": { "": { "name": "swagger-typescript-api", - "version": "13.0.2", + "version": "13.0.3", "license": "MIT", "dependencies": { "@types/swagger-schema-official": "2.0.22", @@ -41,6 +41,7 @@ "eslint-plugin-prettier": "^5.0.0", "git-diff": "^2.0.6", "husky": "^8.0.3", + "ofetch": "^1.3.4", "pretty-quick": "^3.1.3", "rimraf": "^5.0.1" } @@ -1168,6 +1169,12 @@ "node": ">=0.4.0" } }, + "node_modules/destr": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/destr/-/destr-2.0.3.tgz", + "integrity": "sha512-2N3BOUU4gYMpTP24s5rF5iP7BDr7uNTCs4ozw3kf/eKfvWSIu93GEBi5m427YoyJoeOzQ5smuu4nNAPGb8idSQ==", + "dev": true + }, "node_modules/didyoumean": { "version": "1.2.2", "resolved": "https://registry.npmjs.org/didyoumean/-/didyoumean-1.2.2.tgz", @@ -2758,6 +2765,12 @@ "node": "4.x || >=6.0.0" } }, + "node_modules/node-fetch-native": { + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/node-fetch-native/-/node-fetch-native-1.6.4.tgz", + "integrity": "sha512-IhOigYzAKHd244OC0JIMIUrjzctirCmPkaIfhDeGcEETWof5zKYUW7e7MYvChGWh/4CJeXEgsRyGzuF334rOOQ==", + "dev": true + }, "node_modules/node-readfiles": { "version": "0.2.0", "resolved": "https://registry.npmjs.org/node-readfiles/-/node-readfiles-0.2.0.tgz", @@ -2843,6 +2856,17 @@ "url": "https://github.com/Mermade/oas-kit?sponsor=1" } }, + "node_modules/ofetch": { + "version": "1.3.4", + "resolved": "https://registry.npmjs.org/ofetch/-/ofetch-1.3.4.tgz", + "integrity": "sha512-KLIET85ik3vhEfS+3fDlc/BAZiAp+43QEC/yCo5zkNoY2YaKvNkOaFr/6wCFgFH1kuYQM5pMNi0Tg8koiIemtw==", + "dev": true, + "dependencies": { + "destr": "^2.0.3", + "node-fetch-native": "^1.6.3", + "ufo": "^1.5.3" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -3909,6 +3933,12 @@ "node": ">=14.17" } }, + "node_modules/ufo": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/ufo/-/ufo-1.5.3.tgz", + "integrity": "sha512-Y7HYmWaFwPUmkoQCUIAYpKqkOf+SbVj/2fJJZ4RJMCfZp0rTGwRbzQD+HghfnhKOjL9E01okqz+ncJskGYfBNw==", + "dev": true + }, "node_modules/unicode-emoji-modifier-base": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unicode-emoji-modifier-base/-/unicode-emoji-modifier-base-1.0.0.tgz", diff --git a/package.json b/package.json index ab1bffd8..185dc4e7 100644 --- a/package.json +++ b/package.json @@ -45,9 +45,11 @@ "test:jsSingleHttpClientModular": "node tests/spec/jsSingleHttpClientModular/test.js", "test:--js--axios": "node tests/spec/jsAxios/test.js", "test:--axios": "node tests/spec/axios/test.js", + "test:--ofetch": "node tests/spec/ofetch/test.js", "test:--another-array-type": "node tests/spec/another-array-type/test.js", "test:--object-types": "node tests/spec/object-types/test.js", "test:--axios--single-http-client": "node tests/spec/axiosSingleHttpClient/test.js", + "test:--ofetch--single-http-client": "node tests/spec/ofetchSingleHttpClient/test.js", "test:--type-suffix--type-prefix": "node tests/spec/typeSuffixPrefix/test.js", "test:--dot-path-params": "node tests/spec/dot-path-params/test.js", "test:--primitive-type-constructs": "node tests/spec/primitive-type-constructs/test.js", @@ -81,6 +83,7 @@ "@types/prettier": "^2.7.3", "all-contributors-cli": "^6.26.1", "axios": "^1.4.0", + "ofetch": "^1.3.4", "cross-env": "^7.0.3", "dotenv": "^16.3.1", "git-diff": "^2.0.6", diff --git a/src/constants.js b/src/constants.js index 61b55e14..f4166507 100644 --- a/src/constants.js +++ b/src/constants.js @@ -27,6 +27,7 @@ const SCHEMA_TYPES = { const HTTP_CLIENT = { FETCH: 'fetch', + OFETCH: 'ofetch', AXIOS: 'axios', }; diff --git a/templates/base/http-clients/ofetch-http-client.ejs b/templates/base/http-clients/ofetch-http-client.ejs new file mode 100644 index 00000000..a1dfd2b5 --- /dev/null +++ b/templates/base/http-clients/ofetch-http-client.ejs @@ -0,0 +1,124 @@ +<% +const { apiConfig, generateResponses, config } = it; +%> + +import type { $Fetch, FetchOptions } from 'ofetch' +import { $fetch } from 'ofetch' + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface CustomFetchOptions extends FetchOptions { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean +} + +export type RequestParams = Omit + +export interface ApiConfig { + baseURL?: string; + basePath?: string; + baseSiteId?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: $Fetch; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseURL: string = "<%~ apiConfig.baseUrl %>"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (url: string, fetchParams: FetchOptions) => $fetch(url, fetchParams) + + private baseApiParams: RequestParams = { + credentials: 'same-origin', + headers: {}, + redirect: 'follow', + referrerPolicy: 'no-referrer', + } + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType | null) => { + this.securityData = data; + } + + protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + } + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken) + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + } + + public request = async (url: string, { + body, + secure, + method, + baseURL, + signal, + params, + ...options +<% if (config.unwrapResponseData) { %> + }: CustomFetchOptions): Promise => { +<% } else { %> + }: CustomFetchOptions): Promise => { +<% } %> + const secureParams = ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) && this.securityWorker && await this.securityWorker(this.securityData)) || {}; + const requestOptions = this.mergeRequestParams(options, secureParams) + + return this.customFetch( + `${baseURL || this.baseURL || ""}${this.basePath ? `${this.basePath}` : ''}${url}`, + { + params, + method, + ...requestOptions, + signal, + body, + } + <% if (config.unwrapResponseData) { %> + ).then((response: T) => response.data) +<% } else { %> + ).then((response: T) => response) +<% } %> + }; +} diff --git a/templates/default/procedure-call.ejs b/templates/default/procedure-call.ejs index 465d6327..cfba5bb3 100644 --- a/templates/default/procedure-call.ejs +++ b/templates/default/procedure-call.ejs @@ -88,13 +88,20 @@ const describeReturnType = () => { */ <%~ route.routeName.usage %><%~ route.namespace ? ': ' : ' = ' %>(<%~ wrapperArgs %>)<%~ config.toJS ? `: ${describeReturnType()}` : "" %> => +<% if (config.httpClientType === config.constants.HTTP_CLIENT.OFETCH) { %> + <%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>>(`<%~ path %>`, { +<% } %> +<% if (config.httpClientType !== config.constants.HTTP_CLIENT.OFETCH) { %> <%~ config.singleHttpClient ? 'this.http.request' : 'this.request' %><<%~ type %>, <%~ errorType %>>({ path: `<%~ path %>`, +<% } %> method: '<%~ _.upperCase(method) %>', <%~ queryTmpl ? `query: ${queryTmpl},` : '' %> <%~ bodyTmpl ? `body: ${bodyTmpl},` : '' %> <%~ securityTmpl ? `secure: ${securityTmpl},` : '' %> + <% if (config.httpClientType !== config.constants.HTTP_CLIENT.OFETCH) { %> <%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %> <%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %> + <% } %> ...<%~ _.get(requestConfigParam, "name") %>, })<%~ route.namespace ? ',' : '' %> diff --git a/tests/spec/ofetch/expected.ts b/tests/spec/ofetch/expected.ts new file mode 100644 index 00000000..83eddc68 --- /dev/null +++ b/tests/spec/ofetch/expected.ts @@ -0,0 +1,5704 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** A user or organization */ +export interface Actor { + avatar_url?: string; + bio?: string; + /** The website URL from the profile page */ + blog?: string; + collaborators?: number; + company?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + disk_usage?: number; + /** Note: The returned email is the user’s publicly visible email address (or null if the user has not specified a public email address in their profile). */ + email?: string; + followers?: number; + followers_url?: string; + following?: number; + following_url?: string; + gists_url?: string; + gravatar_id?: string; + hireable?: boolean; + html_url?: string; + id?: number; + location?: string; + /** The account username */ + login?: string; + /** The full account name */ + name?: string; + organizations_url?: string; + owned_private_repos?: number; + plan?: { + collaborators?: number; + name?: string; + private_repos?: number; + space?: number; + }; + private_gists?: number; + public_gists?: number; + public_repos?: number; + starred_url?: string; + subscriptions_url?: string; + total_private_repos?: number; + type?: "User" | "Organization"; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; +} + +export interface Asset { + content_type?: string; + created_at?: string; + download_count?: number; + id?: number; + label?: string; + name?: string; + size?: number; + state?: string; + updated_at?: string; + /** A GitHub user */ + uploader?: User; + url?: string; +} + +export interface AssetPatch { + label?: string; + name: string; +} + +export type Assets = Asset[]; + +export type Assignees = User[]; + +export interface Blob { + content?: string; + encoding?: "utf-8" | "base64"; + sha?: string; + size?: number; +} + +export interface Blobs { + sha?: string; +} + +export interface Branch { + _links?: { + html?: string; + self?: string; + }; + commit?: { + /** A GitHub user */ + author?: User; + commit?: { + author?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + committer?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; + }; + name?: string; +} + +export type Branches = { + commit?: { + sha?: string; + url?: string; + }; + name?: string; +}[]; + +export type CodeFrequencyStats = number[]; + +export interface Comment { + body?: string; +} + +export interface CommentBody { + body: string; +} + +export type Comments = { + body?: string; + /** ISO 8601. */ + created_at?: string; + id?: number; + url?: string; + /** A GitHub user */ + user?: User; +}[]; + +export interface Commit { + /** A GitHub user */ + author?: User; + commit?: { + author?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + committer?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + files?: { + additions?: number; + blob_url?: string; + changes?: number; + deletions?: number; + filename?: string; + patch?: string; + raw_url?: string; + status?: string; + }[]; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + stats?: { + additions?: number; + deletions?: number; + total?: number; + }; + url?: string; +} + +export type CommitActivityStats = { + days?: number[]; + total?: number; + week?: number; +}[]; + +export interface CommitComment { + body?: string; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + html_url?: string; + id?: number; + line?: number; + path?: string; + position?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; +} + +export interface CommitCommentBody { + body: string; + /** Deprecated - Use position parameter instead. */ + line?: string; + /** Line number in the file to comment on. Defaults to null. */ + number?: string; + /** Relative path of the file to comment on. */ + path?: string; + /** Line index in the diff to comment on. */ + position?: number; + /** SHA of the commit to comment on. */ + sha: string; +} + +export type Commits = { + /** A GitHub user */ + author?: User; + commit?: { + author?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + committer?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; +}[]; + +export interface CompareCommits { + ahead_by?: number; + base_commit?: { + /** A GitHub user */ + author?: User; + commit?: { + author?: { + date?: string; + email?: string; + name?: string; + }; + committer?: { + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; + }; + behind_by?: number; + commits?: { + /** A GitHub user */ + author?: User; + commit?: { + author?: { + date?: string; + email?: string; + name?: string; + }; + committer?: { + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; + }[]; + diff_url?: string; + files?: { + additions?: number; + blob_url?: string; + changes?: number; + contents_url?: string; + deletions?: number; + filename?: string; + patch?: string; + raw_url?: string; + sha?: string; + status?: string; + }[]; + html_url?: string; + patch_url?: string; + permalink_url?: string; + status?: string; + total_commits?: number; + url?: string; +} + +export interface ContentsPath { + _links?: { + git?: string; + html?: string; + self?: string; + }; + content?: string; + encoding?: string; + git_url?: string; + html_url?: string; + name?: string; + path?: string; + sha?: string; + size?: number; + type?: string; + url?: string; +} + +export type ContributorsStats = { + author?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + /** The Total number of commits authored by the contributor. */ + total?: number; + weeks?: { + /** Number of additions. */ + a?: number; + /** Number of commits. */ + c?: number; + /** Number of deletions. */ + d?: number; + /** Start of the week. */ + w?: string; + }[]; +}[]; + +export interface CreateFile { + commit?: { + author?: { + date?: string; + email?: string; + name?: string; + }; + committer?: { + date?: string; + email?: string; + name?: string; + }; + html_url?: string; + message?: string; + parents?: { + html_url?: string; + sha?: string; + url?: string; + }[]; + sha?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + content?: { + _links?: { + git?: string; + html?: string; + self?: string; + }; + git_url?: string; + html_url?: string; + name?: string; + path?: string; + sha?: string; + size?: number; + type?: string; + url?: string; + }; +} + +export interface CreateFileBody { + committer?: { + email?: string; + name?: string; + }; + content?: string; + message?: string; +} + +export interface DeleteFile { + commit?: { + author?: { + date?: string; + email?: string; + name?: string; + }; + committer?: { + date?: string; + email?: string; + name?: string; + }; + html_url?: string; + message?: string; + parents?: { + html_url?: string; + sha?: string; + url?: string; + }; + sha?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + content?: string; +} + +export interface DeleteFileBody { + committer?: { + email?: string; + name?: string; + }; + message?: string; + sha?: string; +} + +export interface Deployment { + description?: string; + payload?: { + deploy_user?: string; + environment?: string; + room_id?: number; + }; + ref?: string; +} + +export interface DeploymentResp { + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + id?: number; + payload?: string; + sha?: string; + statuses_url?: string; + updated_at?: string; + url?: string; +} + +export type DeploymentStatuses = { + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + id?: number; + payload?: string; + state?: string; + target_url?: string; + updated_at?: string; + url?: string; +}[]; + +export interface DeploymentStatusesCreate { + description?: string; + state?: string; + target_url?: string; +} + +export interface Download { + content_type?: string; + description?: string; + download_count?: number; + html_url?: string; + id?: number; + name?: string; + size?: number; + url?: string; +} + +export type Downloads = Download[]; + +export interface EditTeam { + name: string; + permission?: "pull" | "push" | "admin"; +} + +export type EmailsPost = string[]; + +export type Emojis = Record; + +export interface Event { + /** A user or organization */ + actor?: Actor; + created_at?: object; + id?: number; + /** A GitHub organization */ + org?: Organization; + payload?: object; + public?: boolean; + repo?: { + id?: number; + name?: string; + url?: string; + }; + type?: string; +} + +export type Events = Event[]; + +export interface Feeds { + _links?: { + current_user?: { + href?: string; + type?: string; + }; + current_user_actor?: { + href?: string; + type?: string; + }; + current_user_organization?: { + href?: string; + type?: string; + }; + current_user_public?: { + href?: string; + type?: string; + }; + timeline?: { + href?: string; + type?: string; + }; + user?: { + href?: string; + type?: string; + }; + }; + current_user_actor_url?: string; + current_user_organization_url?: string; + current_user_public?: string; + current_user_url?: string; + timeline_url?: string; + user_url?: string; +} + +export interface ForkBody { + organization?: string; +} + +export type Forks = Repos; + +export interface Gist { + comments?: number; + comments_url?: string; + /** Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. */ + created_at?: string; + description?: string; + files?: { + "ring.erl"?: { + filename?: string; + raw_url?: string; + size?: number; + }; + }; + forks?: { + /** Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. */ + created_at?: string; + url?: string; + /** A GitHub user */ + user?: User; + }[]; + git_pull_url?: string; + git_push_url?: string; + history?: { + change_status?: { + additions?: number; + deletions?: number; + total?: number; + }; + /** Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. */ + committed_at?: string; + url?: string; + /** A GitHub user */ + user?: User; + version?: string; + }[]; + html_url?: string; + id?: string; + public?: boolean; + url?: string; + /** A GitHub user */ + user?: User; +} + +export type Gists = { + comments?: number; + comments_url?: string; + created_at?: string; + description?: string; + files?: { + "ring.erl"?: { + filename?: string; + raw_url?: string; + size?: number; + }; + }; + git_pull_url?: string; + git_push_url?: string; + html_url?: string; + id?: string; + public?: boolean; + url?: string; + /** A GitHub user */ + user?: User; +}[]; + +export interface GitCommit { + author?: { + date?: string; + email?: string; + name?: string; + }; + message?: string; + parents?: string; + tree?: string; +} + +export interface GitRefPatch { + force?: boolean; + sha?: string; +} + +export type Gitignore = any[]; + +export interface GitignoreLang { + name?: string; + source?: string; +} + +export interface HeadBranch { + object?: { + sha?: string; + type?: string; + url?: string; + }; + ref?: string; + url?: string; +} + +export type Hook = { + active?: boolean; + config?: { + content_type?: string; + url?: string; + }; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + events?: ( + | "push" + | "issues" + | "issue_comment" + | "commit_comment" + | "pull_request" + | "pull_request_review_comment" + | "gollum" + | "watch" + | "download" + | "fork" + | "fork_apply" + | "member" + | "public" + | "team_add" + | "status" + )[]; + id?: number; + name?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; +}[]; + +export interface HookBody { + active?: boolean; + add_events?: string[]; +} + +export interface Issue { + assignee?: string; + body?: string; + labels?: string[]; + milestone?: number; + title?: string; +} + +export interface IssueEvent { + /** A user or organization */ + actor?: Actor; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + event?: string; + issue?: { + /** A GitHub user */ + assignee?: User; + body?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + closed_at?: string; + comments?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + html_url?: string; + labels?: { + color?: string; + name?: string; + url?: string; + }[]; + milestone?: { + closed_issues?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + due_on?: string; + number?: number; + open_issues?: number; + state?: "open" | "closed"; + title?: string; + url?: string; + }; + number?: number; + pull_request?: { + diff_url?: string; + html_url?: string; + patch_url?: string; + }; + state?: "open" | "closed"; + title?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; + }; + url?: string; +} + +export type IssueEvents = IssueEvent[]; + +export type Issues = { + /** A GitHub user */ + assignee?: User; + body?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + closed_at?: string; + comments?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + html_url?: string; + labels?: { + color?: string; + name?: string; + url?: string; + }[]; + milestone?: { + closed_issues?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + due_on?: string; + number?: number; + open_issues?: number; + state?: "open" | "closed"; + title?: string; + url?: string; + }; + number?: number; + pull_request?: { + diff_url?: string; + html_url?: string; + patch_url?: string; + }; + state?: "open" | "closed"; + title?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; +}[]; + +export interface IssuesComment { + body?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + html_url?: string; + id?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; +} + +export type IssuesComments = { + _links?: { + html?: { + href?: string; + }; + pull_request?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + body?: string; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + id?: number; + path?: string; + position?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; +}[]; + +export type Keys = { + id?: number; + key?: string; + title?: string; + url?: string; +}[]; + +export interface Label { + /** + * @minLength 6 + * @maxLength 6 + */ + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + /** + * @minLength 6 + * @maxLength 6 + */ + color?: string; + name?: string; + url?: string; +}[]; + +export type Languages = Record; + +export interface Markdown { + context?: string; + mode?: string; + text?: string; +} + +export interface Merge { + merged?: boolean; + message?: string; + sha?: string; +} + +export interface MergePullBody { + commit_message?: string; +} + +export interface MergesBody { + base?: string; + commit_message?: string; + head?: string; +} + +export interface MergesConflict { + /** Error message */ + message?: string; +} + +export interface MergesSuccessful { + /** A GitHub user */ + author?: User; + comments_url?: string; + commit?: { + author?: { + date?: string; + email?: string; + name?: string; + }; + comment_count?: number; + committer?: { + date?: string; + email?: string; + name?: string; + }; + message?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; + }; + /** A GitHub user */ + committer?: User; + merged?: boolean; + message?: string; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; +} + +export interface Meta { + git?: string[]; + hooks?: string[]; +} + +export interface Milestone { + closed_issues?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + due_on?: string; + number?: number; + open_issues?: number; + state?: "open" | "closed"; + title?: string; + url?: string; +} + +export interface MilestoneUpdate { + description?: string; + due_on?: string; + state?: string; + title?: string; +} + +export interface NotificationMarkRead { + last_read_at?: string; +} + +export interface Notifications { + id?: number; + last_read_at?: string; + reason?: string; + repository?: { + description?: string; + fork?: boolean; + full_name?: string; + html_url?: string; + id?: number; + name?: string; + /** A user or organization */ + owner?: Actor; + private?: boolean; + url?: string; + }; + subject?: { + latest_comment_url?: string; + title?: string; + type?: string; + url?: string; + }; + unread?: boolean; + updated_at?: string; + url?: string; +} + +export interface OrgTeamsPost { + name: string; + permission?: "pull" | "push" | "admin"; + repo_names?: string[]; +} + +/** A GitHub organization */ +export type Organization = Actor; + +export interface OrganizationAsTeamMember { + errors?: { + code?: string; + field?: string; + resource?: string; + }[]; + message?: string; +} + +export interface ParticipationStats { + all?: number[]; + owner?: number[]; +} + +export interface PatchGist { + description?: string; + files?: { + "delete_this_file.txt"?: string; + "file1.txt"?: { + content?: string; + }; + "new_file.txt"?: { + content?: string; + }; + "old_name.txt"?: { + content?: string; + filename?: string; + }; + }; +} + +export interface PatchOrg { + /** Billing email address. This address is not publicized. */ + billing_email?: string; + company?: string; + /** Publicly visible email address. */ + email?: string; + location?: string; + name?: string; +} + +export interface PostGist { + description?: string; + files?: { + "file1.txt"?: { + content?: string; + }; + }; + public?: boolean; +} + +export interface PostRepo { + /** True to create an initial commit with empty README. Default is false. */ + auto_init?: boolean; + description?: string; + /** Desired language or platform .gitignore template to apply. Use the name of the template without the extension. For example, "Haskell" Ignored if auto_init parameter is not provided. */ + gitignore_template?: string; + /** True to enable downloads for this repository, false to disable them. Default is true. */ + has_downloads?: boolean; + /** True to enable issues for this repository, false to disable them. Default is true. */ + has_issues?: boolean; + /** True to enable the wiki for this repository, false to disable it. Default is true. */ + has_wiki?: boolean; + homepage?: string; + name: string; + /** True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. */ + private?: boolean; + /** The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization. */ + team_id?: number; +} + +export interface PullRequest { + _links?: { + comments?: { + href?: string; + }; + html?: { + href?: string; + }; + review_comments?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + additions?: number; + base?: { + label?: string; + ref?: string; + repo?: Repo; + sha?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + }; + body?: string; + changed_files?: number; + closed_at?: string; + comments?: number; + commits?: number; + created_at?: string; + deletions?: number; + diff_url?: string; + head?: { + label?: string; + ref?: string; + repo?: Repo; + sha?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + }; + html_url?: string; + issue_url?: string; + merge_commit_sha?: string; + mergeable?: boolean; + merged?: boolean; + merged_at?: string; + merged_by?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + number?: number; + patch_url?: string; + state?: string; + title?: string; + updated_at?: string; + url?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; +} + +export interface PullUpdate { + body?: string; + state?: string; + title?: string; +} + +export type Pulls = { + _links?: { + comments?: { + href?: string; + }; + html?: { + href?: string; + }; + review_comments?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + base?: { + label?: string; + ref?: string; + repo?: Repo; + sha?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + }; + body?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + closed_at?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + diff_url?: string; + head?: { + label?: string; + ref?: string; + repo?: Repo; + sha?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + }; + html_url?: string; + issue_url?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + merged_at?: string; + number?: number; + patch_url?: string; + state?: "open" | "closed"; + title?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; +}[]; + +export interface PullsComment { + _links?: { + html?: { + href?: string; + }; + pull_request?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + body?: string; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + id?: number; + path?: string; + position?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; +} + +export interface PullsCommentPost { + body?: string; + commit_id?: string; + path?: string; + position?: number; +} + +export type PullsComments = { + _links?: { + html?: { + href?: string; + }; + pull_request?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + body?: string; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + id?: number; + path?: string; + position?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + user?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; +}[]; + +export interface PullsPost { + base?: string; + body?: string; + head?: string; + title?: string; +} + +export interface PutSubscription { + created_at?: string; + ignored?: boolean; + reason?: object; + subscribed?: boolean; + thread_url?: string; + url?: string; +} + +export interface RateLimit { + rate?: { + limit?: number; + remaining?: number; + reset?: number; + }; +} + +export type Ref = { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + creator?: { + avatar_url?: string; + gravatar_id?: string; + id?: number; + login?: string; + url?: string; + }; + description?: string; + id?: number; + state?: string; + target_url?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; +}[]; + +export type RefStatus = { + commit_url?: string; + name?: string; + repository_url?: string; + sha?: string; + state?: string; + statuses?: { + context?: string; + created_at?: string; + description?: string; + id?: number; + state?: string; + target_url?: string; + updated_at?: string; + url?: string; + }[]; +}[]; + +export type Refs = { + object?: { + sha?: string; + type?: string; + url?: string; + }; + ref?: string; + url?: string; +}[]; + +export interface RefsBody { + ref?: string; + sha?: string; +} + +export interface Release { + assets?: { + content_type?: string; + created_at?: string; + download_count?: number; + id?: number; + label?: string; + name?: string; + size?: number; + state?: string; + updated_at?: string; + /** A GitHub user */ + uploader?: User; + url?: string; + }[]; + assets_url?: string; + /** A GitHub user */ + author?: User; + body?: string; + created_at?: string; + draft?: boolean; + html_url?: string; + id?: number; + name?: string; + prerelease?: boolean; + published_at?: string; + tag_name?: string; + tarball_url?: string; + target_commitish?: string; + upload_url?: string; + url?: string; + zipball_url?: string; +} + +export interface ReleaseCreate { + body?: string; + draft?: boolean; + name?: string; + prerelease?: boolean; + tag_name?: string; + target_commitish?: string; +} + +export type Releases = { + assets?: { + content_type?: string; + created_at?: string; + download_count?: number; + id?: number; + label?: string; + name?: string; + size?: number; + state?: string; + updated_at?: string; + /** A GitHub user */ + uploader?: User; + url?: string; + }[]; + assets_url?: string; + /** A GitHub user */ + author?: User; + body?: string; + created_at?: string; + draft?: boolean; + html_url?: string; + id?: number; + name?: string; + prerelease?: boolean; + published_at?: string; + tag_name?: string; + tarball_url?: string; + target_commitish?: string; + upload_url?: string; + url?: string; + zipball_url?: string; +}[]; + +export interface Repo { + clone_url?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + description?: string; + fork?: boolean; + forks?: number; + forks_count?: number; + full_name?: string; + git_url?: string; + has_downloads?: boolean; + has_issues?: boolean; + has_wiki?: boolean; + homepage?: string; + html_url?: string; + id?: number; + language?: string; + master_branch?: string; + mirror_url?: string; + name?: string; + open_issues?: number; + open_issues_count?: number; + /** A GitHub organization */ + organization?: Organization; + /** A user or organization */ + owner?: Actor; + /** Is present when the repo is a fork. Parent is the repo this repo was forked from. */ + parent?: Repo; + private?: boolean; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + pushed_at?: string; + size?: number; + /** Is present when the repo is a fork. Source is the ultimate source for the network. */ + source?: Repo; + ssh_url?: string; + svn_url?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + watchers?: number; + watchers_count?: number; +} + +export type RepoDeployments = { + created_at?: string; + /** A GitHub user */ + creator?: User; + description?: string; + id?: number; + payload?: string; + sha?: string; + statuses_url?: string; + updated_at?: string; + url?: string; +}[]; + +export type RepoComments = { + body?: string; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + html_url?: string; + id?: number; + line?: number; + path?: string; + position?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; +}[]; + +export interface RepoCommit { + author?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + committer?: { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + email?: string; + name?: string; + }; + message?: string; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + tree?: { + sha?: string; + url?: string; + }; + url?: string; +} + +export interface RepoCommitBody { + author?: { + date?: string; + email?: string; + name?: string; + }; + message: string; + parents: string[]; + tree: string; +} + +export interface RepoEdit { + description?: string; + has_downloads?: boolean; + has_issues?: boolean; + has_wiki?: boolean; + homepage?: string; + name?: string; + private?: boolean; +} + +export type Repos = Repo[]; + +export interface SearchCode { + items?: { + git_url?: string; + html_url?: string; + name?: string; + path?: string; + repository?: { + archive_url?: string; + assignees_url?: string; + blobs_url?: string; + branches_url?: string; + collaborators_url?: string; + comments_url?: string; + commits_url?: string; + compare_url?: string; + contents_url?: string; + contributors_url?: string; + description?: string; + downloads_url?: string; + events_url?: string; + fork?: boolean; + forks_url?: string; + full_name?: string; + git_commits_url?: string; + git_refs_url?: string; + git_tags_url?: string; + hooks_url?: string; + html_url?: string; + id?: number; + issue_comment_url?: string; + issue_events_url?: string; + issues_url?: string; + keys_url?: string; + labels_url?: string; + languages_url?: string; + merges_url?: string; + milestones_url?: string; + name?: string; + notifications_url?: string; + /** A user or organization */ + owner?: Actor; + private?: boolean; + pulls_url?: string; + stargazers_url?: string; + statuses_url?: string; + subscribers_url?: string; + subscription_url?: string; + tags_url?: string; + teams_url?: string; + trees_url?: string; + url?: string; + }; + score?: number; + sha?: string; + url?: string; + }[]; + total_count?: number; +} + +export interface SearchIssues { + items?: { + assignee?: any; + body?: string; + closed_at?: any; + comments?: number; + comments_url?: string; + created_at?: string; + events_url?: string; + html_url?: string; + id?: number; + labels?: { + color?: string; + name?: string; + url?: string; + }[]; + labels_url?: string; + milestone?: any; + number?: number; + pull_request?: { + diff_url?: any; + html_url?: any; + patch_url?: any; + }; + score?: number; + state?: string; + title?: string; + updated_at?: string; + url?: string; + /** A GitHub user */ + user?: User; + }[]; + total_count?: number; +} + +export interface SearchIssuesByKeyword { + issues?: { + body?: string; + comments?: number; + created_at?: string; + gravatar_id?: string; + html_url?: string; + labels?: string[]; + number?: number; + position?: number; + state?: string; + title?: string; + updated_at?: string; + user?: string; + votes?: number; + }[]; +} + +export interface SearchRepositories { + items?: Repo[]; + total_count?: number; +} + +export interface SearchRepositoriesByKeyword { + repositories?: Repo[]; +} + +export interface SearchUserByEmail { + /** A GitHub user */ + user?: User; +} + +export interface SearchUsers { + items?: Users; + total_count?: number; +} + +export interface SearchUsersByKeyword { + users?: Users; +} + +export interface Subscription { + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + ignored?: boolean; + reason?: string; + repository_url?: string; + subscribed?: boolean; + thread_url?: string; + url?: string; +} + +export interface SubscriptionBody { + ignored?: boolean; + subscribed?: boolean; +} + +export interface Tag { + /** String of the tag message. */ + message?: string; + object?: { + sha?: string; + /** String of the type of the tagged object. Normally this is a commit but it can also be a tree or a blob. */ + type?: "commit" | "tree" | "blob"; + url?: string; + }; + sha?: string; + /** The tag's name. This is typically a version (e.g., "v0.0.1"). */ + tag?: string; + tagger?: { + /** Timestamp of when this object was tagged, in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + /** String of the email of the author of the tag. */ + email?: string; + /** String of the name of the author of the tag. */ + name?: string; + }; + url?: string; +} + +export interface TagBody { + /** String of the tag message. */ + message: string; + /** String of the SHA of the git object this is tagging. */ + object: string; + /** The tag's name. This is typically a version (e.g., "v0.0.1"). */ + tag: string; + tagger: { + /** Timestamp of when this object was tagged, in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + date?: string; + /** String of the email of the author of the tag. */ + email?: string; + /** String of the name of the author of the tag. */ + name?: string; + }; + /** String of the type of the object we’re tagging. Normally this is a commit but it can also be a tree or a blob. */ + type: "commit" | "tree" | "blob"; +} + +export type Tags = Tag[]; + +export interface Team { + id?: number; + members_count?: number; + name?: string; + permission?: string; + repos_count?: number; + url?: string; +} + +export interface TeamMembership { + state?: string; + url?: string; +} + +export type TeamRepos = Repos; + +export type Teams = { + id?: number; + name?: string; + url?: string; +}[]; + +export type TeamsList = { + id?: number; + members_count?: number; + name?: string; + organization?: { + avatar_url?: string; + id?: number; + login?: string; + url?: string; + }; + permission?: string; + repos_count?: number; + url?: string; +}[]; + +export interface Tree { + sha?: string; + tree?: { + /** One of 100644 for file (blob), 100755 for executable (blob), 040000 for subdirectory (tree), 160000 for submodule (commit) or 120000 for a blob that specifies the path of a symlink. */ + mode?: "100644" | "100755" | "040000" | "160000" | "120000"; + path?: string; + /** SHA1 checksum ID of the object in the tree. */ + sha?: string; + size?: number; + type?: "blob" | "tree" | "commit"; + url?: string; + }[]; + url?: string; +} + +export interface Trees { + base_tree?: string; + /** SHA1 checksum ID of the object in the tree. */ + sha?: string; + tree?: Tree[]; + url?: string; +} + +/** A GitHub user */ +export type User = Actor; + +export type UserEmails = string[]; + +export interface UserKeysKeyId { + id?: number; + key?: string; + title?: string; + url?: string; +} + +export interface UserKeysPost { + key?: string; + title?: string; +} + +export interface UserUpdate { + bio?: string; + blog?: string; + company?: string; + email?: string; + hireable?: boolean; + location?: string; + name?: string; +} + +export type Users = User[]; + +import type { $Fetch, FetchOptions } from "ofetch"; +import { $fetch } from "ofetch"; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface CustomFetchOptions extends FetchOptions { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseURL?: string; + basePath?: string; + baseSiteId?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: $Fetch; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseURL: string = "https://api.github.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (url: string, fetchParams: FetchOptions) => $fetch(url, fetchParams); + public basePath: string = "https://api.github.com"; + public baseSiteId: string = "roller"; + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType | null) => { + this.securityData = data; + }; + + protected mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + protected createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = async ( + url: string, + { body, secure, method, baseURL, signal, params, ...options }: CustomFetchOptions, + ): Promise => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestOptions = this.mergeRequestParams(options, secureParams); + + return this.customFetch(`${baseURL || this.baseURL || ""}${this.basePath ? `${this.basePath}` : ""}${url}`, { + params, + method, + ...requestOptions, + signal, + body, + }).then((response: T) => response); + }; +} + +/** + * @title GitHub + * @version v3 + * @termsOfService https://help.github.com/articles/github-terms-of-service/#b-api-terms + * @baseUrl https://api.github.com + * @externalDocs https://developer.github.com/v3/ + * + * Powerful collaboration, code review, and code management for open source and private projects. + */ +export class Api extends HttpClient { + someTest = { + /** + * @description This type should test bug https://github.com/acacode/swagger-typescript-api/issues/156 NOTE: all properties should be required + * + * @name SomeTestList + * @request GET:/some-test + */ + someTestList: (params: RequestParams = {}) => + this.request<{ + user: { + foo: number; + extra: { + id: number; + extra: { + foo: string; + bar: number; + baz: string; + bad: number; + extra: { + foo: string; + bar: number; + baz: string; + bad: number; + extra: { + foo: string; + bar: number; + baz: string; + bad: number; + extra: { + foo: string; + bar: number; + baz: string; + bad: number; + }; + }; + }; + }; + }; + }; + }>(`/some-test`, { + method: "GET", + ...params, + }), + }; + pathParams = { + /** + * @description Lists all the emojis available to use on GitHub. + * + * @name PathParamsList + * @request GET:/path-params + */ + pathParamsList: (petId: number, params: RequestParams = {}) => + this.request(`/path-params`, { + method: "GET", + ...params, + }), + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + */ + eventsList: (params: RequestParams = {}) => + this.request(`/events`, { + method: "GET", + ...params, + }), + }; + feeds = { + /** + * @description List Feeds. GitHub provides several timeline resources in Atom format. The Feeds API lists all the feeds available to the authenticating user. + * + * @name FeedsList + * @request GET:/feeds + */ + feedsList: (params: RequestParams = {}) => + this.request(`/feeds`, { + method: "GET", + ...params, + }), + }; + gists = { + /** + * @description List the authenticated user's gists or if called anonymously, this will return all public gists. + * + * @name GistsList + * @request GET:/gists + */ + gistsList: ( + query?: { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/gists`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + */ + gistsCreate: (body: PostGist, params: RequestParams = {}) => + this.request(`/gists`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description List all public gists. + * + * @name PublicList + * @request GET:/gists/public + */ + publicList: ( + query?: { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/gists/public`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description List the authenticated user's starred gists. + * + * @name StarredList + * @request GET:/gists/starred + */ + starredList: ( + query?: { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/gists/starred`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => + this.request(`/gists/${id}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}/comments`, { + method: "GET", + ...params, + }), + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => + this.request(`/gists/${id}/comments`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.request(`/gists/${id}/comments/${commentId}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name CommentsDetail2 + * @request GET:/gists/{id}/comments/{commentId} + * @originalName commentsDetail + * @duplicate + */ + commentsDetail2: (id: number, commentId: number, params: RequestParams = {}) => + this.request(`/gists/${id}/comments/${commentId}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => + this.request(`/gists/${id}/comments/${commentId}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}/forks`, { + method: "POST", + ...params, + }), + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + starDelete: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}/star`, { + method: "DELETE", + ...params, + }), + + /** + * @description Check if a gist is starred. + * + * @name StarDetail + * @request GET:/gists/{id}/star + */ + starDetail: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}/star`, { + method: "GET", + ...params, + }), + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.request(`/gists/${id}/star`, { + method: "PUT", + ...params, + }), + }; + gitignore = { + /** + * @description Listing available templates. List all templates available to pass as an option when creating a repository. + * + * @name TemplatesList + * @request GET:/gitignore/templates + */ + templatesList: (params: RequestParams = {}) => + this.request(`/gitignore/templates`, { + method: "GET", + ...params, + }), + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.request(`/gitignore/templates/${language}`, { + method: "GET", + ...params, + }), + }; + issues = { + /** + * @description List issues. List all issues across all the authenticated user's visible repositories. + * + * @name IssuesList + * @request GET:/issues + */ + issuesList: ( + query: { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * @default "all" + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + /** @default "open" */ + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + /** @default "created" */ + sort: "created" | "updated" | "comments"; + /** @default "desc" */ + direction: "asc" | "desc"; + /** + * Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Only issues updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/issues`, { + method: "GET", + query: query, + ...params, + }), + }; + legacy = { + /** + * @description Find issues by state and keyword. + * + * @name IssuesSearchDetail + * @request GET:/legacy/issues/search/{owner}/{repository}/{state}/{keyword} + * @deprecated + */ + issuesSearchDetail: ( + keyword: string, + state: "open" | "closed", + owner: string, + repository: string, + params: RequestParams = {}, + ) => + this.request(`/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, { + method: "GET", + ...params, + }), + + /** + * @description Find repositories by keyword. Note, this legacy method does not follow the v3 pagination pattern. This method returns up to 100 results per page and pages can be fetched using the start_page parameter. + * + * @name ReposSearchDetail + * @request GET:/legacy/repos/search/{keyword} + * @deprecated + */ + reposSearchDetail: ( + keyword: string, + query?: { + /** + * The sort field. if sort param is provided. Can be either asc or desc. + * @default "desc" + */ + order?: "desc" | "asc"; + /** Filter results by language */ + language?: string; + /** The page number to fetch */ + start_page?: string; + /** The sort field. One of stars, forks, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "stars" | "forks"; + }, + params: RequestParams = {}, + ) => + this.request(`/legacy/repos/search/${keyword}`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description This API call is added for compatibility reasons only. + * + * @name UserEmailDetail + * @request GET:/legacy/user/email/{email} + * @deprecated + */ + userEmailDetail: (email: string, params: RequestParams = {}) => + this.request(`/legacy/user/email/${email}`, { + method: "GET", + ...params, + }), + + /** + * @description Find users by keyword. + * + * @name UserSearchDetail + * @request GET:/legacy/user/search/{keyword} + * @deprecated + */ + userSearchDetail: ( + keyword: string, + query?: { + /** + * The sort field. if sort param is provided. Can be either asc or desc. + * @default "desc" + */ + order?: "desc" | "asc"; + /** The page number to fetch */ + start_page?: string; + /** The sort field. One of stars, forks, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "stars" | "forks"; + }, + params: RequestParams = {}, + ) => + this.request(`/legacy/user/search/${keyword}`, { + method: "GET", + query: query, + ...params, + }), + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + */ + markdownCreate: (body: Markdown, params: RequestParams = {}) => + this.request(`/markdown`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + */ + postMarkdown: (params: RequestParams = {}) => + this.request(`/markdown/raw`, { + method: "POST", + ...params, + }), + }; + meta = { + /** + * @description This gives some information about GitHub.com, the service. + * + * @name MetaList + * @request GET:/meta + */ + metaList: (params: RequestParams = {}) => + this.request(`/meta`, { + method: "GET", + ...params, + }), + }; + networks = { + /** + * @description List public events for a network of repositories. + * + * @name EventsDetail + * @request GET:/networks/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/networks/${owner}/${repo}/events`, { + method: "GET", + ...params, + }), + }; + notifications = { + /** + * @description List your notifications. List all notifications for the current user, grouped by repository. + * + * @name NotificationsList + * @request GET:/notifications + */ + notificationsList: ( + query?: { + /** True to show notifications marked as read. */ + all?: boolean; + /** + * True to show only notifications in which the user is directly participating + * or mentioned. + */ + participating?: boolean; + /** + * The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Example: "2012-10-09T23:39:01Z". + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/notifications`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Mark as read. Marking a notification as "read" removes it from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/notifications + */ + notificationsUpdate: (body: NotificationMarkRead, params: RequestParams = {}) => + this.request(`/notifications`, { + method: "PUT", + body: body, + ...params, + }), + + /** + * @description View a single thread. + * + * @name ThreadsDetail + * @request GET:/notifications/threads/{id} + */ + threadsDetail: (id: number, params: RequestParams = {}) => + this.request(`/notifications/threads/${id}`, { + method: "GET", + ...params, + }), + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.request(`/notifications/threads/${id}`, { + method: "PATCH", + ...params, + }), + + /** + * @description Delete a Thread Subscription. + * + * @name ThreadsSubscriptionDelete + * @request DELETE:/notifications/threads/{id}/subscription + */ + threadsSubscriptionDelete: (id: number, params: RequestParams = {}) => + this.request(`/notifications/threads/${id}/subscription`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a Thread Subscription. + * + * @name ThreadsSubscriptionDetail + * @request GET:/notifications/threads/{id}/subscription + */ + threadsSubscriptionDetail: (id: number, params: RequestParams = {}) => + this.request(`/notifications/threads/${id}/subscription`, { + method: "GET", + ...params, + }), + + /** + * @description Set a Thread Subscription. This lets you subscribe to a thread, or ignore it. Subscribing to a thread is unnecessary if the user is already subscribed to the repository. Ignoring a thread will mute all future notifications (until you comment or get @mentioned). + * + * @name ThreadsSubscriptionUpdate + * @request PUT:/notifications/threads/{id}/subscription + */ + threadsSubscriptionUpdate: (id: number, body: PutSubscription, params: RequestParams = {}) => + this.request(`/notifications/threads/${id}/subscription`, { + method: "PUT", + body: body, + ...params, + }), + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.request(`/orgs/${org}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => + this.request(`/orgs/${org}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/events`, { + method: "GET", + ...params, + }), + + /** + * @description List issues. List all issues for a given organization for the authenticated user. + * + * @name IssuesDetail + * @request GET:/orgs/{org}/issues + */ + issuesDetail: ( + org: string, + query: { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * @default "all" + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + /** @default "open" */ + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + /** @default "created" */ + sort: "created" | "updated" | "comments"; + /** @default "desc" */ + direction: "asc" | "desc"; + /** + * Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Only issues updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/orgs/${org}/issues`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Members list. List all users who are members of an organization. A member is a user tha belongs to at least 1 team in the organization. If the authenticated user is also an owner of this organization then both concealed and public members will be returned. If the requester is not an owner of the organization the query will be redirected to the public members list. + * + * @name MembersDetail + * @request GET:/orgs/{org}/members + */ + membersDetail: (org: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/members`, { + method: "GET", + ...params, + }), + + /** + * @description Remove a member. Removing a user from this list will remove them from all teams and they will no longer have any access to the organization's repositories. + * + * @name MembersDelete + * @request DELETE:/orgs/{org}/members/{username} + */ + membersDelete: (org: string, username: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/members/${username}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Check if a user is, publicly or privately, a member of the organization. + * + * @name MembersDetail2 + * @request GET:/orgs/{org}/members/{username} + * @originalName membersDetail + * @duplicate + */ + membersDetail2: (org: string, username: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/members/${username}`, { + method: "GET", + ...params, + }), + + /** + * @description Public members list. Members of an organization can choose to have their membership publicized or not. + * + * @name PublicMembersDetail + * @request GET:/orgs/{org}/public_members + */ + publicMembersDetail: (org: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/public_members`, { + method: "GET", + ...params, + }), + + /** + * @description Conceal a user's membership. + * + * @name PublicMembersDelete + * @request DELETE:/orgs/{org}/public_members/{username} + */ + publicMembersDelete: (org: string, username: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/public_members/${username}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Check public membership. + * + * @name PublicMembersDetail2 + * @request GET:/orgs/{org}/public_members/{username} + * @originalName publicMembersDetail + * @duplicate + */ + publicMembersDetail2: (org: string, username: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/public_members/${username}`, { + method: "GET", + ...params, + }), + + /** + * @description Publicize a user's membership. + * + * @name PublicMembersUpdate + * @request PUT:/orgs/{org}/public_members/{username} + */ + publicMembersUpdate: (org: string, username: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/public_members/${username}`, { + method: "PUT", + ...params, + }), + + /** + * @description List repositories for the specified org. + * + * @name ReposDetail + * @request GET:/orgs/{org}/repos + */ + reposDetail: ( + org: string, + query?: { + /** @default "all" */ + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request(`/orgs/${org}/repos`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/orgs/{org}/repos + */ + reposCreate: (org: string, body: PostRepo, params: RequestParams = {}) => + this.request(`/orgs/${org}/repos`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.request(`/orgs/${org}/teams`, { + method: "GET", + ...params, + }), + + /** + * @description Create team. In order to create a team, the authenticated user must be an owner of organization. + * + * @name TeamsCreate + * @request POST:/orgs/{org}/teams + */ + teamsCreate: (org: string, body: OrgTeamsPost, params: RequestParams = {}) => + this.request(`/orgs/${org}/teams`, { + method: "POST", + body: body, + ...params, + }), + }; + rateLimit = { + /** + * @description Get your current rate limit status Note: Accessing this endpoint does not count against your rate limit. + * + * @name RateLimitList + * @request GET:/rate_limit + */ + rateLimitList: (params: RequestParams = {}) => + this.request(`/rate_limit`, { + method: "GET", + ...params, + }), + }; + repos = { + /** + * @description Delete a Repository. Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required. + * + * @name ReposDelete + * @request DELETE:/repos/{owner}/{repo} + */ + reposDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get repository. + * + * @name ReposDetail + * @request GET:/repos/{owner}/{repo} + */ + reposDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List assignees. This call lists all the available assignees (owner + collaborators) to which issues may be assigned. + * + * @name AssigneesDetail + * @request GET:/repos/{owner}/{repo}/assignees + */ + assigneesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/assignees`, { + method: "GET", + ...params, + }), + + /** + * @description Check assignee. You may also check to see if a particular user is an assignee for a repository. + * + * @name AssigneesDetail2 + * @request GET:/repos/{owner}/{repo}/assignees/{assignee} + * @originalName assigneesDetail + * @duplicate + */ + assigneesDetail2: (owner: string, repo: string, assignee: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/assignees/${assignee}`, { + method: "GET", + ...params, + }), + + /** + * @description Get list of branches + * + * @name BranchesDetail + * @request GET:/repos/{owner}/{repo}/branches + */ + branchesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/branches`, { + method: "GET", + ...params, + }), + + /** + * @description Get Branch + * + * @name BranchesDetail2 + * @request GET:/repos/{owner}/{repo}/branches/{branch} + * @originalName branchesDetail + * @duplicate + */ + branchesDetail2: (owner: string, repo: string, branch: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/branches/${branch}`, { + method: "GET", + ...params, + }), + + /** + * @description List. When authenticating as an organization owner of an organization-owned repository, all organization owners are included in the list of collaborators. Otherwise, only users with access to the repository are returned in the collaborators list. + * + * @name CollaboratorsDetail + * @request GET:/repos/{owner}/{repo}/collaborators + */ + collaboratorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/collaborators`, { + method: "GET", + ...params, + }), + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/collaborators/${user}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Check if user is a collaborator + * + * @name CollaboratorsDetail2 + * @request GET:/repos/{owner}/{repo}/collaborators/{user} + * @originalName collaboratorsDetail + * @duplicate + */ + collaboratorsDetail2: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/collaborators/${user}`, { + method: "GET", + ...params, + }), + + /** + * @description Add collaborator. + * + * @name CollaboratorsUpdate + * @request PUT:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsUpdate: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/collaborators/${user}`, { + method: "PUT", + ...params, + }), + + /** + * @description List commit comments for a repository. Comments are ordered by ascending ID. + * + * @name CommentsDetail + * @request GET:/repos/{owner}/{repo}/comments + */ + commentsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/comments`, { + method: "GET", + ...params, + }), + + /** + * @description Delete a commit comment + * + * @name CommentsDelete + * @request DELETE:/repos/{owner}/{repo}/comments/{commentId} + */ + commentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/comments/${commentId}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a single commit comment. + * + * @name CommentsDetail2 + * @request GET:/repos/{owner}/{repo}/comments/{commentId} + * @originalName commentsDetail + * @duplicate + */ + commentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/comments/${commentId}`, { + method: "GET", + ...params, + }), + + /** + * @description Update a commit comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/comments/{commentId} + */ + commentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/comments/${commentId}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List commits on a repository. + * + * @name CommitsDetail + * @request GET:/repos/{owner}/{repo}/commits + */ + commitsDetail: ( + owner: string, + repo: string, + query?: { + /** + * The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Example: "2012-10-09T23:39:01Z". + */ + since?: string; + /** Sha or branch to start listing commits from. */ + sha?: string; + /** Only commits containing this file path will be returned. */ + path?: string; + /** GitHub login, name, or email by which to filter by commit author. */ + author?: string; + /** ISO 8601 Date - Only commits before this date will be returned. */ + until?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/commits`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Get the combined Status for a specific Ref The Combined status endpoint is currently available for developers to preview. During the preview period, the API may change without advance notice. Please see the blog post for full details. To access this endpoint during the preview period, you must provide a custom media type in the Accept header: application/vnd.github.she-hulk-preview+json + * + * @name CommitsStatusDetail + * @request GET:/repos/{owner}/{repo}/commits/{ref}/status + */ + commitsStatusDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/commits/${ref}/status`, { + method: "GET", + ...params, + }), + + /** + * @description Get a single commit. + * + * @name CommitsDetail2 + * @request GET:/repos/{owner}/{repo}/commits/{shaCode} + * @originalName commitsDetail + * @duplicate + */ + commitsDetail2: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/commits/${shaCode}`, { + method: "GET", + ...params, + }), + + /** + * @description List comments for a single commitList comments for a single commit. + * + * @name CommitsCommentsDetail + * @request GET:/repos/{owner}/{repo}/commits/{shaCode}/comments + */ + commitsCommentsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/commits/${shaCode}/comments`, { + method: "GET", + ...params, + }), + + /** + * @description Create a commit comment. + * + * @name CommitsCommentsCreate + * @request POST:/repos/{owner}/{repo}/commits/{shaCode}/comments + */ + commitsCommentsCreate: ( + owner: string, + repo: string, + shaCode: string, + body: CommitCommentBody, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/commits/${shaCode}/comments`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Compare two commits + * + * @name CompareDetail + * @request GET:/repos/{owner}/{repo}/compare/{baseId}...{headId} + */ + compareDetail: (owner: string, repo: string, baseId: string, headId: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/compare/${baseId}...${headId}`, { + method: "GET", + ...params, + }), + + /** + * @description Delete a file. This method deletes a file in a repository. + * + * @name ContentsDelete + * @request DELETE:/repos/{owner}/{repo}/contents/{path} + */ + contentsDelete: (owner: string, repo: string, path: string, body: DeleteFileBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/contents/${path}`, { + method: "DELETE", + body: body, + ...params, + }), + + /** + * @description Get contents. This method returns the contents of a file or directory in a repository. Files and symlinks support a custom media type for getting the raw content. Directories and submodules do not support custom media types. Note: This API supports files up to 1 megabyte in size. Here can be many outcomes. For details see "http://developer.github.com/v3/repos/contents/" + * + * @name ContentsDetail + * @request GET:/repos/{owner}/{repo}/contents/{path} + */ + contentsDetail: ( + owner: string, + repo: string, + path: string, + query?: { + /** The content path. */ + path?: string; + /** The String name of the Commit/Branch/Tag. Defaults to 'master'. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/contents/${path}`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Create a file. + * + * @name ContentsUpdate + * @request PUT:/repos/{owner}/{repo}/contents/{path} + */ + contentsUpdate: (owner: string, repo: string, path: string, body: CreateFileBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/contents/${path}`, { + method: "PUT", + body: body, + ...params, + }), + + /** + * @description Get list of contributors. + * + * @name ContributorsDetail + * @request GET:/repos/{owner}/{repo}/contributors + */ + contributorsDetail: ( + owner: string, + repo: string, + query: { + /** Set to 1 or true to include anonymous contributors in results. */ + anon: string; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/contributors`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Users with pull access can view deployments for a repository + * + * @name DeploymentsDetail + * @request GET:/repos/{owner}/{repo}/deployments + */ + deploymentsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/deployments`, { + method: "GET", + ...params, + }), + + /** + * @description Users with push access can create a deployment for a given ref + * + * @name DeploymentsCreate + * @request POST:/repos/{owner}/{repo}/deployments + */ + deploymentsCreate: (owner: string, repo: string, body: Deployment, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/deployments`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Users with pull access can view deployment statuses for a deployment + * + * @name DeploymentsStatusesDetail + * @request GET:/repos/{owner}/{repo}/deployments/{id}/statuses + */ + deploymentsStatusesDetail: (owner: string, repo: string, id: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/deployments/${id}/statuses`, { + method: "GET", + ...params, + }), + + /** + * @description Create a Deployment Status Users with push access can create deployment statuses for a given deployment: + * + * @name DeploymentsStatusesCreate + * @request POST:/repos/{owner}/{repo}/deployments/{id}/statuses + */ + deploymentsStatusesCreate: ( + owner: string, + repo: string, + id: number, + body: DeploymentStatusesCreate, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/deployments/${id}/statuses`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Deprecated. List downloads for a repository. + * + * @name DownloadsDetail + * @request GET:/repos/{owner}/{repo}/downloads + * @deprecated + */ + downloadsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/downloads`, { + method: "GET", + ...params, + }), + + /** + * @description Deprecated. Delete a download. + * + * @name DownloadsDelete + * @request DELETE:/repos/{owner}/{repo}/downloads/{downloadId} + * @deprecated + */ + downloadsDelete: (owner: string, repo: string, downloadId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/downloads/${downloadId}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Deprecated. Get a single download. + * + * @name DownloadsDetail2 + * @request GET:/repos/{owner}/{repo}/downloads/{downloadId} + * @deprecated + * @originalName downloadsDetail + * @duplicate + */ + downloadsDetail2: (owner: string, repo: string, downloadId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/downloads/${downloadId}`, { + method: "GET", + ...params, + }), + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/events`, { + method: "GET", + ...params, + }), + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + /** @default "newes" */ + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/forks`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Create a fork. Forking a Repository happens asynchronously. Therefore, you may have to wai a short period before accessing the git objects. If this takes longer than 5 minutes, be sure to contact Support. + * + * @name ForksCreate + * @request POST:/repos/{owner}/{repo}/forks + */ + forksCreate: (owner: string, repo: string, body: ForkBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/forks`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Create a Blob. + * + * @name GitBlobsCreate + * @request POST:/repos/{owner}/{repo}/git/blobs + */ + gitBlobsCreate: (owner: string, repo: string, body: Blob, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/blobs`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Get a Blob. Since blobs can be any arbitrary binary data, the input and responses for the blob API takes an encoding parameter that can be either utf-8 or base64. If your data cannot be losslessly sent as a UTF-8 string, you can base64 encode it. + * + * @name GitBlobsDetail + * @request GET:/repos/{owner}/{repo}/git/blobs/{shaCode} + */ + gitBlobsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/blobs/${shaCode}`, { + method: "GET", + ...params, + }), + + /** + * @description Create a Commit. + * + * @name GitCommitsCreate + * @request POST:/repos/{owner}/{repo}/git/commits + */ + gitCommitsCreate: (owner: string, repo: string, body: RepoCommitBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/commits`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Get a Commit. + * + * @name GitCommitsDetail + * @request GET:/repos/{owner}/{repo}/git/commits/{shaCode} + */ + gitCommitsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/commits/${shaCode}`, { + method: "GET", + ...params, + }), + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/refs`, { + method: "GET", + ...params, + }), + + /** + * @description Create a Reference + * + * @name GitRefsCreate + * @request POST:/repos/{owner}/{repo}/git/refs + */ + gitRefsCreate: (owner: string, repo: string, body: RefsBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/refs`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Delete a Reference Example: Deleting a branch: DELETE /repos/octocat/Hello-World/git/refs/heads/feature-a Example: Deleting a tag: DELETE /repos/octocat/Hello-World/git/refs/tags/v1.0 + * + * @name GitRefsDelete + * @request DELETE:/repos/{owner}/{repo}/git/refs/{ref} + */ + gitRefsDelete: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/refs/${ref}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a Reference + * + * @name GitRefsDetail2 + * @request GET:/repos/{owner}/{repo}/git/refs/{ref} + * @originalName gitRefsDetail + * @duplicate + */ + gitRefsDetail2: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/refs/${ref}`, { + method: "GET", + ...params, + }), + + /** + * @description Update a Reference + * + * @name GitRefsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/git/refs/{ref} + */ + gitRefsPartialUpdate: (owner: string, repo: string, ref: string, body: GitRefPatch, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/refs/${ref}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description Create a Tag Object. Note that creating a tag object does not create the reference that makes a tag in Git. If you want to create an annotated tag in Git, you have to do this call to create the tag object, and then create the refs/tags/[tag] reference. If you want to create a lightweight tag, you only have to create the tag reference - this call would be unnecessary. + * + * @name GitTagsCreate + * @request POST:/repos/{owner}/{repo}/git/tags + */ + gitTagsCreate: (owner: string, repo: string, body: TagBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/tags`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Get a Tag. + * + * @name GitTagsDetail + * @request GET:/repos/{owner}/{repo}/git/tags/{shaCode} + */ + gitTagsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/tags/${shaCode}`, { + method: "GET", + ...params, + }), + + /** + * @description Create a Tree. The tree creation API will take nested entries as well. If both a tree and a nested path modifying that tree are specified, it will overwrite the contents of that tree with the new path contents and write a new tree out. + * + * @name GitTreesCreate + * @request POST:/repos/{owner}/{repo}/git/trees + */ + gitTreesCreate: (owner: string, repo: string, body: Tree, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/git/trees`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Get a Tree. + * + * @name GitTreesDetail + * @request GET:/repos/{owner}/{repo}/git/trees/{shaCode} + */ + gitTreesDetail: ( + owner: string, + repo: string, + shaCode: string, + query?: { + /** Get a Tree Recursively. (0 or 1) */ + recursive?: number; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/git/trees/${shaCode}`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks`, { + method: "GET", + ...params, + }), + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description Delete a hook. + * + * @name HooksDelete + * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} + */ + hooksDelete: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks/${hookId}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get single hook. + * + * @name HooksDetail2 + * @request GET:/repos/{owner}/{repo}/hooks/{hookId} + * @originalName hooksDetail + * @duplicate + */ + hooksDetail2: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks/${hookId}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit a hook. + * + * @name HooksPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/hooks/{hookId} + */ + hooksPartialUpdate: (owner: string, repo: string, hookId: number, body: HookBody, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks/${hookId}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description Test a push hook. This will trigger the hook with the latest push to the current repository if the hook is subscribed to push events. If the hook is not subscribed to push events, the server will respond with 204 but no test POST will be generated. Note: Previously /repos/:owner/:repo/hooks/:id/tes + * + * @name HooksTestsCreate + * @request POST:/repos/{owner}/{repo}/hooks/{hookId}/tests + */ + hooksTestsCreate: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/hooks/${hookId}/tests`, { + method: "POST", + ...params, + }), + + /** + * @description List issues for a repository. + * + * @name IssuesDetail + * @request GET:/repos/{owner}/{repo}/issues + */ + issuesDetail: ( + owner: string, + repo: string, + query: { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * @default "all" + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + /** @default "open" */ + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + /** @default "created" */ + sort: "created" | "updated" | "comments"; + /** @default "desc" */ + direction: "asc" | "desc"; + /** + * Optional string of a timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Only issues updated at or after this time are returned. + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/issues`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Create an issue. Any user with pull access to a repository can create an issue. + * + * @name IssuesCreate + * @request POST:/repos/{owner}/{repo}/issues + */ + issuesCreate: (owner: string, repo: string, body: Issue, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description List comments in a repository. + * + * @name IssuesCommentsDetail + * @request GET:/repos/{owner}/{repo}/issues/comments + */ + issuesCommentsDetail: ( + owner: string, + repo: string, + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + /** + * The time should be passed in as UTC in the ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ. + * Example: "2012-10-09T23:39:01Z". + */ + since?: string; + }, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/issues/comments`, { + method: "GET", + query: query, + ...params, + }), + + /** + * @description Delete a comment. + * + * @name IssuesCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/comments/{commentId} + */ + issuesCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/comments/${commentId}`, { + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name IssuesCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/issues/comments/{commentId} + * @originalName issuesCommentsDetail + * @duplicate + */ + issuesCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/comments/${commentId}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name IssuesCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/issues/comments/{commentId} + */ + issuesCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/issues/comments/${commentId}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List issue events for a repository. + * + * @name IssuesEventsDetail + * @request GET:/repos/{owner}/{repo}/issues/events + */ + issuesEventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/events`, { + method: "GET", + ...params, + }), + + /** + * @description Get a single event. + * + * @name IssuesEventsDetail2 + * @request GET:/repos/{owner}/{repo}/issues/events/{eventId} + * @originalName issuesEventsDetail + * @duplicate + */ + issuesEventsDetail2: (owner: string, repo: string, eventId: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/events/${eventId}`, { + method: "GET", + ...params, + }), + + /** + * @description Get a single issue + * + * @name IssuesDetail2 + * @request GET:/repos/{owner}/{repo}/issues/{number} + * @originalName issuesDetail + * @duplicate + */ + issuesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}`, { + method: "GET", + ...params, + }), + + /** + * @description Edit an issue. Issue owners and users with push access can edit an issue. + * + * @name IssuesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/issues/{number} + */ + issuesPartialUpdate: (owner: string, repo: string, number: number, body: Issue, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}`, { + method: "PATCH", + body: body, + ...params, + }), + + /** + * @description List comments on an issue. + * + * @name IssuesCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/comments + * @originalName issuesCommentsDetail + * @duplicate + */ + issuesCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}/comments`, { + method: "GET", + ...params, + }), + + /** + * @description Create a comment. + * + * @name IssuesCommentsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/comments + */ + issuesCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request(`/repos/${owner}/${repo}/issues/${number}/comments`, { + method: "POST", + body: body, + ...params, + }), + + /** + * @description List events for an issue. + * + * @name IssuesEventsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/events + * @originalName issuesEventsDetail + * @duplicate + */ + issuesEventsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}/events`, { + method: "GET", + ...params, + }), + + /** + * @description Remove all labels from an issue. + * + * @name IssuesLabelsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}/labels`, { + method: "DELETE", + ...params, + }), + + /** + * @description List labels on an issue. + * + * @name IssuesLabelsDetail + * @request GET:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request(`/repos/${owner}/${repo}/issues/${number}/labels`, { + method: "GET", + ...params, + }), + + /** + * @description Add labels to an issue. + * + * @name IssuesLabelsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsCreate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => + this.request