diff --git a/CHANGELOG.md b/CHANGELOG.md index 979086ba..de3457b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,11 @@ -# next release +# next release + +# 10.0.3 +fix: CRLF -> LF (#423) +docs: add docs for addReadonly nodeJS api flag (#425) +chore: remove useless trailing whitespaces which make test edit harder (thanks @qboot, #422) +internal: add test snapshots (git diff + nodejs assertions) +chore: add logging (project version, node version, npm version) # 10.0.2 diff --git a/README.md b/README.md index a86226b7..804fa22e 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,7 @@ generateApi({ enumNamesAsValues: false, moduleNameFirstTag: false, generateUnionEnums: false, + addReadonly: false, extraTemplates: [], hooks: { onCreateComponent: (component) => {}, diff --git a/index.d.ts b/index.d.ts index f71d5cf1..85f9ef7a 100644 --- a/index.d.ts +++ b/index.d.ts @@ -123,6 +123,10 @@ interface GenerateApiParamsBase { * authorization token */ authorizationToken?: string; + /** + * generate readonly properties (default: false) + */ + addReadonly?: boolean; } interface GenerateApiParamsFromPath extends GenerateApiParamsBase { diff --git a/package-lock.json b/package-lock.json index 783a43db..2cb0edf7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "swagger-typescript-api", - "version": "10.0.2", + "version": "10.0.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "swagger-typescript-api", - "version": "10.0.2", + "version": "10.0.3", "license": "MIT", "dependencies": { "@types/swagger-schema-official": "2.0.22", @@ -34,6 +34,7 @@ "@types/node": "^15.0.2", "@types/prettier": "^2.7.0", "all-contributors-cli": "^6.20.0", + "cross-env": "^7.0.3", "git-diff": "^2.0.6", "husky": "^4.3.6", "pretty-quick": "^3.1.0" @@ -531,6 +532,38 @@ "node": ">=10" } }, + "node_modules/cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "dependencies": { + "cross-spawn": "^7.0.1" + }, + "bin": { + "cross-env": "src/bin/cross-env.js", + "cross-env-shell": "src/bin/cross-env-shell.js" + }, + "engines": { + "node": ">=10.14", + "npm": ">=6", + "yarn": ">=1" + } + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -640,65 +673,6 @@ "url": "https://github.com/sindresorhus/execa?sponsor=1" } }, - "node_modules/execa/node_modules/cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "dependencies": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - }, - "engines": { - "node": ">= 8" - } - }, - "node_modules/execa/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/execa/node_modules/shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "dependencies": { - "shebang-regex": "^3.0.0" - }, - "engines": { - "node": ">=8" - } - }, - "node_modules/execa/node_modules/shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true, - "engines": { - "node": ">=8" - } - }, - "node_modules/execa/node_modules/which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "dependencies": { - "isexe": "^2.0.0" - }, - "bin": { - "node-which": "bin/node-which" - }, - "engines": { - "node": ">= 8" - } - }, "node_modules/external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -1187,7 +1161,7 @@ "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "node_modules/js-tokens": { @@ -1498,15 +1472,6 @@ "node": ">=8" } }, - "node_modules/npm-run-path/node_modules/path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true, - "engines": { - "node": ">=8" - } - }, "node_modules/oas-kit-common": { "version": "1.0.8", "resolved": "https://registry.npmjs.org/oas-kit-common/-/oas-kit-common-1.0.8.tgz", @@ -1696,6 +1661,15 @@ "node": ">=0.10.0" } }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -1995,6 +1969,27 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/shelljs": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", @@ -2238,6 +2233,21 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", @@ -2745,6 +2755,26 @@ "yaml": "^1.10.0" } }, + "cross-env": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-env/-/cross-env-7.0.3.tgz", + "integrity": "sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.1" + } + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, "decamelize": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz", @@ -2825,49 +2855,6 @@ "onetime": "^5.1.0", "signal-exit": "^3.0.2", "strip-final-newline": "^2.0.0" - }, - "dependencies": { - "cross-spawn": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", - "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", - "dev": true, - "requires": { - "path-key": "^3.1.0", - "shebang-command": "^2.0.0", - "which": "^2.0.1" - } - }, - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - }, - "shebang-command": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", - "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", - "dev": true, - "requires": { - "shebang-regex": "^3.0.0" - } - }, - "shebang-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", - "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", - "dev": true - }, - "which": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", - "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", - "dev": true, - "requires": { - "isexe": "^2.0.0" - } - } } }, "external-editor": { @@ -3222,7 +3209,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, "js-tokens": { @@ -3448,14 +3435,6 @@ "dev": true, "requires": { "path-key": "^3.0.0" - }, - "dependencies": { - "path-key": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", - "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", - "dev": true - } } }, "oas-kit-common": { @@ -3593,6 +3572,12 @@ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, "path-parse": { "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", @@ -3810,6 +3795,21 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "dev": true }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, "shelljs": { "version": "0.8.5", "resolved": "https://registry.npmjs.org/shelljs/-/shelljs-0.8.5.tgz", @@ -3999,6 +3999,15 @@ "webidl-conversions": "^3.0.0" } }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + }, "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", diff --git a/package.json b/package.json index 205a9f53..0e3640a1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swagger-typescript-api", - "version": "10.0.2", + "version": "10.0.3", "description": "Generate typescript/javascript api from swagger schema", "scripts": { "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts", @@ -10,8 +10,10 @@ "contributors": "all-contributors generate", "cli:help": "node index.js -h", "test-all": "node --unhandled-rejections=strict ./scriptsRunner.js generate validate test:*", + "test-all(update-snapshots)": "cross-env UPDATE_SNAPSHOTS=true node --unhandled-rejections=strict ./scriptsRunner.js generate validate test:*", "test-all-extended": "node --unhandled-rejections=strict ./scriptsRunner.js generate-extended validate generate validate test:*", "test-specific": "node ./scriptsRunner.js generate validate test:*", + "test-specific-only": "node ./scriptsRunner.js test:*", "prepare": "npm run test-all-extended", "generate": "node tests/generate.js", "generate-extended": "node tests/generate-extended.js", @@ -52,6 +54,7 @@ "typings": "./index.d.ts", "main": "src/index.js", "devDependencies": { + "cross-env": "^7.0.3", "@types/axios": "^0.14.0", "@types/lodash": "^4.14.182", "@types/node": "^15.0.2", diff --git a/src/config.js b/src/config.js index 9b728116..5dbc5d1e 100644 --- a/src/config.js +++ b/src/config.js @@ -1,7 +1,9 @@ const { HTTP_CLIENT, TS_KEYWORDS, PRETTIER_OPTIONS } = require("./constants"); const { NameResolver } = require("./utils/resolveName"); +const packageJson = require("../package.json"); const config = { + version: packageJson.version, /** CLI flag */ templates: "../templates/default", /** CLI flag */ diff --git a/src/logger.js b/src/logger.js index cdfc0ddc..5821e0ca 100644 --- a/src/logger.js +++ b/src/logger.js @@ -2,6 +2,8 @@ const _ = require("lodash"); const { config } = require("./config"); const { emojify, emoji } = require("node-emoji"); +let firstLog = true; + /** * * @param {{ type: "warn" | "log" | "error", emojiName: keyof emoji, messages: unknown[] }} payload @@ -12,6 +14,13 @@ const createLogMessage = ({ type, emojiName, messages }) => { const emoji = emojify(emojiName); + if (firstLog) { + firstLog = false; + logger.log( + `swagger-typescript-api(${config.version}),${process.env.npm_config_user_agent || `nodejs(${process.version})`}`, + ); + } + console[type]( emoji, " ", diff --git a/src/modelNames.js b/src/modelNames.js index 1a21ef81..a65edd17 100644 --- a/src/modelNames.js +++ b/src/modelNames.js @@ -53,11 +53,7 @@ const formatModelName = (name, options) => { const fixedModelName = fixModelName(name); - const formattedModelName = _.replace( - _.startCase(`${typePrefix}_${fixedModelName}_${typeSuffix}`), - /\s/g, - "", - ); + const formattedModelName = _.replace(_.startCase(`${typePrefix}_${fixedModelName}_${typeSuffix}`), /\s/g, ""); const modelName = config.hooks.onFormatTypeName(formattedModelName, name) || formattedModelName; formattedModelNamesMap.set(hashKey, modelName); diff --git a/src/translators/JavaScript.js b/src/translators/JavaScript.js index 61d81443..4e2af71e 100644 --- a/src/translators/JavaScript.js +++ b/src/translators/JavaScript.js @@ -7,20 +7,9 @@ function translate(fileName, content, options) { const originalSourceFileGet = host.getSourceFile.bind(host); host.getSourceFile = (sourceFileName, languageVersion, onError, shouldCreateNewSourceFile) => { if (sourceFileName !== fileName) - return originalSourceFileGet( - sourceFileName, - languageVersion, - onError, - shouldCreateNewSourceFile, - ); - - return ts.createSourceFile( - sourceFileName, - content, - languageVersion, - true, - ts.ScriptKind.External, - ); + return originalSourceFileGet(sourceFileName, languageVersion, onError, shouldCreateNewSourceFile); + + return ts.createSourceFile(sourceFileName, content, languageVersion, true, ts.ScriptKind.External); }; host.writeFile = (fileName, contents) => { diff --git a/src/utils/resolveName.js b/src/utils/resolveName.js index b31d0845..ed4a2110 100644 --- a/src/utils/resolveName.js +++ b/src/utils/resolveName.js @@ -82,10 +82,7 @@ class ComponentTypeNameResolver extends NameResolver { */ constructor(reservedNames) { super(reservedNames, (variants) => { - return ( - (variants[0] && `${variants[0]}${getRandomInt(1, 10)}`) || - `ComponentType${getRandomInt(1, 10)}` - ); + return (variants[0] && `${variants[0]}${getRandomInt(1, 10)}`) || `ComponentType${getRandomInt(1, 10)}`; }); } } diff --git a/templates/base/route-docs.ejs b/templates/base/route-docs.ejs index af96934b..60855f9c 100644 --- a/templates/base/route-docs.ejs +++ b/templates/base/route-docs.ejs @@ -21,8 +21,7 @@ const jsDocLines = _.compact([ ` * @response \`${status}\` \`${_.replace(_.replace(type, /\/\*/g, "\\*"), /\*\//g, "*\\")}\` ${description}`, ) : []), -]).join("\n"); - +]).map(str => str.trimEnd()).join("\n"); return { description: jsDocDescription, diff --git a/templates/default/procedure-call.ejs b/templates/default/procedure-call.ejs index 7ff931c7..31049f5b 100644 --- a/templates/default/procedure-call.ejs +++ b/templates/default/procedure-call.ejs @@ -81,7 +81,7 @@ const describeReturnType = () => { /** <%~ routeDocs.description %> - * <% /* Here you can add some other JSDoc tags */ %> + *<% /* Here you can add some other JSDoc tags */ %> <%~ routeDocs.lines %> @@ -96,4 +96,4 @@ const describeReturnType = () => { <%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %> <%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %> ...<%~ _.get(requestConfigParam, "name") %>, - })<%~ route.namespace ? ',' : '' %> \ No newline at end of file + })<%~ route.namespace ? ',' : '' %> diff --git a/templates/modular/procedure-call.ejs b/templates/modular/procedure-call.ejs index 7da49e58..7c98c765 100644 --- a/templates/modular/procedure-call.ejs +++ b/templates/modular/procedure-call.ejs @@ -81,7 +81,7 @@ const describeReturnType = () => { /** <%~ routeDocs.description %> - * <% /* Here you can add some other JSDoc tags */ %> + *<% /* Here you can add some other JSDoc tags */ %> <%~ routeDocs.lines %> @@ -96,4 +96,4 @@ const describeReturnType = () => { <%~ bodyContentKindTmpl ? `type: ${bodyContentKindTmpl},` : '' %> <%~ responseFormatTmpl ? `format: ${responseFormatTmpl},` : '' %> ...<%~ _.get(requestConfigParam, "name") %>, - }) \ No newline at end of file + }) diff --git a/tests/helpers/assertGeneratedModule.js b/tests/helpers/assertGeneratedModule.js new file mode 100644 index 00000000..076c0517 --- /dev/null +++ b/tests/helpers/assertGeneratedModule.js @@ -0,0 +1,26 @@ +const fs = require("fs"); +const gitDiff = require("git-diff"); + +const assertGeneratedModule = (pathToModule1, pathToModule2) => { + if (process.env.UPDATE_SNAPSHOTS) { + const output = fs.readFileSync(pathToModule1).toString("utf8"); + fs.writeFileSync(pathToModule2, output, { encoding: "utf8" }); + } else { + const output = fs.readFileSync(pathToModule1).toString("utf8"); + const expected = fs.readFileSync(pathToModule2).toString("utf8"); + + const diff = gitDiff(output, expected, { + color: true, + flags: "--diff-algorithm=default --ignore-space-at-eol --ignore-cr-at-eol", + }); + + if (diff && diff.length) { + console.error("\n" + diff); + throw new Error("expected another output"); + } + } + + return void 0; +}; + +module.exports = assertGeneratedModule; diff --git a/tests/helpers/validateGeneratedModule.js b/tests/helpers/validateGeneratedModule.js index f6e31a35..687f5c97 100644 --- a/tests/helpers/validateGeneratedModule.js +++ b/tests/helpers/validateGeneratedModule.js @@ -63,5 +63,10 @@ module.exports = (pathToFile) => { // ); // }); + if (diagnostics.length) { + console.error(diagnostics); + throw new Error("Failed"); + } + return diagnostics; }; diff --git a/tests/spec/axios/expected.ts b/tests/spec/axios/expected.ts new file mode 100644 index 00000000..02321936 --- /dev/null +++ b/tests/spec/axios/expected.ts @@ -0,0 +1,6151 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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 axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, HeadersDefaults, ResponseType } from "axios"; + +export type QueryParamsType = Record; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseType; + /** request body */ + body?: unknown; +} + +export type RequestParams = Omit; + +export interface ApiConfig extends Omit { + securityWorker?: ( + securityData: SecurityDataType | null, + ) => Promise | AxiosRequestConfig | void; + secure?: boolean; + format?: ResponseType; +} + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public instance: AxiosInstance; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private secure?: boolean; + private format?: ResponseType; + + constructor({ securityWorker, secure, format, ...axiosConfig }: ApiConfig = {}) { + this.instance = axios.create({ ...axiosConfig, baseURL: axiosConfig.baseURL || "https://api.github.com" }); + this.secure = secure; + this.format = format; + this.securityWorker = securityWorker; + } + + public setSecurityData = (data: SecurityDataType | null) => { + this.securityData = data; + }; + + protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig { + const method = params1.method || (params2 && params2.method); + + return { + ...this.instance.defaults, + ...params1, + ...(params2 || {}), + headers: { + ...((method && this.instance.defaults.headers[method.toLowerCase() as keyof HeadersDefaults]) || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + protected stringifyFormItem(formItem: unknown) { + if (typeof formItem === "object" && formItem !== null) { + return JSON.stringify(formItem); + } else { + return `${formItem}`; + } + } + + protected createFormData(input: Record): FormData { + return Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + const propertyContent: Iterable = property instanceof Array ? property : [property]; + + for (const formItem of propertyContent) { + const isFileType = formItem instanceof Blob || formItem instanceof File; + formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem)); + } + + return formData; + }, new FormData()); + } + + public request = async ({ + secure, + path, + type, + query, + format, + body, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const responseFormat = format || this.format || undefined; + + if (type === ContentType.FormData && body && body !== null && typeof body === "object") { + body = this.createFormData(body as Record); + } + + return this.instance.request({ + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + params: query, + responseType: responseFormat, + data: body, + url: path, + }); + }; +} + +/** + * @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; + }; + }; + }; + }; + }; + }; + }, + any + >({ + path: `/some-test`, + method: "GET", + format: "json", + ...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: `/path-params`, + method: "GET", + format: "json", + ...params, + }), + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + */ + eventsList: (params: RequestParams = {}) => + this.request({ + path: `/events`, + method: "GET", + format: "json", + ...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({ + path: `/feeds`, + method: "GET", + format: "json", + ...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({ + path: `/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + */ + gistsCreate: (body: PostGist, params: RequestParams = {}) => + this.request({ + path: `/gists`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/gists/public`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/gists/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gists/${id}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/forks`, + method: "POST", + ...params, + }), + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + starDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gists/${id}/star`, + method: "GET", + ...params, + }), + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gitignore/templates`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.request({ + path: `/gitignore/templates/${language}`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, + method: "GET", + format: "json", + ...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. */ + 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({ + path: `/legacy/repos/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/legacy/user/email/${email}`, + method: "GET", + format: "json", + ...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. */ + 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({ + path: `/legacy/user/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + */ + markdownCreate: (body: Markdown, params: RequestParams = {}) => + this.request({ + path: `/markdown`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + */ + postMarkdown: (params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/meta`, + method: "GET", + format: "json", + ...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({ + path: `/networks/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...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({ + path: `/notifications`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/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({ + path: `/notifications/threads/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/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({ + path: `/notifications/threads/${id}/subscription`, + method: "GET", + format: "json", + ...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({ + path: `/notifications/threads/${id}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/events`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/orgs/${org}/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/orgs/${org}/members`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/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({ + path: `/orgs/${org}/public_members`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/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({ + path: `/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?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/orgs/${org}/repos`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/orgs/${org}/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/teams`, + method: "GET", + format: "json", + ...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({ + path: `/orgs/${org}/teams`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/rate_limit`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/assignees`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/branches`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/branches/${branch}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/collaborators`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/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({ + path: `/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({ + path: `/repos/${owner}/${repo}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${ref}/status`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/compare/${baseId}...${headId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "DELETE", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contributors`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "POST", + body: body, + type: ContentType.Json, + ...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({ + path: `/repos/${owner}/${repo}/downloads`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/forks`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/blobs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/blobs/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/commits`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/tags`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/tags/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/trees`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/repos/${owner}/${repo}/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/comments`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/events`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/events/${eventId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/events`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsUpdate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + + /** + * @description Remove a label from an issue. + * + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + */ + issuesLabelsDelete2: (owner: string, repo: string, number: number, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get list of keys. + * + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + */ + keysDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a key. + * + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + */ + keysCreate: (owner: string, repo: string, body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a key. + * + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + */ + keysDelete: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a key + * + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + */ + keysDetail2: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all labels for this repository. + * + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + */ + labelsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a label. + * + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + */ + labelsCreate: (owner: string, repo: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a label. + * + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + */ + labelsDelete: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single label. + * + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + */ + labelsDetail2: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a label. + * + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + */ + labelsPartialUpdate: (owner: string, repo: string, name: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + */ + languagesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/languages`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Perform a merge. + * + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + */ + mergesCreate: (owner: string, repo: string, body: MergesBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/merges`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List milestones for a repository. + * + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + */ + milestonesDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a milestone. + * + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + */ + milestonesCreate: (owner: string, repo: string, body: MilestoneUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a milestone. + * + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single milestone. + * + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + */ + milestonesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a milestone. + * + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: MilestoneUpdate, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get labels for every issue in a milestone. + * + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + */ + milestonesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List your notifications in a repository List all notifications for the current user. + * + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + */ + notificationsDetail: ( + owner: string, + repo: string, + 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({ + path: `/repos/${owner}/${repo}/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + */ + notificationsUpdate: (owner: string, repo: string, body: NotificationMarkRead, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description List pull requests. + * + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + */ + pullsDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a pull request. + * + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + */ + pullsCreate: (owner: string, repo: string, body: PullsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + */ + pullsCommentsDetail: ( + 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({ + path: `/repos/${owner}/${repo}/pulls/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get a single pull request. + * + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + */ + pullsDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a pull request. + * + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + */ + pullsPartialUpdate: (owner: string, repo: string, number: number, body: PullUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a pull request. + * + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + */ + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: PullsCommentPost, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List commits on a pull request. + * + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + */ + pullsCommitsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/commits`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List pull requests files. + * + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + */ + pullsFilesDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/files`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get if a pull request has been merged. + * + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "GET", + ...params, + }), + + /** + * @description Merge a pull request (Merge Button's) + * + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeUpdate: (owner: string, repo: string, number: number, body: MergePullBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get the README. This method returns the preferred README for a repository. + * + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + */ + readmeDetail: ( + owner: string, + repo: string, + query?: { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/readme`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + */ + releasesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a release Users with push access to the repository can create a release. + * + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + */ + releasesCreate: (owner: string, repo: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a release asset + * + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release asset + * + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDetail: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: AssetPatch, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can delete a release. + * + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + */ + releasesDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release + * + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + */ + releasesDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can edit a release + * + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + */ + releasesPartialUpdate: (owner: string, repo: string, id: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List assets for a release + * + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + */ + releasesAssetsDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}/assets`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. + * + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + */ + stargazersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stargazers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + */ + statsCodeFrequencyDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/code_frequency`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + */ + statsCommitActivityDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/commit_activity`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get contributors list with additions, deletions, and commit counts. + * + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + */ + statsContributorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/contributors`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + */ + statsParticipationDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/participation`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + */ + statsPunchCardDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/punch_card`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Statuses for a specific Ref. + * + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Status. + * + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesCreate: (owner: string, repo: string, ref: string, body: HeadBranch, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List watchers. + * + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + */ + subscribersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscribers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a Repository Subscription. + * + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + */ + subscriptionDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a Repository Subscription. + * + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + */ + subscriptionDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Set a Repository Subscription + * + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + */ + subscriptionUpdate: (owner: string, repo: string, body: SubscriptionBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get list of tags. + * + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + */ + tagsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/tags`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of teams + * + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + */ + teamsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. New implementation. + * + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + */ + watchersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/watchers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: ( + owner: string, + repo: string, + archiveFormat: "tarball" | "zipball", + path: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/${archiveFormat}/${path}`, + method: "GET", + ...params, + }), + }; + repositories = { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * + * @name RepositoriesList + * @request GET:/repositories + */ + repositoriesList: ( + 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + search = { + /** + * @description Search code. + * + * @name CodeList + * @request GET:/search/code + */ + codeList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/code`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * + * @name IssuesList + * @request GET:/search/issues + */ + issuesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search repositories. + * + * @name RepositoriesList + * @request GET:/search/repositories + */ + repositoriesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search users. + * + * @name UsersList + * @request GET:/search/users + */ + usersList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + teams = { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + */ + teamsDelete: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team. + * + * @name TeamsDetail + * @request GET:/teams/{teamId} + */ + teamsDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + */ + teamsPartialUpdate: (teamId: number, body: EditTeam, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * + * @name MembersDetail + * @request GET:/teams/{teamId}/members + */ + membersDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + */ + membersDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + */ + membersDetail2: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "GET", + ...params, + }), + + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + */ + membersUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + */ + membershipsDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + */ + membershipsDetail: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + */ + membershipsUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "PUT", + format: "json", + ...params, + }), + + /** + * @description List team repos + * + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + */ + reposDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + */ + reposDelete: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if a team manages a repository + * + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + */ + reposUpdate: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "PUT", + ...params, + }), + }; + user = { + /** + * @description Get the authenticated user. + * + * @name UserList + * @request GET:/user + */ + userList: (params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update the authenticated user. + * + * @name UserPartialUpdate + * @request PATCH:/user + */ + userPartialUpdate: (body: UserUpdate, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * + * @name EmailsDelete + * @request DELETE:/user/emails + */ + emailsDelete: (body: UserEmails, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "DELETE", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * + * @name EmailsList + * @request GET:/user/emails + */ + emailsList: (params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "GET", + ...params, + }), + + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * + * @name EmailsCreate + * @request POST:/user/emails + */ + emailsCreate: (body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "POST", + body: body, + ...params, + }), + + /** + * @description List the authenticated user's followers + * + * @name FollowersList + * @request GET:/user/followers + */ + followersList: (params: RequestParams = {}) => + this.request({ + path: `/user/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List who the authenticated user is following. + * + * @name FollowingList + * @request GET:/user/following + */ + followingList: (params: RequestParams = {}) => + this.request({ + path: `/user/following`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingDelete + * @request DELETE:/user/following/{username} + */ + followingDelete: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are following a user. + * + * @name FollowingDetail + * @request GET:/user/following/{username} + */ + followingDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "GET", + ...params, + }), + + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingUpdate + * @request PUT:/user/following/{username} + */ + followingUpdate: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * + * @name IssuesList + * @request GET:/user/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/user/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * + * @name KeysList + * @request GET:/user/keys + */ + keysList: (params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a public key. + * + * @name KeysCreate + * @request POST:/user/keys + */ + keysCreate: (body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + */ + keysDelete: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single public key. + * + * @name KeysDetail + * @request GET:/user/keys/{keyId} + */ + keysDetail: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List public and private organizations for the authenticated user. + * + * @name OrgsList + * @request GET:/user/orgs + */ + orgsList: (params: RequestParams = {}) => + this.request({ + path: `/user/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * + * @name ReposList + * @request GET:/user/repos + */ + reposList: ( + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/user/repos + */ + reposCreate: (body: PostRepo, params: RequestParams = {}) => + this.request({ + path: `/user/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by the authenticated user. + * + * @name StarredList + * @request GET:/user/starred + */ + starredList: ( + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Unstar a repository + * + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + */ + starredDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are starring a repository. + * + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + */ + starredDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Star a repository. + * + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + */ + starredUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List repositories being watched by the authenticated user. + * + * @name SubscriptionsList + * @request GET:/user/subscriptions + */ + subscriptionsList: (params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Stop watching a repository + * + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are watching a repository. + * + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Watch a repository. + * + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * + * @name TeamsList + * @request GET:/user/teams + */ + teamsList: (params: RequestParams = {}) => + this.request({ + path: `/user/teams`, + method: "GET", + format: "json", + ...params, + }), + }; + users = { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * + * @name UsersList + * @request GET:/users + */ + usersList: ( + query?: { + /** The integer ID of the last user that you've seen. */ + since?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get a single user. + * + * @name UsersDetail + * @request GET:/users/{username} + */ + usersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * + * @name EventsDetail + * @request GET:/users/{username}/events + */ + eventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events`, + method: "GET", + ...params, + }), + + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + */ + eventsOrgsDetail: (username: string, org: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events/orgs/${org}`, + method: "GET", + ...params, + }), + + /** + * @description List a user's followers + * + * @name FollowersDetail + * @request GET:/users/{username}/followers + */ + followersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Check if one user follows another. + * + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + */ + followingDetail: (username: string, targetUser: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/following/${targetUser}`, + method: "GET", + ...params, + }), + + /** + * @description List a users gists. + * + * @name GistsDetail + * @request GET:/users/{username}/gists + */ + gistsDetail: ( + username: 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * + * @name KeysDetail + * @request GET:/users/{username}/keys + */ + keysDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all public organizations for a user. + * + * @name OrgsDetail + * @request GET:/users/{username}/orgs + */ + orgsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description These are events that you'll only see public events. + * + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + */ + receivedEventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events`, + method: "GET", + ...params, + }), + + /** + * @description List public events that a user has received + * + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + */ + receivedEventsPublicDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events/public`, + method: "GET", + ...params, + }), + + /** + * @description List public repositories for the specified user. + * + * @name ReposDetail + * @request GET:/users/{username}/repos + */ + reposDetail: ( + username: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by a user. + * + * @name StarredDetail + * @request GET:/users/{username}/starred + */ + starredDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/starred`, + method: "GET", + ...params, + }), + + /** + * @description List repositories being watched by a user. + * + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + */ + subscriptionsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/subscriptions`, + method: "GET", + ...params, + }), + }; +} diff --git a/tests/spec/axios/test.js b/tests/spec/axios/test.js index 7f86c86e..ed47b590 100644 --- a/tests/spec/axios/test.js +++ b/tests/spec/axios/test.js @@ -2,6 +2,7 @@ const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { httpClientType: "axios", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/axiosSingleHttpClient/expected.ts b/tests/spec/axiosSingleHttpClient/expected.ts new file mode 100644 index 00000000..2e9fc1e7 --- /dev/null +++ b/tests/spec/axiosSingleHttpClient/expected.ts @@ -0,0 +1,6157 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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 axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse, HeadersDefaults, ResponseType } from "axios"; + +export type QueryParamsType = Record; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseType; + /** request body */ + body?: unknown; +} + +export type RequestParams = Omit; + +export interface ApiConfig extends Omit { + securityWorker?: ( + securityData: SecurityDataType | null, + ) => Promise | AxiosRequestConfig | void; + secure?: boolean; + format?: ResponseType; +} + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public instance: AxiosInstance; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private secure?: boolean; + private format?: ResponseType; + + constructor({ securityWorker, secure, format, ...axiosConfig }: ApiConfig = {}) { + this.instance = axios.create({ ...axiosConfig, baseURL: axiosConfig.baseURL || "https://api.github.com" }); + this.secure = secure; + this.format = format; + this.securityWorker = securityWorker; + } + + public setSecurityData = (data: SecurityDataType | null) => { + this.securityData = data; + }; + + protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig { + const method = params1.method || (params2 && params2.method); + + return { + ...this.instance.defaults, + ...params1, + ...(params2 || {}), + headers: { + ...((method && this.instance.defaults.headers[method.toLowerCase() as keyof HeadersDefaults]) || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + protected stringifyFormItem(formItem: unknown) { + if (typeof formItem === "object" && formItem !== null) { + return JSON.stringify(formItem); + } else { + return `${formItem}`; + } + } + + protected createFormData(input: Record): FormData { + return Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + const propertyContent: Iterable = property instanceof Array ? property : [property]; + + for (const formItem of propertyContent) { + const isFileType = formItem instanceof Blob || formItem instanceof File; + formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem)); + } + + return formData; + }, new FormData()); + } + + public request = async ({ + secure, + path, + type, + query, + format, + body, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const responseFormat = format || this.format || undefined; + + if (type === ContentType.FormData && body && body !== null && typeof body === "object") { + body = this.createFormData(body as Record); + } + + return this.instance.request({ + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + params: query, + responseType: responseFormat, + data: body, + url: path, + }); + }; +} + +/** + * @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 { + http: HttpClient; + + constructor(http: HttpClient) { + this.http = http; + } + + 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.http.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; + }; + }; + }; + }; + }; + }; + }, + any + >({ + path: `/some-test`, + method: "GET", + format: "json", + ...params, + }), + }; + pathParams = { + /** + * @description Lists all the emojis available to use on GitHub. + * + * @name PathParamsList + * @request GET:/path-params + */ + pathParamsList: (petId: number, params: RequestParams = {}) => + this.http.request({ + path: `/path-params`, + method: "GET", + format: "json", + ...params, + }), + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + */ + eventsList: (params: RequestParams = {}) => + this.http.request({ + path: `/events`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/feeds`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + */ + gistsCreate: (body: PostGist, params: RequestParams = {}) => + this.http.request({ + path: `/gists`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/gists/public`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/gists/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/gists/${id}/forks`, + method: "POST", + ...params, + }), + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + starDelete: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/gists/${id}/star`, + method: "GET", + ...params, + }), + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/gitignore/templates`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.http.request({ + path: `/gitignore/templates/${language}`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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.http.request({ + path: `/issues`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, + method: "GET", + format: "json", + ...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. */ + 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.http.request({ + path: `/legacy/repos/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/legacy/user/email/${email}`, + method: "GET", + format: "json", + ...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. */ + 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.http.request({ + path: `/legacy/user/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + */ + markdownCreate: (body: Markdown, params: RequestParams = {}) => + this.http.request({ + path: `/markdown`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + */ + postMarkdown: (params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/meta`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/networks/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/notifications`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description View a single thread. + * + * @name ThreadsDetail + * @request GET:/notifications/threads/{id} + */ + threadsDetail: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/notifications/threads/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/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.http.request({ + path: `/notifications/threads/${id}/subscription`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/notifications/threads/${id}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.http.request({ + path: `/orgs/${org}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => + this.http.request({ + path: `/orgs/${org}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.http.request({ + path: `/orgs/${org}/events`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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.http.request({ + path: `/orgs/${org}/issues`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/orgs/${org}/members`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/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.http.request({ + path: `/orgs/${org}/public_members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Conceal a user's membership. + * + * @name PublicMembersDelete + * @request DELETE:/orgs/{org}/public_members/{username} + */ + publicMembersDelete: (org: string, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/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.http.request({ + path: `/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?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/orgs/${org}/repos`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/orgs/${org}/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.http.request({ + path: `/orgs/${org}/teams`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/orgs/${org}/teams`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/rate_limit`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get repository. + * + * @name ReposDetail + * @request GET:/repos/{owner}/{repo} + */ + reposDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/assignees`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/branches`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/branches/${branch}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/collaborators`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/comments`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/commits`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/commits/${ref}/status`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/compare/${baseId}...${headId}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "DELETE", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/contributors`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/deployments`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/deployments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "POST", + body: body, + type: ContentType.Json, + ...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.http.request({ + path: `/repos/${owner}/${repo}/downloads`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Create a Blob. + * + * @name GitBlobsCreate + * @request POST:/repos/{owner}/{repo}/git/blobs + */ + gitBlobsCreate: (owner: string, repo: string, body: Blob, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/git/blobs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/blobs/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Commit. + * + * @name GitCommitsCreate + * @request POST:/repos/{owner}/{repo}/git/commits + */ + gitCommitsCreate: (owner: string, repo: string, body: RepoCommitBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/git/commits`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Reference + * + * @name GitRefsCreate + * @request POST:/repos/{owner}/{repo}/git/refs + */ + gitRefsCreate: (owner: string, repo: string, body: RefsBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/tags`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/tags/${shaCode}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/trees`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a hook. + * + * @name HooksDelete + * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} + */ + hooksDelete: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "PATCH", + body: body, + format: "json", + ...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.http.request({ + path: `/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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.http.request({ + path: `/repos/${owner}/${repo}/issues`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues`, + method: "POST", + body: body, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/comments`, + method: "GET", + query: query, + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/events`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/events/${eventId}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "PATCH", + body: body, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "POST", + body: body, + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/events`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "GET", + format: "json", + ...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.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsUpdate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + + /** + * @description Remove a label from an issue. + * + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + */ + issuesLabelsDelete2: (owner: string, repo: string, number: number, name: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get list of keys. + * + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + */ + keysDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a key. + * + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + */ + keysCreate: (owner: string, repo: string, body: UserKeysPost, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a key. + * + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + */ + keysDelete: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a key + * + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + */ + keysDetail2: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all labels for this repository. + * + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + */ + labelsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a label. + * + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + */ + labelsCreate: (owner: string, repo: string, body: EmailsPost, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a label. + * + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + */ + labelsDelete: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single label. + * + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + */ + labelsDetail2: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a label. + * + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + */ + labelsPartialUpdate: (owner: string, repo: string, name: string, body: EmailsPost, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + */ + languagesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/languages`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Perform a merge. + * + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + */ + mergesCreate: (owner: string, repo: string, body: MergesBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/merges`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List milestones for a repository. + * + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + */ + milestonesDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a milestone. + * + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + */ + milestonesCreate: (owner: string, repo: string, body: MilestoneUpdate, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a milestone. + * + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single milestone. + * + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + */ + milestonesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a milestone. + * + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: MilestoneUpdate, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get labels for every issue in a milestone. + * + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + */ + milestonesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/milestones/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List your notifications in a repository List all notifications for the current user. + * + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + */ + notificationsDetail: ( + owner: string, + repo: string, + 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.http.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + */ + notificationsUpdate: (owner: string, repo: string, body: NotificationMarkRead, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description List pull requests. + * + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + */ + pullsDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a pull request. + * + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + */ + pullsCreate: (owner: string, repo: string, body: PullsPost, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + */ + pullsCommentsDetail: ( + 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.http.request({ + path: `/repos/${owner}/${repo}/pulls/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get a single pull request. + * + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + */ + pullsDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a pull request. + * + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + */ + pullsPartialUpdate: (owner: string, repo: string, number: number, body: PullUpdate, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a pull request. + * + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + */ + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: PullsCommentPost, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List commits on a pull request. + * + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + */ + pullsCommitsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/commits`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List pull requests files. + * + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + */ + pullsFilesDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/files`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get if a pull request has been merged. + * + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "GET", + ...params, + }), + + /** + * @description Merge a pull request (Merge Button's) + * + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeUpdate: (owner: string, repo: string, number: number, body: MergePullBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get the README. This method returns the preferred README for a repository. + * + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + */ + readmeDetail: ( + owner: string, + repo: string, + query?: { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/readme`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + */ + releasesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a release Users with push access to the repository can create a release. + * + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + */ + releasesCreate: (owner: string, repo: string, body: ReleaseCreate, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a release asset + * + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release asset + * + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDetail: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: AssetPatch, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can delete a release. + * + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + */ + releasesDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release + * + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + */ + releasesDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can edit a release + * + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + */ + releasesPartialUpdate: (owner: string, repo: string, id: string, body: ReleaseCreate, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List assets for a release + * + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + */ + releasesAssetsDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/releases/${id}/assets`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. + * + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + */ + stargazersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stargazers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + */ + statsCodeFrequencyDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stats/code_frequency`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + */ + statsCommitActivityDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stats/commit_activity`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get contributors list with additions, deletions, and commit counts. + * + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + */ + statsContributorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stats/contributors`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + */ + statsParticipationDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stats/participation`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + */ + statsPunchCardDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/stats/punch_card`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Statuses for a specific Ref. + * + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Status. + * + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesCreate: (owner: string, repo: string, ref: string, body: HeadBranch, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List watchers. + * + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + */ + subscribersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/subscribers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a Repository Subscription. + * + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + */ + subscriptionDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a Repository Subscription. + * + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + */ + subscriptionDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Set a Repository Subscription + * + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + */ + subscriptionUpdate: (owner: string, repo: string, body: SubscriptionBody, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get list of tags. + * + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + */ + tagsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/tags`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of teams + * + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + */ + teamsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. New implementation. + * + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + */ + watchersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/repos/${owner}/${repo}/watchers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: ( + owner: string, + repo: string, + archiveFormat: "tarball" | "zipball", + path: string, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repos/${owner}/${repo}/${archiveFormat}/${path}`, + method: "GET", + ...params, + }), + }; + repositories = { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * + * @name RepositoriesList + * @request GET:/repositories + */ + repositoriesList: ( + 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; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + search = { + /** + * @description Search code. + * + * @name CodeList + * @request GET:/search/code + */ + codeList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/search/code`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * + * @name IssuesList + * @request GET:/search/issues + */ + issuesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/search/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search repositories. + * + * @name RepositoriesList + * @request GET:/search/repositories + */ + repositoriesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/search/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search users. + * + * @name UsersList + * @request GET:/search/users + */ + usersList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/search/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + teams = { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + */ + teamsDelete: (teamId: number, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team. + * + * @name TeamsDetail + * @request GET:/teams/{teamId} + */ + teamsDetail: (teamId: number, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + */ + teamsPartialUpdate: (teamId: number, body: EditTeam, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * + * @name MembersDetail + * @request GET:/teams/{teamId}/members + */ + membersDetail: (teamId: number, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + */ + membersDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/members/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + */ + membersDetail2: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/members/${username}`, + method: "GET", + ...params, + }), + + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + */ + membersUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/members/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + */ + membershipsDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + */ + membershipsDetail: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + */ + membershipsUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "PUT", + format: "json", + ...params, + }), + + /** + * @description List team repos + * + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + */ + reposDetail: (teamId: number, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/repos`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + */ + reposDelete: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if a team manages a repository + * + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + */ + reposUpdate: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "PUT", + ...params, + }), + }; + user = { + /** + * @description Get the authenticated user. + * + * @name UserList + * @request GET:/user + */ + userList: (params: RequestParams = {}) => + this.http.request({ + path: `/user`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update the authenticated user. + * + * @name UserPartialUpdate + * @request PATCH:/user + */ + userPartialUpdate: (body: UserUpdate, params: RequestParams = {}) => + this.http.request({ + path: `/user`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * + * @name EmailsDelete + * @request DELETE:/user/emails + */ + emailsDelete: (body: UserEmails, params: RequestParams = {}) => + this.http.request({ + path: `/user/emails`, + method: "DELETE", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * + * @name EmailsList + * @request GET:/user/emails + */ + emailsList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/emails`, + method: "GET", + ...params, + }), + + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * + * @name EmailsCreate + * @request POST:/user/emails + */ + emailsCreate: (body: EmailsPost, params: RequestParams = {}) => + this.http.request({ + path: `/user/emails`, + method: "POST", + body: body, + ...params, + }), + + /** + * @description List the authenticated user's followers + * + * @name FollowersList + * @request GET:/user/followers + */ + followersList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List who the authenticated user is following. + * + * @name FollowingList + * @request GET:/user/following + */ + followingList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/following`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingDelete + * @request DELETE:/user/following/{username} + */ + followingDelete: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/following/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are following a user. + * + * @name FollowingDetail + * @request GET:/user/following/{username} + */ + followingDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/following/${username}`, + method: "GET", + ...params, + }), + + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingUpdate + * @request PUT:/user/following/{username} + */ + followingUpdate: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/following/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * + * @name IssuesList + * @request GET:/user/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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.http.request({ + path: `/user/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * + * @name KeysList + * @request GET:/user/keys + */ + keysList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a public key. + * + * @name KeysCreate + * @request POST:/user/keys + */ + keysCreate: (body: UserKeysPost, params: RequestParams = {}) => + this.http.request({ + path: `/user/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + */ + keysDelete: (keyId: number, params: RequestParams = {}) => + this.http.request({ + path: `/user/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single public key. + * + * @name KeysDetail + * @request GET:/user/keys/{keyId} + */ + keysDetail: (keyId: number, params: RequestParams = {}) => + this.http.request({ + path: `/user/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List public and private organizations for the authenticated user. + * + * @name OrgsList + * @request GET:/user/orgs + */ + orgsList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * + * @name ReposList + * @request GET:/user/repos + */ + reposList: ( + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/user/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/user/repos + */ + reposCreate: (body: PostRepo, params: RequestParams = {}) => + this.http.request({ + path: `/user/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by the authenticated user. + * + * @name StarredList + * @request GET:/user/starred + */ + starredList: ( + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/user/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Unstar a repository + * + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + */ + starredDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/starred/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are starring a repository. + * + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + */ + starredDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/starred/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Star a repository. + * + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + */ + starredUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/starred/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List repositories being watched by the authenticated user. + * + * @name SubscriptionsList + * @request GET:/user/subscriptions + */ + subscriptionsList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/subscriptions`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Stop watching a repository + * + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are watching a repository. + * + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Watch a repository. + * + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.http.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * + * @name TeamsList + * @request GET:/user/teams + */ + teamsList: (params: RequestParams = {}) => + this.http.request({ + path: `/user/teams`, + method: "GET", + format: "json", + ...params, + }), + }; + users = { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * + * @name UsersList + * @request GET:/users + */ + usersList: ( + query?: { + /** The integer ID of the last user that you've seen. */ + since?: number; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get a single user. + * + * @name UsersDetail + * @request GET:/users/{username} + */ + usersDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * + * @name EventsDetail + * @request GET:/users/{username}/events + */ + eventsDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/events`, + method: "GET", + ...params, + }), + + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + */ + eventsOrgsDetail: (username: string, org: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/events/orgs/${org}`, + method: "GET", + ...params, + }), + + /** + * @description List a user's followers + * + * @name FollowersDetail + * @request GET:/users/{username}/followers + */ + followersDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Check if one user follows another. + * + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + */ + followingDetail: (username: string, targetUser: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/following/${targetUser}`, + method: "GET", + ...params, + }), + + /** + * @description List a users gists. + * + * @name GistsDetail + * @request GET:/users/{username}/gists + */ + gistsDetail: ( + username: 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; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/users/${username}/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * + * @name KeysDetail + * @request GET:/users/{username}/keys + */ + keysDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all public organizations for a user. + * + * @name OrgsDetail + * @request GET:/users/{username}/orgs + */ + orgsDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description These are events that you'll only see public events. + * + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + */ + receivedEventsDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/received_events`, + method: "GET", + ...params, + }), + + /** + * @description List public events that a user has received + * + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + */ + receivedEventsPublicDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/received_events/public`, + method: "GET", + ...params, + }), + + /** + * @description List public repositories for the specified user. + * + * @name ReposDetail + * @request GET:/users/{username}/repos + */ + reposDetail: ( + username: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.http.request({ + path: `/users/${username}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by a user. + * + * @name StarredDetail + * @request GET:/users/{username}/starred + */ + starredDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/starred`, + method: "GET", + ...params, + }), + + /** + * @description List repositories being watched by a user. + * + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + */ + subscriptionsDetail: (username: string, params: RequestParams = {}) => + this.http.request({ + path: `/users/${username}/subscriptions`, + method: "GET", + ...params, + }), + }; +} diff --git a/tests/spec/axiosSingleHttpClient/test.js b/tests/spec/axiosSingleHttpClient/test.js index 106bf3e4..18bf067f 100644 --- a/tests/spec/axiosSingleHttpClient/test.js +++ b/tests/spec/axiosSingleHttpClient/test.js @@ -2,6 +2,7 @@ const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); const { generateApiForTest } = require("../../helpers/generateApiForTest"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -17,5 +18,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { httpClientType: "axios", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/defaultAsSuccess/expected.ts b/tests/spec/defaultAsSuccess/expected.ts new file mode 100644 index 00000000..442069ed --- /dev/null +++ b/tests/spec/defaultAsSuccess/expected.ts @@ -0,0 +1,611 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Authentiq ID in JWT format, self-signed. + */ +export interface AuthentiqID { + /** device token for push messages */ + devtoken?: string; + /** UUID and public signing key */ + sub: string; +} + +/** + * Claim in JWT format, self- or issuer-signed. + */ +export interface Claims { + email?: string; + phone?: string; + /** claim scope */ + scope: string; + /** UUID */ + sub: string; + type?: string; +} + +export interface Error { + detail?: string; + error: number; + title?: string; + /** unique uri for this error */ + type?: string; +} + +/** + * PushToken in JWT format, self-signed. + */ +export interface PushToken { + /** audience (URI) */ + aud: string; + exp?: number; + iat?: number; + /** issuer (URI) */ + iss: string; + nbf?: number; + /** UUID and public signing key */ + sub: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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://6-dot-authentiqio.appspot.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Authentiq + * @version 6 + * @license Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://authentiq.com/terms/ + * @baseUrl https://6-dot-authentiqio.appspot.com + * @contact Authentiq team (http://authentiq.io/support) + * + * Strong authentication, without the passwords. + */ +export class Api extends HttpClient { + key = { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + */ + keyRevokeNosecret: ( + query: { + /** primary email associated to Key (ID) */ + email: string; + /** primary phone number, international representation */ + phone: string; + /** verification code sent by email */ + code?: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** pending or done */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + keyRegister: (body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Revoke an Identity (Key) with a revocation secret + * + * @tags key, delete + * @name KeyRevoke + * @request DELETE:/key/{PK} + */ + keyRevoke: ( + pk: string, + query: { + /** revokation secret */ + secret: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get public details of an Authentiq ID. + * + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + */ + getKey: (pk: string, params: RequestParams = {}) => + this.request< + { + /** @format date-time */ + since?: string; + status?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD info on Authentiq ID + * + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + */ + headKey: (pk: string, params: RequestParams = {}) => + this.request({ + path: `/key/${pk}`, + method: "HEAD", + ...params, + }), + + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + */ + keyUpdate: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + */ + keyBind: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + }; + login = { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + */ + pushLoginRequest: ( + query: { + /** URI App will connect to */ + callback: string; + }, + body: PushToken, + params: RequestParams = {}, + ) => + this.request< + { + /** sent */ + status?: string; + }, + Error + >({ + path: `/login`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + }; + scope = { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, post + * @name SignRequest + * @request POST:/scope + */ + signRequest: ( + body: Claims, + query?: { + /** test only mode, using test issuer */ + test?: number; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** 20-character ID */ + job?: string; + /** waiting */ + status?: string; + }, + Error + >({ + path: `/scope`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + + /** + * @description delete a verification job + * + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + */ + signDelete: (job: string, params: RequestParams = {}) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "DELETE", + format: "json", + ...params, + }), + + /** + * @description get the status / current content of a verification job + * + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + */ + signRetrieve: (job: string, params: RequestParams = {}) => + this.request< + { + exp?: number; + field?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD to get the status of a verification job + * + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + */ + signRetrieveHead: (job: string, params: RequestParams = {}) => + this.request({ + path: `/scope/${job}`, + method: "HEAD", + ...params, + }), + + /** + * @description this is a scope confirmation + * + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + */ + signConfirm: (job: string, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "POST", + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + */ + signUpdate: (job: string, params: RequestParams = {}) => + this.request< + { + /** result is JWT or JSON?? */ + jwt?: string; + /** ready */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "PUT", + ...params, + }), + }; +} diff --git a/tests/spec/defaultAsSuccess/test.js b/tests/spec/defaultAsSuccess/test.js index 1adc19a5..c6eac255 100644 --- a/tests/spec/defaultAsSuccess/test.js +++ b/tests/spec/defaultAsSuccess/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { defaultResponseAsSuccess: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/defaultResponse/expected.ts b/tests/spec/defaultResponse/expected.ts new file mode 100644 index 00000000..6becb046 --- /dev/null +++ b/tests/spec/defaultResponse/expected.ts @@ -0,0 +1,257 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/api"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache 2.0 (https://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/api + * @contact Swagger API Team (http://swagger.io) + * + * A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + */ +export class Api extends HttpClient { + pets = { + /** + * @description Returns all pets from the system that the user has access to Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + * + * @name FindPets + * @request GET:/pets + */ + findPets: ( + query?: { + /** tags to filter by */ + tags?: string[]; + /** + * maximum number of results to return + * @format int32 + */ + limit?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pets`, + method: "GET", + query: query, + ...params, + }), + }; +} diff --git a/tests/spec/defaultResponse/test.js b/tests/spec/defaultResponse/test.js index df8855f3..afd5a8c8 100644 --- a/tests/spec/defaultResponse/test.js +++ b/tests/spec/defaultResponse/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { defaultResponseType: "unknown", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/enumNamesAsValues/expected.ts b/tests/spec/enumNamesAsValues/expected.ts new file mode 100644 index 00000000..ff29449f --- /dev/null +++ b/tests/spec/enumNamesAsValues/expected.ts @@ -0,0 +1,617 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type TestAllOfDc = (FooBarBaz & FooBar) & { + prop?: string; +}; + +export type TestAllOfDc2 = FooBarBaz & { + prop?: string; +}; + +export type TestAnyOfDc = (FooBarBaz | FooBar | (FooBarBaz & FooBar)) & { + prop?: string; +}; + +export type TestOneOfDc = (FooBarBaz | FooBar) & { + prop?: string; +}; + +/** + * FooBar + * @format int32 + */ +export enum IntEnumWithNames { + Unknown = "Unknown", + String = "String", + Int32 = "Int32", + Int64 = "Int64", + Double = "Double", + DateTime = "DateTime", + Test2 = "Test2", + Test23 = "Test23", + Tess44 = "Tess44", + BooFar = "BooFar", +} + +export type PetIds = 10 | 20 | 30 | 40; + +export type PetIdsWithWrongEnum = 10 | 20 | 30 | 40; + +/** + * Information about job + */ +export interface FooBarBaz { + id?: string; + kind?: JobKind; + name?: string; + link?: string; +} + +/** + * Information about job + */ +export interface FooBar { + kind?: JobKind; +} + +/** + * Information about job + */ +export interface FooBaz { + name?: string; + link?: string; +} + +/** + * From T, pick a set of properties whose keys are in the union K + */ +export interface PickUserTypeExcludeKeysIdOrId { + username: string; + password: string; +} + +export type OmitUserTypeIdOrId = PickUserTypeExcludeKeysIdOrId; + +export type OmitIdUserType = OmitUserTypeIdOrId; + +export type AuthUserType = OmitIdUserType; + +export enum JobKind { + COMPANY = "COMPANY", + PERSONAL = "PERSONAL", + FREELANCE = "FREELANCE", + OPEN_SOURCE = "OPEN_SOURCE", +} + +/** + * Information about job + */ +export interface JobType { + id: string; + kind: JobKind; + name?: string; + link?: string; + /** + * Exist only in open source jobs + * Format: `${username}/${projectName}` + */ + github?: string; + /** + * Exist only in open source jobs + * Format: `${orgname}/${projectName}` + */ + npm?: string; + /** + * Exist only in open source jobs + * Means project is dev. tool (like swagger code generator) + */ + isTool?: boolean; + /** web site address */ + address?: string; +} + +/** + * From T, pick a set of properties whose keys are in the union K + */ +export interface PickJobTypeExcludeKeysIdOrId { + kind: JobKind; + name?: string; + link?: string; + /** + * Exist only in open source jobs + * Format: `${username}/${projectName}` + */ + github?: string; + /** + * Exist only in open source jobs + * Format: `${orgname}/${projectName}` + */ + npm?: string; + /** + * Exist only in open source jobs + * Means project is dev. tool (like swagger code generator) + */ + isTool?: boolean; + /** web site address */ + address?: string; +} + +export type OmitJobTypeIdOrId = PickJobTypeExcludeKeysIdOrId; + +export type OmitIdJobType = OmitJobTypeIdOrId; + +export type JobUpdateType = OmitIdJobType; + +/** + * From T, pick a set of properties whose keys are in the union K + */ +export interface PickProjectTypeExcludeKeysJob { + id: string; + name?: string; + /** @format double */ + year: number; + description: string; + notImportant?: boolean; + prefix?: string; + tags: string[]; + teamSize: string; +} + +export type OmitProjectTypeJob = PickProjectTypeExcludeKeysJob; + +export type ExtractedProjectType = OmitProjectTypeJob & { + /** Information about job */ + job: JobType; +}; + +/** + * From T, pick a set of properties whose keys are in the union K + */ +export interface PickProjectTypeExcludeKeysIdOrId { + name?: string; + job: string; + /** @format double */ + year: number; + description: string; + notImportant?: boolean; + prefix?: string; + tags: string[]; + teamSize: string; +} + +export type OmitProjectTypeIdOrId = PickProjectTypeExcludeKeysIdOrId; + +export type OmitIdProjectType = OmitProjectTypeIdOrId; + +export type ProjectUpdateType = OmitIdProjectType; + +export interface ProjectType { + id: string; + /** @format double */ + year: number; + description: string; + job: string; + name?: string; + notImportant?: boolean; + prefix?: string; + tags: string[]; + teamSize: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://localhost:8080/api/v1"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title No title + * @baseUrl http://localhost:8080/api/v1 + */ +export class Api extends HttpClient { + auth = { + /** + * No description + * + * @tags Auth + * @name Login + * @request POST:/auth + */ + login: (data: AuthUserType, params: RequestParams = {}) => + this.request({ + path: `/auth`, + method: "POST", + body: data, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Auth + * @name Refresh + * @request POST:/auth/refresh + * @secure + */ + refresh: (params: RequestParams = {}) => + this.request({ + path: `/auth/refresh`, + method: "POST", + secure: true, + format: "json", + ...params, + }), + }; + jobs = { + /** + * No description + * + * @tags Jobs + * @name GetJobs + * @request GET:/jobs + * @secure + */ + getJobs: (params: RequestParams = {}) => + this.request({ + path: `/jobs`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Jobs + * @name AddJob + * @request POST:/jobs + * @secure + */ + addJob: (data: JobUpdateType, params: RequestParams = {}) => + this.request({ + path: `/jobs`, + method: "POST", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Jobs + * @name GetJob + * @request GET:/jobs/{id} + * @secure + */ + getJob: (id: string, params: RequestParams = {}) => + this.request({ + path: `/jobs/${id}`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Jobs + * @name UpdateJob + * @request PATCH:/jobs/{id} + * @secure + */ + updateJob: (id: string, data: JobUpdateType, params: RequestParams = {}) => + this.request({ + path: `/jobs/${id}`, + method: "PATCH", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Jobs + * @name DeleteJob + * @request DELETE:/jobs/{id} + * @secure + */ + deleteJob: (id: string, params: RequestParams = {}) => + this.request({ + path: `/jobs/${id}`, + method: "DELETE", + secure: true, + format: "json", + ...params, + }), + }; + projects = { + /** + * No description + * + * @tags Projects + * @name GetProjects + * @request GET:/projects + */ + getProjects: (params: RequestParams = {}) => + this.request({ + path: `/projects`, + method: "GET", + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Projects + * @name AddProjects + * @request POST:/projects + * @secure + */ + addProjects: (data: ProjectUpdateType, params: RequestParams = {}) => + this.request({ + path: `/projects`, + method: "POST", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Projects + * @name UpdateProject + * @request PATCH:/projects/{id} + * @secure + */ + updateProject: (id: string, data: ProjectUpdateType, params: RequestParams = {}) => + this.request({ + path: `/projects/${id}`, + method: "PATCH", + body: data, + secure: true, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags Projects + * @name DeleteProject + * @request DELETE:/projects/{id} + */ + deleteProject: (id: string, params: RequestParams = {}) => + this.request({ + path: `/projects/${id}`, + method: "DELETE", + format: "json", + ...params, + }), + }; +} diff --git a/tests/spec/enumNamesAsValues/test.js b/tests/spec/enumNamesAsValues/test.js index 946ca39b..63eddba0 100644 --- a/tests/spec/enumNamesAsValues/test.js +++ b/tests/spec/enumNamesAsValues/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { enumNamesAsValues: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/extractRequestBody/expected.ts b/tests/spec/extractRequestBody/expected.ts new file mode 100644 index 00000000..ea84fb9b --- /dev/null +++ b/tests/spec/extractRequestBody/expected.ts @@ -0,0 +1,819 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Pet Order + * An order for a pets from the pet store + * @example {"petId":6,"quantity":1,"id":0,"shipDate":"2000-01-23T04:56:07.000+00:00","complete":false,"status":"placed"} + */ +export interface OrderTTT { + /** @format int64 */ + id?: number; + /** @format int64 */ + petId?: number; + /** @format int32 */ + quantity?: number; + /** @format date-time */ + shipDate?: string; + /** Order Status */ + status?: "placed" | "approved" | "delivered" | null; + complete?: boolean; +} + +/** + * Pet category + * A category for a pet + * @example {"name":"name","id":6} + */ +export interface CategoryTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +/** + * a User + * A User who is purchasing from the pet store + * @example {"firstName":"firstName","lastName":"lastName","password":"password","userStatus":6,"phone":"phone","id":0,"email":"email","username":"username"} + */ +export interface UserTTT { + /** @format int64 */ + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + /** + * User Status + * @format int32 + */ + userStatus?: number; +} + +/** + * Pet Tag + * A tag for a pet + * @example {"name":"name","id":1} + */ +export interface TagTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +export enum PetNamesTTT { + FluffyHero = "Fluffy Hero", + PiggyPo = "Piggy Po", + SwaggerTypescriptApi = "Swagger Typescript Api", + UPPER_CASE = "UPPER_CASE", +} + +export type PetIdsTTT = 10 | 20 | 30 | 40; + +export type PetIdsWithWrongEnumTTT = 10 | 20 | 30 | 40; + +/** + * a Pet + * A pet for sale in the pet store + * @example {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"} + */ +export interface PetTTT { + /** @format int64 */ + id?: number; + /** A category for a pet */ + category?: CategoryTTT; + /** @example doggie */ + name: string; + photoUrls: string[]; + tags?: TagTTT[]; + /** pet status in the store */ + status?: "available" | "pending" | "sold"; +} + +/** + * An uploaded response + * Describes the result of uploading an image resource + * @example {"code":0,"type":"type","message":"message"} + */ +export interface ApiResponseTTT { + /** @format int32 */ + code?: number; + type?: string; + message?: string; +} + +/** + * some description + */ +export interface AmountTTT { + /** + * some description + * + * @format double + * @min 0.01 + * @max 1000000000000000 + */ + value: number; + /** + * some description + * + */ + currency: CurrencyTTT; +} + +/** + * some description + * @pattern ^[A-Z]{3,3}$ + */ +export type CurrencyTTT = string; + +export interface SingleFormUrlEncodedRequestPayloadTTT { + /** @format string */ + param1: string; + param2: string; +} + +export interface UpdatePetWithFormPayloadTTT { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; +} + +export interface UploadFilePayloadTTT { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/v2"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/v2 + * @externalDocs http://swagger.io + * @contact + * + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + */ +export class Api extends HttpClient { + pet = { + /** + * No description + * + * @tags pet + * @name AddPet + * @summary Add a new pet to the store + * @request POST:/pet + * @secure + */ + addPet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "POST", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePet + * @summary Update an existing pet + * @request PUT:/pet + * @secure + */ + updatePet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "PUT", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * @description Multiple status values can be provided with comma separated strings + * + * @tags pet + * @name FindPetsByStatus + * @summary Finds Pets by status + * @request GET:/pet/findByStatus + * @secure + */ + findPetsByStatus: ( + query: { + /** Status values that need to be considered for filter */ + status: ("available" | "pending" | "sold")[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByStatus`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name SingleFormUrlEncodedRequest + * @summary summary + * @request POST:/pet/single-form-url-encoded + */ + singleFormUrlEncodedRequest: (data: SingleFormUrlEncodedRequestPayloadTTT, params: RequestParams = {}) => + this.request({ + path: `/pet/single-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest + * @summary summary + * @request POST:/pet/form-url-encoded + */ + formUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest2 + * @summary summary + * @request POST:/pet/end-form-url-encoded + * @originalName formUrlEncodedRequest + * @duplicate + */ + formUrlEncodedRequest2: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/end-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @tags pet + * @name FindPetsByTags + * @summary Finds Pets by tags + * @request GET:/pet/findByTags + * @deprecated + * @secure + */ + findPetsByTags: ( + query: { + /** Tags to filter by */ + tags: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByTags`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Returns a single pet + * + * @tags pet + * @name GetPetById + * @summary Find pet by ID + * @request GET:/pet/{petId} + * @secure + */ + getPetById: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePetWithForm + * @summary Updates a pet in the store with form data + * @request POST:/pet/{petId} + * @secure + */ + updatePetWithForm: (petId: number, data: UpdatePetWithFormPayloadTTT, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name DeletePet + * @summary Deletes a pet + * @request DELETE:/pet/{petId} + * @secure + */ + deletePet: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "DELETE", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UploadFile + * @summary uploads an image + * @request POST:/pet/{petId}/uploadImage + * @secure + */ + uploadFile: (petId: number, data: UploadFilePayloadTTT, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}/uploadImage`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + format: "json", + ...params, + }), + }; + store = { + /** + * @description Returns a map of status codes to quantities + * + * @tags store + * @name GetInventory + * @summary Returns pet inventories by status + * @request GET:/store/inventory + * @secure + */ + getInventory: (params: RequestParams = {}) => + this.request, any>({ + path: `/store/inventory`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags store + * @name PlaceOrder + * @summary Place an order for a pet + * @request POST:/store/order + */ + placeOrder: (body: OrderTTT, params: RequestParams = {}) => + this.request({ + path: `/store/order`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @tags store + * @name GetOrderById + * @summary Find purchase order by ID + * @request GET:/store/order/{orderId} + */ + getOrderById: (orderId: number, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @tags store + * @name DeleteOrder + * @summary Delete purchase order by ID + * @request DELETE:/store/order/{orderId} + */ + deleteOrder: (orderId: string, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "DELETE", + ...params, + }), + }; + user = { + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name CreateUser + * @summary Create user + * @request POST:/user + */ + createUser: (body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithArrayInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithArray + */ + createUsersWithArrayInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithArray`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithListInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithList + */ + createUsersWithListInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithList`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LoginUser + * @summary Logs user into the system + * @request GET:/user/login + */ + loginUser: ( + query: { + /** The user name for login */ + username: string; + /** The password for login in clear text */ + password: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/login`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags user + * @name LogoutUser + * @summary Logs out current logged in user session + * @request GET:/user/logout + */ + logoutUser: (params: RequestParams = {}) => + this.request({ + path: `/user/logout`, + method: "GET", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:/user/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:/user/{username} + */ + updateUser: (username: string, body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:/user/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "DELETE", + ...params, + }), + }; +} diff --git a/tests/spec/extractRequestBody/test.js b/tests/spec/extractRequestBody/test.js index 96cadbda..4dcaf1b8 100644 --- a/tests/spec/extractRequestBody/test.js +++ b/tests/spec/extractRequestBody/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/extractRequestParams/expected.ts b/tests/spec/extractRequestParams/expected.ts new file mode 100644 index 00000000..73910194 --- /dev/null +++ b/tests/spec/extractRequestParams/expected.ts @@ -0,0 +1,631 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Authentiq ID in JWT format, self-signed. + */ +export interface AuthentiqID { + /** device token for push messages */ + devtoken?: string; + /** UUID and public signing key */ + sub: string; +} + +/** + * Claim in JWT format, self- or issuer-signed. + */ +export interface Claims { + email?: string; + phone?: string; + /** claim scope */ + scope: string; + /** UUID */ + sub: string; + type?: string; +} + +export interface Error { + detail?: string; + error: number; + title?: string; + /** unique uri for this error */ + type?: string; +} + +/** + * PushToken in JWT format, self-signed. + */ +export interface PushToken { + /** audience (URI) */ + aud: string; + exp?: number; + iat?: number; + /** issuer (URI) */ + iss: string; + nbf?: number; + /** UUID and public signing key */ + sub: string; +} + +export interface KeyRevokeNosecretParams { + /** primary email associated to Key (ID) */ + email: string; + /** primary phone number, international representation */ + phone: string; + /** verification code sent by email */ + code?: string; +} + +export interface KeyRevokeParams { + /** revokation secret */ + secret: string; + /** bar baz */ + barBaz: string; + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; +} + +export interface KeyRevoke2Params { + /** revokation secret */ + secret: string; + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; +} + +export interface PushLoginRequestParams { + /** URI App will connect to */ + callback: string; +} + +export interface SignRequestParams { + /** test only mode, using test issuer */ + test?: number; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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://6-dot-authentiqio.appspot.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Authentiq + * @version 6 + * @license Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://authentiq.com/terms/ + * @baseUrl https://6-dot-authentiqio.appspot.com + * @contact Authentiq team (http://authentiq.io/support) + * + * Strong authentication, without the passwords. + */ +export class Api extends HttpClient { + key = { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + */ + keyRevokeNosecret: (query: KeyRevokeNosecretParams, params: RequestParams = {}) => + this.request< + { + /** pending or done */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + keyRegister: (body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Revoke an Identity (Key) with a revocation secret + * + * @name KeyRevoke + * @request DELETE:/key/{bar-baz}/{PK} + */ + keyRevoke: ({ barBaz, pk, ...query }: KeyRevokeParams, params: RequestParams = {}) => + this.request({ + path: `/key/${barBaz}/${pk}`, + method: "DELETE", + query: query, + ...params, + }), + + /** + * @description Revoke an Identity (Key) with a revocation secret + * + * @tags key, delete + * @name KeyRevoke2 + * @request DELETE:/key/{PK} + * @originalName keyRevoke + * @duplicate + */ + keyRevoke2: ({ pk, ...query }: KeyRevoke2Params, params: RequestParams = {}) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get public details of an Authentiq ID. + * + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + */ + getKey: (pk: string, params: RequestParams = {}) => + this.request< + { + /** @format date-time */ + since?: string; + status?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD info on Authentiq ID + * + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + */ + headKey: (pk: string, params: RequestParams = {}) => + this.request({ + path: `/key/${pk}`, + method: "HEAD", + ...params, + }), + + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + */ + keyUpdate: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + */ + keyBind: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + }; + login = { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + */ + pushLoginRequest: (query: PushLoginRequestParams, body: PushToken, params: RequestParams = {}) => + this.request< + { + /** sent */ + status?: string; + }, + Error + >({ + path: `/login`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + }; + scope = { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, post + * @name SignRequest + * @request POST:/scope + */ + signRequest: (query: SignRequestParams, body: Claims, params: RequestParams = {}) => + this.request< + { + /** 20-character ID */ + job?: string; + /** waiting */ + status?: string; + }, + Error + >({ + path: `/scope`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + + /** + * @description delete a verification job + * + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + */ + signDelete: (job: string, params: RequestParams = {}) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "DELETE", + format: "json", + ...params, + }), + + /** + * @description get the status / current content of a verification job + * + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + */ + signRetrieve: (job: string, params: RequestParams = {}) => + this.request< + { + exp?: number; + field?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD to get the status of a verification job + * + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + */ + signRetrieveHead: (job: string, params: RequestParams = {}) => + this.request({ + path: `/scope/${job}`, + method: "HEAD", + ...params, + }), + + /** + * @description this is a scope confirmation + * + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + */ + signConfirm: (job: string, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "POST", + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + */ + signUpdate: (job: string, params: RequestParams = {}) => + this.request< + { + /** result is JWT or JSON?? */ + jwt?: string; + /** ready */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "PUT", + ...params, + }), + }; +} diff --git a/tests/spec/extractRequestParams/test.js b/tests/spec/extractRequestParams/test.js index d59ab6a6..e1d6c4da 100644 --- a/tests/spec/extractRequestParams/test.js +++ b/tests/spec/extractRequestParams/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { extractRequestParams: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/extractResponseBody/expected.ts b/tests/spec/extractResponseBody/expected.ts new file mode 100644 index 00000000..42d962c5 --- /dev/null +++ b/tests/spec/extractResponseBody/expected.ts @@ -0,0 +1,837 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Pet Order + * An order for a pets from the pet store + * @example {"petId":6,"quantity":1,"id":0,"shipDate":"2000-01-23T04:56:07.000+00:00","complete":false,"status":"placed"} + */ +export interface OrderTTT { + /** @format int64 */ + id?: number; + /** @format int64 */ + petId?: number; + /** @format int32 */ + quantity?: number; + /** @format date-time */ + shipDate?: string; + /** Order Status */ + status?: "placed" | "approved" | "delivered" | null; + complete?: boolean; +} + +/** + * Pet category + * A category for a pet + * @example {"name":"name","id":6} + */ +export interface CategoryTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +/** + * a User + * A User who is purchasing from the pet store + * @example {"firstName":"firstName","lastName":"lastName","password":"password","userStatus":6,"phone":"phone","id":0,"email":"email","username":"username"} + */ +export interface UserTTT { + /** @format int64 */ + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + /** + * User Status + * @format int32 + */ + userStatus?: number; +} + +/** + * Pet Tag + * A tag for a pet + * @example {"name":"name","id":1} + */ +export interface TagTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +export enum PetNamesTTT { + FluffyHero = "Fluffy Hero", + PiggyPo = "Piggy Po", + SwaggerTypescriptApi = "Swagger Typescript Api", + UPPER_CASE = "UPPER_CASE", +} + +export type PetIdsTTT = 10 | 20 | 30 | 40; + +export type PetIdsWithWrongEnumTTT = 10 | 20 | 30 | 40; + +/** + * a Pet + * A pet for sale in the pet store + * @example {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"} + */ +export interface PetTTT { + /** @format int64 */ + id?: number; + /** A category for a pet */ + category?: CategoryTTT; + /** @example doggie */ + name: string; + photoUrls: string[]; + tags?: TagTTT[]; + /** pet status in the store */ + status?: "available" | "pending" | "sold"; +} + +/** + * some description + */ +export interface AmountTTT { + /** + * some description + * + * @format double + * @min 0.01 + * @max 1000000000000000 + */ + value: number; + /** + * some description + * + */ + currency: CurrencyTTT; +} + +/** + * some description + * @pattern ^[A-Z]{3,3}$ + */ +export type CurrencyTTT = string; + +export type FindPetsByStatusDataTTT = PetTTT[]; + +export type SingleFormUrlEncodedRequestDataTTT = any; + +export type FormUrlEncodedRequestDataTTT = any; + +export type FormUrlEncodedRequest2DataTTT = any; + +export type FindPetsByTagsDataTTT = PetTTT[]; + +export type GetPetByIdDataTTT = PetTTT; + +/** + * An uploaded response + * Describes the result of uploading an image resource + * @example {"code":0,"type":"type","message":"message"} + */ +export interface UploadFileDataTTT { + /** @format int32 */ + code?: number; + type?: string; + message?: string; +} + +export type GetInventoryDataTTT = Record; + +export type PlaceOrderDataTTT = OrderTTT; + +export type GetOrderByIdDataTTT = OrderTTT; + +export type LoginUserDataTTT = string; + +export type GetUserByNameDataTTT = UserTTT; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/v2"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/v2 + * @externalDocs http://swagger.io + * @contact + * + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + */ +export class Api extends HttpClient { + pet = { + /** + * No description + * + * @tags pet + * @name AddPet + * @summary Add a new pet to the store + * @request POST:/pet + * @secure + */ + addPet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "POST", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePet + * @summary Update an existing pet + * @request PUT:/pet + * @secure + */ + updatePet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "PUT", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * @description Multiple status values can be provided with comma separated strings + * + * @tags pet + * @name FindPetsByStatus + * @summary Finds Pets by status + * @request GET:/pet/findByStatus + * @secure + */ + findPetsByStatus: ( + query: { + /** Status values that need to be considered for filter */ + status: ("available" | "pending" | "sold")[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByStatus`, + method: "GET", + query: query, + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name SingleFormUrlEncodedRequest + * @summary summary + * @request POST:/pet/single-form-url-encoded + */ + singleFormUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/single-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest + * @summary summary + * @request POST:/pet/form-url-encoded + */ + formUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest2 + * @summary summary + * @request POST:/pet/end-form-url-encoded + * @originalName formUrlEncodedRequest + * @duplicate + */ + formUrlEncodedRequest2: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/end-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @tags pet + * @name FindPetsByTags + * @summary Finds Pets by tags + * @request GET:/pet/findByTags + * @deprecated + * @secure + */ + findPetsByTags: ( + query: { + /** Tags to filter by */ + tags: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByTags`, + method: "GET", + query: query, + secure: true, + ...params, + }), + + /** + * @description Returns a single pet + * + * @tags pet + * @name GetPetById + * @summary Find pet by ID + * @request GET:/pet/{petId} + * @secure + */ + getPetById: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "GET", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePetWithForm + * @summary Updates a pet in the store with form data + * @request POST:/pet/{petId} + * @secure + */ + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/${petId}`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name DeletePet + * @summary Deletes a pet + * @request DELETE:/pet/{petId} + * @secure + */ + deletePet: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "DELETE", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UploadFile + * @summary uploads an image + * @request POST:/pet/{petId}/uploadImage + * @secure + */ + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/${petId}/uploadImage`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + }; + store = { + /** + * @description Returns a map of status codes to quantities + * + * @tags store + * @name GetInventory + * @summary Returns pet inventories by status + * @request GET:/store/inventory + * @secure + */ + getInventory: (params: RequestParams = {}) => + this.request({ + path: `/store/inventory`, + method: "GET", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags store + * @name PlaceOrder + * @summary Place an order for a pet + * @request POST:/store/order + */ + placeOrder: (body: OrderTTT, params: RequestParams = {}) => + this.request({ + path: `/store/order`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @tags store + * @name GetOrderById + * @summary Find purchase order by ID + * @request GET:/store/order/{orderId} + */ + getOrderById: (orderId: number, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "GET", + ...params, + }), + + /** + * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @tags store + * @name DeleteOrder + * @summary Delete purchase order by ID + * @request DELETE:/store/order/{orderId} + */ + deleteOrder: (orderId: string, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "DELETE", + ...params, + }), + }; + user = { + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name CreateUser + * @summary Create user + * @request POST:/user + */ + createUser: (body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithArrayInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithArray + */ + createUsersWithArrayInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithArray`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithListInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithList + */ + createUsersWithListInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithList`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LoginUser + * @summary Logs user into the system + * @request GET:/user/login + */ + loginUser: ( + query: { + /** The user name for login */ + username: string; + /** The password for login in clear text */ + password: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/login`, + method: "GET", + query: query, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LogoutUser + * @summary Logs out current logged in user session + * @request GET:/user/logout + */ + logoutUser: (params: RequestParams = {}) => + this.request({ + path: `/user/logout`, + method: "GET", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:/user/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "GET", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:/user/{username} + */ + updateUser: (username: string, body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:/user/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "DELETE", + ...params, + }), + }; +} diff --git a/tests/spec/extractResponseBody/test.js b/tests/spec/extractResponseBody/test.js index 5017c6df..1bdd8f62 100644 --- a/tests/spec/extractResponseBody/test.js +++ b/tests/spec/extractResponseBody/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/extractResponseError/expected.ts b/tests/spec/extractResponseError/expected.ts new file mode 100644 index 00000000..8e4e02be --- /dev/null +++ b/tests/spec/extractResponseError/expected.ts @@ -0,0 +1,859 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Pet Order + * An order for a pets from the pet store + * @example {"petId":6,"quantity":1,"id":0,"shipDate":"2000-01-23T04:56:07.000+00:00","complete":false,"status":"placed"} + */ +export interface OrderTTT { + /** @format int64 */ + id?: number; + /** @format int64 */ + petId?: number; + /** @format int32 */ + quantity?: number; + /** @format date-time */ + shipDate?: string; + /** Order Status */ + status?: "placed" | "approved" | "delivered" | null; + complete?: boolean; +} + +/** + * Pet category + * A category for a pet + * @example {"name":"name","id":6} + */ +export interface CategoryTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +/** + * a User + * A User who is purchasing from the pet store + * @example {"firstName":"firstName","lastName":"lastName","password":"password","userStatus":6,"phone":"phone","id":0,"email":"email","username":"username"} + */ +export interface UserTTT { + /** @format int64 */ + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + /** + * User Status + * @format int32 + */ + userStatus?: number; +} + +/** + * Pet Tag + * A tag for a pet + * @example {"name":"name","id":1} + */ +export interface TagTTT { + /** @format int64 */ + id?: number; + name?: string; +} + +export enum PetNamesTTT { + FluffyHero = "Fluffy Hero", + PiggyPo = "Piggy Po", + SwaggerTypescriptApi = "Swagger Typescript Api", + UPPER_CASE = "UPPER_CASE", +} + +export type PetIdsTTT = 10 | 20 | 30 | 40; + +export type PetIdsWithWrongEnumTTT = 10 | 20 | 30 | 40; + +/** + * a Pet + * A pet for sale in the pet store + * @example {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"} + */ +export interface PetTTT { + /** @format int64 */ + id?: number; + /** A category for a pet */ + category?: CategoryTTT; + /** @example doggie */ + name: string; + photoUrls: string[]; + tags?: TagTTT[]; + /** pet status in the store */ + status?: "available" | "pending" | "sold"; +} + +/** + * some description + */ +export interface AmountTTT { + /** + * some description + * + * @format double + * @min 0.01 + * @max 1000000000000000 + */ + value: number; + /** + * some description + * + */ + currency: CurrencyTTT; +} + +/** + * some description + * @pattern ^[A-Z]{3,3}$ + */ +export type CurrencyTTT = string; + +/** + * HttpError HttpError HttpErrorRetry HttpValidationError HttpError + * asd asd asd asd asd + */ +export type FormUrlEncodedRequest2ErrorTTT = + | { + /** + * Detail + * asdsad asd asd sa dsa + * @example asdasd sad sa dsad + */ + detail: string; + } + | { + /** + * Detail + * sadas das dasd asd + * @example sadasd sads adsad asd + */ + detail: string; + /** + * sadsa dsa dsa das + * sadas dasd as dasd asd + * @example 600 + */ + retry_after: number; + } + | Record; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/v2"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/v2 + * @externalDocs http://swagger.io + * @contact + * + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + */ +export class Api extends HttpClient { + pet = { + /** + * No description + * + * @tags pet + * @name AddPet + * @summary Add a new pet to the store + * @request POST:/pet + * @secure + */ + addPet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "POST", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePet + * @summary Update an existing pet + * @request PUT:/pet + * @secure + */ + updatePet: (body: PetTTT, params: RequestParams = {}) => + this.request({ + path: `/pet`, + method: "PUT", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * @description Multiple status values can be provided with comma separated strings + * + * @tags pet + * @name FindPetsByStatus + * @summary Finds Pets by status + * @request GET:/pet/findByStatus + * @secure + */ + findPetsByStatus: ( + query: { + /** Status values that need to be considered for filter */ + status: ("available" | "pending" | "sold")[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByStatus`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name SingleFormUrlEncodedRequest + * @summary summary + * @request POST:/pet/single-form-url-encoded + */ + singleFormUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/single-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest + * @summary summary + * @request POST:/pet/form-url-encoded + */ + formUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name FormUrlEncodedRequest2 + * @summary summary + * @request POST:/pet/end-form-url-encoded + * @originalName formUrlEncodedRequest + * @duplicate + */ + formUrlEncodedRequest2: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** + * Id + * asd asdsad asd as + */ + id: string; + }, + FormUrlEncodedRequest2ErrorTTT + >({ + path: `/pet/end-form-url-encoded`, + method: "POST", + body: data, + type: ContentType.UrlEncoded, + format: "json", + ...params, + }), + + /** + * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @tags pet + * @name FindPetsByTags + * @summary Finds Pets by tags + * @request GET:/pet/findByTags + * @deprecated + * @secure + */ + findPetsByTags: ( + query: { + /** Tags to filter by */ + tags: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/findByTags`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Returns a single pet + * + * @tags pet + * @name GetPetById + * @summary Find pet by ID + * @request GET:/pet/{petId} + * @secure + */ + getPetById: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePetWithForm + * @summary Updates a pet in the store with form data + * @request POST:/pet/{petId} + * @secure + */ + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/pet/${petId}`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name DeletePet + * @summary Deletes a pet + * @request DELETE:/pet/{petId} + * @secure + */ + deletePet: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/pet/${petId}`, + method: "DELETE", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UploadFile + * @summary uploads an image + * @request POST:/pet/{petId}/uploadImage + * @secure + */ + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** @format int32 */ + code?: number; + type?: string; + message?: string; + }, + any + >({ + path: `/pet/${petId}/uploadImage`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + format: "json", + ...params, + }), + }; + store = { + /** + * @description Returns a map of status codes to quantities + * + * @tags store + * @name GetInventory + * @summary Returns pet inventories by status + * @request GET:/store/inventory + * @secure + */ + getInventory: (params: RequestParams = {}) => + this.request, any>({ + path: `/store/inventory`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags store + * @name PlaceOrder + * @summary Place an order for a pet + * @request POST:/store/order + */ + placeOrder: (body: OrderTTT, params: RequestParams = {}) => + this.request({ + path: `/store/order`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @tags store + * @name GetOrderById + * @summary Find purchase order by ID + * @request GET:/store/order/{orderId} + */ + getOrderById: (orderId: number, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @tags store + * @name DeleteOrder + * @summary Delete purchase order by ID + * @request DELETE:/store/order/{orderId} + */ + deleteOrder: (orderId: string, params: RequestParams = {}) => + this.request({ + path: `/store/order/${orderId}`, + method: "DELETE", + ...params, + }), + }; + user = { + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name CreateUser + * @summary Create user + * @request POST:/user + */ + createUser: (body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithArrayInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithArray + */ + createUsersWithArrayInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithArray`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithListInput + * @summary Creates list of users with given input array + * @request POST:/user/createWithList + */ + createUsersWithListInput: (body: UserTTT[], params: RequestParams = {}) => + this.request({ + path: `/user/createWithList`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LoginUser + * @summary Logs user into the system + * @request GET:/user/login + */ + loginUser: ( + query: { + /** The user name for login */ + username: string; + /** The password for login in clear text */ + password: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/login`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags user + * @name LogoutUser + * @summary Logs out current logged in user session + * @request GET:/user/logout + */ + logoutUser: (params: RequestParams = {}) => + this.request({ + path: `/user/logout`, + method: "GET", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:/user/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:/user/{username} + */ + updateUser: (username: string, body: UserTTT, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:/user/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/${username}`, + method: "DELETE", + ...params, + }), + }; +} diff --git a/tests/spec/extractResponseError/test.js b/tests/spec/extractResponseError/test.js index e0821fe4..714f26d1 100644 --- a/tests/spec/extractResponseError/test.js +++ b/tests/spec/extractResponseError/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { typeSuffix: "TTT", }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/modular/Key.ts b/tests/spec/modular/expected/Key.ts similarity index 100% rename from tests/spec/modular/Key.ts rename to tests/spec/modular/expected/Key.ts diff --git a/tests/spec/modular/KeyRoute.ts b/tests/spec/modular/expected/KeyRoute.ts similarity index 100% rename from tests/spec/modular/KeyRoute.ts rename to tests/spec/modular/expected/KeyRoute.ts diff --git a/tests/spec/modular/Login.ts b/tests/spec/modular/expected/Login.ts similarity index 100% rename from tests/spec/modular/Login.ts rename to tests/spec/modular/expected/Login.ts diff --git a/tests/spec/modular/LoginRoute.ts b/tests/spec/modular/expected/LoginRoute.ts similarity index 100% rename from tests/spec/modular/LoginRoute.ts rename to tests/spec/modular/expected/LoginRoute.ts diff --git a/tests/spec/modular/Scope.ts b/tests/spec/modular/expected/Scope.ts similarity index 100% rename from tests/spec/modular/Scope.ts rename to tests/spec/modular/expected/Scope.ts diff --git a/tests/spec/modular/ScopeRoute.ts b/tests/spec/modular/expected/ScopeRoute.ts similarity index 100% rename from tests/spec/modular/ScopeRoute.ts rename to tests/spec/modular/expected/ScopeRoute.ts diff --git a/tests/spec/modular/data-contracts.ts b/tests/spec/modular/expected/data-contracts.ts similarity index 100% rename from tests/spec/modular/data-contracts.ts rename to tests/spec/modular/expected/data-contracts.ts diff --git a/tests/spec/modular/http-client.ts b/tests/spec/modular/expected/http-client.ts similarity index 100% rename from tests/spec/modular/http-client.ts rename to tests/spec/modular/expected/http-client.ts diff --git a/tests/spec/modular/route-types.ts b/tests/spec/modular/expected/route-types.ts similarity index 100% rename from tests/spec/modular/route-types.ts rename to tests/spec/modular/expected/route-types.ts diff --git a/tests/spec/modular/generated/Key.ts b/tests/spec/modular/generated/Key.ts new file mode 100644 index 00000000..0ee5c954 --- /dev/null +++ b/tests/spec/modular/generated/Key.ts @@ -0,0 +1,176 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { AuthentiqID, Error } from "./data-contracts"; +import { HttpClient, RequestParams } from "./http-client"; + +export class Key extends HttpClient { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + */ + keyRevokeNosecret = ( + query: { + /** primary email associated to Key (ID) */ + email: string; + /** primary phone number, international representation */ + phone: string; + /** verification code sent by email */ + code?: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** pending or done */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "DELETE", + query: query, + format: "json", + ...params, + }); + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + keyRegister = (body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "POST", + body: body, + format: "json", + ...params, + }); + /** + * @description Revoke an Identity (Key) with a revocation secret + * + * @tags key, delete + * @name KeyRevoke + * @request DELETE:/key/{PK} + */ + keyRevoke = ( + pk: string, + query: { + /** revokation secret */ + secret: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "DELETE", + query: query, + format: "json", + ...params, + }); + /** + * @description Get public details of an Authentiq ID. + * + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + */ + getKey = (pk: string, params: RequestParams = {}) => + this.request< + { + /** @format date-time */ + since?: string; + status?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "GET", + format: "json", + ...params, + }); + /** + * @description HEAD info on Authentiq ID + * + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + */ + headKey = (pk: string, params: RequestParams = {}) => + this.request({ + path: `/key/${pk}`, + method: "HEAD", + ...params, + }); + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + */ + keyUpdate = (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "POST", + body: body, + format: "json", + ...params, + }); + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + */ + keyBind = (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "PUT", + body: body, + format: "json", + ...params, + }); +} diff --git a/tests/spec/modular/generated/KeyRoute.ts b/tests/spec/modular/generated/KeyRoute.ts new file mode 100644 index 00000000..be168a2f --- /dev/null +++ b/tests/spec/modular/generated/KeyRoute.ts @@ -0,0 +1,160 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { AuthentiqID } from "./data-contracts"; + +export namespace Key { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + */ + export namespace KeyRevokeNosecret { + export type RequestParams = {}; + export type RequestQuery = { + /** primary email associated to Key (ID) */ + email: string; + /** primary phone number, international representation */ + phone: string; + /** verification code sent by email */ + code?: string; + }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** pending or done */ + status?: string; + }; + } + + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + export namespace KeyRegister { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }; + } + + /** + * @description Revoke an Identity (Key) with a revocation secret + * @tags key, delete + * @name KeyRevoke + * @request DELETE:/key/{PK} + */ + export namespace KeyRevoke { + export type RequestParams = { + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; + }; + export type RequestQuery = { + /** revokation secret */ + secret: string; + }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** done */ + status?: string; + }; + } + + /** + * @description Get public details of an Authentiq ID. + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + */ + export namespace GetKey { + export type RequestParams = { + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** @format date-time */ + since?: string; + status?: string; + /** base64safe encoded public signing key */ + sub?: string; + }; + } + + /** + * @description HEAD info on Authentiq ID + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + */ + export namespace HeadKey { + export type RequestParams = { + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = void; + } + + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + */ + export namespace KeyUpdate { + export type RequestParams = { + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; + }; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { + /** confirmed */ + status?: string; + }; + } + + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + */ + export namespace KeyBind { + export type RequestParams = { + /** Public Signing Key - Authentiq ID (43 chars) */ + pk: string; + }; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { + /** confirmed */ + status?: string; + }; + } +} diff --git a/tests/spec/modular/generated/Login.ts b/tests/spec/modular/generated/Login.ts new file mode 100644 index 00000000..c9390b9f --- /dev/null +++ b/tests/spec/modular/generated/Login.ts @@ -0,0 +1,67 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { Error, PushToken } from "./data-contracts"; +import { HttpClient, RequestParams } from "./http-client"; + +export class Login extends HttpClient { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + */ + pushLoginRequest = ( + query: { + /** URI App will connect to */ + callback: string; + }, + body: PushToken, + params: RequestParams = {}, + ) => + this.request< + { + /** sent */ + status?: string; + }, + Error + >({ + path: `/login`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }); + /** + * @description Get a current key register + * + * @tags key, get + * @name KeyRegister + * @request GET:/login + */ + keyRegister = (params: RequestParams = {}) => + this.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + Error + >({ + path: `/login`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/tests/spec/modular/generated/LoginRoute.ts b/tests/spec/modular/generated/LoginRoute.ts new file mode 100644 index 00000000..5e6e1bc2 --- /dev/null +++ b/tests/spec/modular/generated/LoginRoute.ts @@ -0,0 +1,53 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { PushToken } from "./data-contracts"; + +export namespace Login { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + */ + export namespace PushLoginRequest { + export type RequestParams = {}; + export type RequestQuery = { + /** URI App will connect to */ + callback: string; + }; + export type RequestBody = PushToken; + export type RequestHeaders = {}; + export type ResponseBody = { + /** sent */ + status?: string; + }; + } + + /** + * @description Get a current key register + * @tags key, get + * @name KeyRegister + * @request GET:/login + */ + export namespace KeyRegister { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }; + } +} diff --git a/tests/spec/modular/generated/Scope.ts b/tests/spec/modular/generated/Scope.ts new file mode 100644 index 00000000..beefc4c8 --- /dev/null +++ b/tests/spec/modular/generated/Scope.ts @@ -0,0 +1,144 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { Claims, Error } from "./data-contracts"; +import { ContentType, HttpClient, RequestParams } from "./http-client"; + +export class Scope extends HttpClient { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, post + * @name SignRequest + * @request POST:/scope + */ + signRequest = ( + body: Claims, + query?: { + /** test only mode, using test issuer */ + test?: number; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** 20-character ID */ + job?: string; + /** waiting */ + status?: string; + }, + Error + >({ + path: `/scope`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }); + /** + * @description delete a verification job + * + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + */ + signDelete = (job: string, params: RequestParams = {}) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "DELETE", + format: "json", + ...params, + }); + /** + * @description get the status / current content of a verification job + * + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + */ + signRetrieve = (job: string, params: RequestParams = {}) => + this.request< + { + exp?: number; + field?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "GET", + format: "json", + ...params, + }); + /** + * @description HEAD to get the status of a verification job + * + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + */ + signRetrieveHead = (job: string, params: RequestParams = {}) => + this.request({ + path: `/scope/${job}`, + method: "HEAD", + ...params, + }); + /** + * @description this is a scope confirmation + * + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + */ + signConfirm = (job: string, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "POST", + type: ContentType.Json, + format: "json", + ...params, + }); + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + */ + signUpdate = (job: string, params: RequestParams = {}) => + this.request< + { + /** result is JWT or JSON?? */ + jwt?: string; + /** ready */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "PUT", + ...params, + }); +} diff --git a/tests/spec/modular/generated/ScopeRoute.ts b/tests/spec/modular/generated/ScopeRoute.ts new file mode 100644 index 00000000..0d645b8f --- /dev/null +++ b/tests/spec/modular/generated/ScopeRoute.ts @@ -0,0 +1,137 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { Claims } from "./data-contracts"; + +export namespace Scope { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags scope, post + * @name SignRequest + * @request POST:/scope + */ + export namespace SignRequest { + export type RequestParams = {}; + export type RequestQuery = { + /** test only mode, using test issuer */ + test?: number; + }; + export type RequestBody = Claims; + export type RequestHeaders = {}; + export type ResponseBody = { + /** 20-character ID */ + job?: string; + /** waiting */ + status?: string; + }; + } + + /** + * @description delete a verification job + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + */ + export namespace SignDelete { + export type RequestParams = { + /** Job ID (20 chars) */ + job: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** done */ + status?: string; + }; + } + + /** + * @description get the status / current content of a verification job + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + */ + export namespace SignRetrieve { + export type RequestParams = { + /** Job ID (20 chars) */ + job: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + exp?: number; + field?: string; + /** base64safe encoded public signing key */ + sub?: string; + }; + } + + /** + * @description HEAD to get the status of a verification job + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + */ + export namespace SignRetrieveHead { + export type RequestParams = { + /** Job ID (20 chars) */ + job: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = void; + } + + /** + * @description this is a scope confirmation + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + */ + export namespace SignConfirm { + export type RequestParams = { + /** Job ID (20 chars) */ + job: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** confirmed */ + status?: string; + }; + } + + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + */ + export namespace SignUpdate { + export type RequestParams = { + /** Job ID (20 chars) */ + job: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + /** result is JWT or JSON?? */ + jwt?: string; + /** ready */ + status?: string; + }; + } +} diff --git a/tests/spec/modular/generated/data-contracts.ts b/tests/spec/modular/generated/data-contracts.ts new file mode 100644 index 00000000..e3bc93eb --- /dev/null +++ b/tests/spec/modular/generated/data-contracts.ts @@ -0,0 +1,56 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Authentiq ID in JWT format, self-signed. + */ +export interface AuthentiqID { + /** device token for push messages */ + devtoken?: string; + /** UUID and public signing key */ + sub: string; +} + +/** + * Claim in JWT format, self- or issuer-signed. + */ +export interface Claims { + email?: string; + phone?: string; + /** claim scope */ + scope: string; + /** UUID */ + sub: string; + type?: string; +} + +export interface Error { + detail?: string; + error: number; + title?: string; + /** unique uri for this error */ + type?: string; +} + +/** + * PushToken in JWT format, self-signed. + */ +export interface PushToken { + /** audience (URI) */ + aud: string; + exp?: number; + iat?: number; + /** issuer (URI) */ + iss: string; + nbf?: number; + /** UUID and public signing key */ + sub: string; +} diff --git a/tests/spec/modular/generated/http-client.ts b/tests/spec/modular/generated/http-client.ts new file mode 100644 index 00000000..f0f5ed83 --- /dev/null +++ b/tests/spec/modular/generated/http-client.ts @@ -0,0 +1,218 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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://6-dot-authentiqio.appspot.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} diff --git a/tests/spec/modular/generated/route-types.ts b/tests/spec/modular/generated/route-types.ts new file mode 100644 index 00000000..d1cd6888 --- /dev/null +++ b/tests/spec/modular/generated/route-types.ts @@ -0,0 +1,216 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +import { AuthentiqID, Claims, PushToken } from "./data-contracts"; + +export namespace key { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + */ + export namespace KeyRevokeNosecret { + export type RequestParams = {}; + export type RequestQuery = { email: string; phone: string; code?: string }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + export namespace KeyRegister { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { secret?: string; status?: string }; + } + /** + * @description Revoke an Identity (Key) with a revocation secret + * @tags key, delete + * @name KeyRevoke + * @request DELETE:/key/{PK} + */ + export namespace KeyRevoke { + export type RequestParams = { pk: string }; + export type RequestQuery = { secret: string }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description Get public details of an Authentiq ID. + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + */ + export namespace GetKey { + export type RequestParams = { pk: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { since?: string; status?: string; sub?: string }; + } + /** + * @description HEAD info on Authentiq ID + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + */ + export namespace HeadKey { + export type RequestParams = { pk: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = void; + } + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + */ + export namespace KeyUpdate { + export type RequestParams = { pk: string }; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + */ + export namespace KeyBind { + export type RequestParams = { pk: string }; + export type RequestQuery = {}; + export type RequestBody = AuthentiqID; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } +} + +export namespace login { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + */ + export namespace PushLoginRequest { + export type RequestParams = {}; + export type RequestQuery = { callback: string }; + export type RequestBody = PushToken; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description Get a current key register + * @tags key, get + * @name KeyRegister + * @request GET:/login + */ + export namespace KeyRegister { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { secret?: string; status?: string }; + } +} + +export namespace scope { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags scope, post + * @name SignRequest + * @request POST:/scope + */ + export namespace SignRequest { + export type RequestParams = {}; + export type RequestQuery = { test?: number }; + export type RequestBody = Claims; + export type RequestHeaders = {}; + export type ResponseBody = { job?: string; status?: string }; + } + /** + * @description delete a verification job + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + */ + export namespace SignDelete { + export type RequestParams = { job: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description get the status / current content of a verification job + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + */ + export namespace SignRetrieve { + export type RequestParams = { job: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { exp?: number; field?: string; sub?: string }; + } + /** + * @description HEAD to get the status of a verification job + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + */ + export namespace SignRetrieveHead { + export type RequestParams = { job: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = void; + } + /** + * @description this is a scope confirmation + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + */ + export namespace SignConfirm { + export type RequestParams = { job: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { status?: string }; + } + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + */ + export namespace SignUpdate { + export type RequestParams = { job: string }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { jwt?: string; status?: string }; + } +} diff --git a/tests/spec/modular/test.js b/tests/spec/modular/test.js index a0dee59c..f9962d78 100644 --- a/tests/spec/modular/test.js +++ b/tests/spec/modular/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -10,18 +11,29 @@ schemas.forEach(({ absolutePath, Exception }) => { testName: "--modular option test", silent: true, input: absolutePath, - output: resolve(__dirname, "./"), + output: resolve(__dirname, "./generated"), modular: true, generateClient: true, generateRouteTypes: true, }).then(() => { - const diagnostics = [ - ...validateGeneratedModule(resolve(__dirname, `./data-contracts.ts`)), - ...validateGeneratedModule(resolve(__dirname, `./http-client.ts`)), - ...validateGeneratedModule(resolve(__dirname, `./Key`)), - ...validateGeneratedModule(resolve(__dirname, `./Login`)), - ...validateGeneratedModule(resolve(__dirname, `./Scope`)), + const outputFileNames = [ + "data-contracts", + "http-client", + "Key", + "KeyRoute", + "Login", + "LoginRoute", + "route-types", + "Scope", + "ScopeRoute", ]; - if (diagnostics.length) throw new Exception("Failed"); + + for (const fileName of outputFileNames) { + validateGeneratedModule(resolve(__dirname, `./generated/${fileName}.ts`)); + assertGeneratedModule( + resolve(__dirname, `./generated/${fileName}.ts`), + resolve(__dirname, `./expected/${fileName}.ts`), + ); + } }); }); diff --git a/tests/spec/moduleNameFirstTag/expected.ts b/tests/spec/moduleNameFirstTag/expected.ts new file mode 100644 index 00000000..08000b74 --- /dev/null +++ b/tests/spec/moduleNameFirstTag/expected.ts @@ -0,0 +1,801 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Pet Order + * An order for a pets from the pet store + * @example {"petId":6,"quantity":1,"id":0,"shipDate":"2000-01-23T04:56:07.000+00:00","complete":false,"status":"placed"} + */ +export interface Order { + /** @format int64 */ + id?: number; + /** @format int64 */ + petId?: number; + /** @format int32 */ + quantity?: number; + /** @format date-time */ + shipDate?: string; + /** Order Status */ + status?: "placed" | "approved" | "delivered"; + complete?: boolean; +} + +/** + * Pet category + * A category for a pet + * @example {"name":"name","id":6} + */ +export interface Category { + /** @format int64 */ + id?: number; + name?: string; +} + +/** + * a User + * A User who is purchasing from the pet store + * @example {"firstName":"firstName","lastName":"lastName","password":"password","userStatus":6,"phone":"phone","id":0,"email":"email","username":"username"} + */ +export interface User { + /** @format int64 */ + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + /** + * User Status + * @format int32 + */ + userStatus?: number; +} + +/** + * Pet Tag + * A tag for a pet + * @example {"name":"name","id":1} + */ +export interface Tag { + /** @format int64 */ + id?: number; + name?: string; +} + +export enum PetNames { + FluffyHero = "Fluffy Hero", + PiggyPo = "Piggy Po", + SwaggerTypescriptApi = "Swagger Typescript Api", +} + +export type PetIds = 10 | 20 | 30 | 40; + +/** + * a Pet + * A pet for sale in the pet store + * @example {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"} + */ +export interface Pet { + /** @format int64 */ + id?: number; + /** A category for a pet */ + category?: Category; + /** @example doggie */ + name: string; + photoUrls: string[]; + tags?: Tag[]; + /** pet status in the store */ + status?: "available" | "pending" | "sold"; +} + +/** + * An uploaded response + * Describes the result of uploading an image resource + * @example {"code":0,"type":"type","message":"message"} + */ +export interface ApiResponse { + /** @format int32 */ + code?: number; + type?: string; + message?: string; +} + +/** + * some description + */ +export interface Amount { + /** + * some description + * + * @format double + * @min 0.01 + * @max 1000000000000000 + */ + value: number; + /** + * some description + * + */ + currency: Currency; +} + +/** + * some description + * @pattern ^[A-Z]{3,3}$ + */ +export type Currency = string; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/v2"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/v2 + * @externalDocs http://swagger.io + * @contact + * + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + */ +export class Api extends HttpClient { + pet = { + /** + * No description + * + * @tags pet + * @name AddPet + * @summary Add a new pet to the store + * @request POST:api/v1/pet + * @secure + */ + addPet: (body: Pet, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet`, + method: "POST", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePet + * @summary Update an existing pet + * @request PUT:api/v1/pet + * @secure + */ + updatePet: (body: Pet, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet`, + method: "PUT", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * @description Multiple status values can be provided with comma separated strings + * + * @tags pet + * @name FindPetsByStatus + * @summary Finds Pets by status + * @request GET:api/v1/pet/findByStatus + * @secure + */ + findPetsByStatus: ( + query: { + /** Status values that need to be considered for filter */ + status: ("available" | "pending" | "sold")[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/findByStatus`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @tags pet + * @name FindPetsByTags + * @summary Finds Pets by tags + * @request GET:api/v1/pet/findByTags + * @deprecated + * @secure + */ + findPetsByTags: ( + query: { + /** Tags to filter by */ + tags: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/findByTags`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Returns a single pet + * + * @tags pet + * @name GetPetById + * @summary Find pet by ID + * @request GET:api/v1/pet/{petId} + * @secure + */ + getPetById: (petId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePetWithForm + * @summary Updates a pet in the store with form data + * @request POST:api/v1/pet/{petId} + * @secure + */ + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name DeletePet + * @summary Deletes a pet + * @request DELETE:api/v1/pet/{petId} + * @secure + */ + deletePet: (petId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "DELETE", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UploadFile + * @summary uploads an image + * @request POST:api/v1/pet/{petId}/uploadImage + * @secure + */ + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/${petId}/uploadImage`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + format: "json", + ...params, + }), + }; + store = { + /** + * @description Returns a map of status codes to quantities + * + * @tags store + * @name GetInventory + * @summary Returns pet inventories by status + * @request GET:api/v1/store/inventory + * @secure + */ + getInventory: (params: RequestParams = {}) => + this.request, any>({ + path: `api/v1/store/inventory`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags store + * @name PlaceOrder + * @summary Place an order for a pet + * @request POST:api/v1/store/order + */ + placeOrder: (body: Order, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @tags store + * @name GetOrderById + * @summary Find purchase order by ID + * @request GET:api/v1/store/order/{orderId} + */ + getOrderById: (orderId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order/${orderId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @tags store + * @name DeleteOrder + * @summary Delete purchase order by ID + * @request DELETE:api/v1/store/order/{orderId} + */ + deleteOrder: (orderId: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order/${orderId}`, + method: "DELETE", + ...params, + }), + }; + user = { + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name CreateUser + * @summary Create user + * @request POST:api/v1/user + */ + createUser: (body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/user`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithArrayInput + * @summary Creates list of users with given input array + * @request POST:api/v1/user/createWithArray + */ + createUsersWithArrayInput: (body: User[], params: RequestParams = {}) => + this.request({ + path: `api/v1/user/createWithArray`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithListInput + * @summary Creates list of users with given input array + * @request POST:api/v1/user/createWithList + */ + createUsersWithListInput: (body: User[], params: RequestParams = {}) => + this.request({ + path: `api/v1/user/createWithList`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LoginUser + * @summary Logs user into the system + * @request GET:api/v1/user/login + */ + loginUser: ( + query: { + /** The user name for login */ + username: string; + /** The password for login in clear text */ + password: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/user/login`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags user + * @name LogoutUser + * @summary Logs out current logged in user session + * @request GET:api/v1/user/logout + */ + logoutUser: (params: RequestParams = {}) => + this.request({ + path: `api/v1/user/logout`, + method: "GET", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:api/v1/user/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:api/v1/user/{username} + */ + updateUser: (username: string, body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:api/v1/user/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "DELETE", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName2 + * @summary Get user by user name + * @request GET:api/v1/{username} + * @originalName getUserByName + * @duplicate + */ + getUserByName2: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser2 + * @summary Updated user + * @request PUT:api/v1/{username} + * @originalName updateUser + * @duplicate + */ + updateUser2: (username: string, body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser2 + * @summary Delete user + * @request DELETE:api/v1/{username} + * @originalName deleteUser + * @duplicate + */ + deleteUser2: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "DELETE", + ...params, + }), + }; +} diff --git a/tests/spec/moduleNameFirstTag/test.js b/tests/spec/moduleNameFirstTag/test.js index cbbd2e4e..f12d693a 100644 --- a/tests/spec/moduleNameFirstTag/test.js +++ b/tests/spec/moduleNameFirstTag/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { moduleNameFirstTag: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/moduleNameIndex/expected.ts b/tests/spec/moduleNameIndex/expected.ts new file mode 100644 index 00000000..cdee6ae9 --- /dev/null +++ b/tests/spec/moduleNameIndex/expected.ts @@ -0,0 +1,796 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Pet Order + * An order for a pets from the pet store + * @example {"petId":6,"quantity":1,"id":0,"shipDate":"2000-01-23T04:56:07.000+00:00","complete":false,"status":"placed"} + */ +export interface Order { + /** @format int64 */ + id?: number; + /** @format int64 */ + petId?: number; + /** @format int32 */ + quantity?: number; + /** @format date-time */ + shipDate?: string; + /** Order Status */ + status?: "placed" | "approved" | "delivered"; + complete?: boolean; +} + +/** + * Pet category + * A category for a pet + * @example {"name":"name","id":6} + */ +export interface Category { + /** @format int64 */ + id?: number; + name?: string; +} + +/** + * a User + * A User who is purchasing from the pet store + * @example {"firstName":"firstName","lastName":"lastName","password":"password","userStatus":6,"phone":"phone","id":0,"email":"email","username":"username"} + */ +export interface User { + /** @format int64 */ + id?: number; + username?: string; + firstName?: string; + lastName?: string; + email?: string; + password?: string; + phone?: string; + /** + * User Status + * @format int32 + */ + userStatus?: number; +} + +/** + * Pet Tag + * A tag for a pet + * @example {"name":"name","id":1} + */ +export interface Tag { + /** @format int64 */ + id?: number; + name?: string; +} + +export enum PetNames { + FluffyHero = "Fluffy Hero", + PiggyPo = "Piggy Po", + SwaggerTypescriptApi = "Swagger Typescript Api", +} + +export type PetIds = 10 | 20 | 30 | 40; + +/** + * a Pet + * A pet for sale in the pet store + * @example {"photoUrls":["photoUrls","photoUrls"],"name":"doggie","id":0,"category":{"name":"name","id":6},"tags":[{"name":"name","id":1},{"name":"name","id":1}],"status":"available"} + */ +export interface Pet { + /** @format int64 */ + id?: number; + /** A category for a pet */ + category?: Category; + /** @example doggie */ + name: string; + photoUrls: string[]; + tags?: Tag[]; + /** pet status in the store */ + status?: "available" | "pending" | "sold"; +} + +/** + * An uploaded response + * Describes the result of uploading an image resource + * @example {"code":0,"type":"type","message":"message"} + */ +export interface ApiResponse { + /** @format int32 */ + code?: number; + type?: string; + message?: string; +} + +/** + * some description + */ +export interface Amount { + /** + * some description + * + * @format double + * @min 0.01 + * @max 1000000000000000 + */ + value: number; + /** + * some description + * + */ + currency: Currency; +} + +/** + * some description + * @pattern ^[A-Z]{3,3}$ + */ +export type Currency = string; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/v2"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license Apache-2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/v2 + * @externalDocs http://swagger.io + * @contact + * + * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + */ +export class Api extends HttpClient { + pet = { + /** + * No description + * + * @tags pet + * @name AddPet + * @summary Add a new pet to the store + * @request POST:api/v1/pet + * @secure + */ + addPet: (body: Pet, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet`, + method: "POST", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePet + * @summary Update an existing pet + * @request PUT:api/v1/pet + * @secure + */ + updatePet: (body: Pet, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet`, + method: "PUT", + body: body, + secure: true, + type: ContentType.Json, + ...params, + }), + + /** + * @description Multiple status values can be provided with comma separated strings + * + * @tags pet + * @name FindPetsByStatus + * @summary Finds Pets by status + * @request GET:api/v1/pet/findByStatus + * @secure + */ + findPetsByStatus: ( + query: { + /** Status values that need to be considered for filter */ + status: ("available" | "pending" | "sold")[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/findByStatus`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * + * @tags pet + * @name FindPetsByTags + * @summary Finds Pets by tags + * @request GET:api/v1/pet/findByTags + * @deprecated + * @secure + */ + findPetsByTags: ( + query: { + /** Tags to filter by */ + tags: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/findByTags`, + method: "GET", + query: query, + secure: true, + format: "json", + ...params, + }), + + /** + * @description Returns a single pet + * + * @tags pet + * @name GetPetById + * @summary Find pet by ID + * @request GET:api/v1/pet/{petId} + * @secure + */ + getPetById: (petId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UpdatePetWithForm + * @summary Updates a pet in the store with form data + * @request POST:api/v1/pet/{petId} + * @secure + */ + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name DeletePet + * @summary Deletes a pet + * @request DELETE:api/v1/pet/{petId} + * @secure + */ + deletePet: (petId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/pet/${petId}`, + method: "DELETE", + secure: true, + ...params, + }), + + /** + * No description + * + * @tags pet + * @name UploadFile + * @summary uploads an image + * @request POST:api/v1/pet/{petId}/uploadImage + * @secure + */ + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/pet/${petId}/uploadImage`, + method: "POST", + body: data, + secure: true, + type: ContentType.FormData, + format: "json", + ...params, + }), + }; + store = { + /** + * @description Returns a map of status codes to quantities + * + * @tags store + * @name GetInventory + * @summary Returns pet inventories by status + * @request GET:api/v1/store/inventory + * @secure + */ + getInventory: (params: RequestParams = {}) => + this.request, any>({ + path: `api/v1/store/inventory`, + method: "GET", + secure: true, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags store + * @name PlaceOrder + * @summary Place an order for a pet + * @request POST:api/v1/store/order + */ + placeOrder: (body: Order, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions + * + * @tags store + * @name GetOrderById + * @summary Find purchase order by ID + * @request GET:api/v1/store/order/{orderId} + */ + getOrderById: (orderId: number, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order/${orderId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors + * + * @tags store + * @name DeleteOrder + * @summary Delete purchase order by ID + * @request DELETE:api/v1/store/order/{orderId} + */ + deleteOrder: (orderId: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/store/order/${orderId}`, + method: "DELETE", + ...params, + }), + }; + user = { + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name CreateUser + * @summary Create user + * @request POST:api/v1/user + */ + createUser: (body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/user`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithArrayInput + * @summary Creates list of users with given input array + * @request POST:api/v1/user/createWithArray + */ + createUsersWithArrayInput: (body: User[], params: RequestParams = {}) => + this.request({ + path: `api/v1/user/createWithArray`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name CreateUsersWithListInput + * @summary Creates list of users with given input array + * @request POST:api/v1/user/createWithList + */ + createUsersWithListInput: (body: User[], params: RequestParams = {}) => + this.request({ + path: `api/v1/user/createWithList`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * No description + * + * @tags user + * @name LoginUser + * @summary Logs user into the system + * @request GET:api/v1/user/login + */ + loginUser: ( + query: { + /** The user name for login */ + username: string; + /** The password for login in clear text */ + password: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `api/v1/user/login`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * No description + * + * @tags user + * @name LogoutUser + * @summary Logs out current logged in user session + * @request GET:api/v1/user/logout + */ + logoutUser: (params: RequestParams = {}) => + this.request({ + path: `api/v1/user/logout`, + method: "GET", + ...params, + }), + + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:api/v1/user/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:api/v1/user/{username} + */ + updateUser: (username: string, body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:api/v1/user/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/user/${username}`, + method: "DELETE", + ...params, + }), + }; + username = { + /** + * No description + * + * @tags user + * @name GetUserByName + * @summary Get user by user name + * @request GET:api/v1/{username} + */ + getUserByName: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name UpdateUser + * @summary Updated user + * @request PUT:api/v1/{username} + */ + updateUser: (username: string, body: User, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "PUT", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description This can only be done by the logged in user. + * + * @tags user + * @name DeleteUser + * @summary Delete user + * @request DELETE:api/v1/{username} + */ + deleteUser: (username: string, params: RequestParams = {}) => + this.request({ + path: `api/v1/${username}`, + method: "DELETE", + ...params, + }), + }; +} diff --git a/tests/spec/moduleNameIndex/test.js b/tests/spec/moduleNameIndex/test.js index bb5fdaf4..3a1d8bc2 100644 --- a/tests/spec/moduleNameIndex/test.js +++ b/tests/spec/moduleNameIndex/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { moduleNameIndex: 2, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/noClient/expected.ts b/tests/spec/noClient/expected.ts new file mode 100644 index 00000000..5b454b3a --- /dev/null +++ b/tests/spec/noClient/expected.ts @@ -0,0 +1,1906 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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[]; diff --git a/tests/spec/noClient/test.js b/tests/spec/noClient/test.js index 23a0b7a9..44f56d21 100644 --- a/tests/spec/noClient/test.js +++ b/tests/spec/noClient/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/object-types/test.js b/tests/spec/object-types/test.js index 0797750f..f2d7e2a9 100644 --- a/tests/spec/object-types/test.js +++ b/tests/spec/object-types/test.js @@ -1,9 +1,8 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); -const fs = require("fs"); -const gitDiff = require("git-diff"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -18,20 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); - - const output = fs.readFileSync(resolve(__dirname, `./${apiFileName}`)).toString("utf8"); - const expected = fs.readFileSync(resolve(__dirname, `./expected.ts`)).toString("utf8"); - - const diff = gitDiff(output, expected, { - color: true, - flags: "--diff-algorithm=default", - }); - - if (diff && diff.length) { - console.error("\n" + diff); - throw new Error("expected another output"); - } - - return void 0; + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/partialBaseTemplate/expected.ts b/tests/spec/partialBaseTemplate/expected.ts new file mode 100644 index 00000000..9338e036 --- /dev/null +++ b/tests/spec/partialBaseTemplate/expected.ts @@ -0,0 +1,258 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** PARTIAL TEMPLATES */ +/** + * * FOO BAR + */ +export interface Pet { + /** @format int64 */ + id: number; + name: string; + tag?: string; + multiple?: string | number; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/api"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Swagger Petstore + * @version 1.0.0 + * @license MIT + * @termsOfService http://swagger.io/terms/ + * @baseUrl http://petstore.swagger.io/api + * @contact Swagger API Team + * + * A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + */ +export class Api extends HttpClient { + pets = { + /** + * @description Returns all pets from the system that the user has access to + * + * @name PetsList + * @request GET:/pets + */ + petsList: (params: RequestParams = {}) => + this.request({ + path: `/pets`, + method: "GET", + format: "json", + ...params, + }), + }; +} diff --git a/tests/spec/partialBaseTemplate/test.js b/tests/spec/partialBaseTemplate/test.js index d734cbf3..9721cb18 100644 --- a/tests/spec/partialBaseTemplate/test.js +++ b/tests/spec/partialBaseTemplate/test.js @@ -3,6 +3,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -21,5 +22,6 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { } validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/partialDefaultTemplate/expected.ts b/tests/spec/partialDefaultTemplate/expected.ts new file mode 100644 index 00000000..c9c76784 --- /dev/null +++ b/tests/spec/partialDefaultTemplate/expected.ts @@ -0,0 +1,251 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface Pet { + /** @format int64 */ + id: number; + name: string; + tag?: string; + multiple?: string | number; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://petstore.swagger.io/api"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** PARTIAL TEMPLATES */ +/** + * @title Swagger Petstore + * @version 1.0.0 + * @baseUrl http://petstore.swagger.io/api + * A sample API that uses a petstore as an example to demonstrate features in the swagger-2.0 specification + */ +export class Api extends HttpClient { + pets = { + /** + * @description Returns all pets from the system that the user has access to + * + * @name PetsList + * @request GET:/pets + */ + petsList: (params: RequestParams = {}) => + this.request({ + path: `/pets`, + method: "GET", + format: "json", + ...params, + }), + }; +} diff --git a/tests/spec/partialDefaultTemplate/test.js b/tests/spec/partialDefaultTemplate/test.js index 34fd8c1e..4f5b99c6 100644 --- a/tests/spec/partialDefaultTemplate/test.js +++ b/tests/spec/partialDefaultTemplate/test.js @@ -3,6 +3,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -21,5 +22,6 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { } validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/patch/expected.ts b/tests/spec/patch/expected.ts new file mode 100644 index 00000000..4d303ba1 --- /dev/null +++ b/tests/spec/patch/expected.ts @@ -0,0 +1,6184 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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[]; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title GitHub + * @version v3 + * @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 { + emojis = { + /** + * @description Lists all the emojis available to use on GitHub. + * + * @name EmojisList + * @request GET:/emojis + */ + emojisList: (params: RequestParams = {}) => + this.request({ + path: `/emojis`, + method: "GET", + format: "json", + ...params, + }), + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + */ + eventsList: (params: RequestParams = {}) => + this.request({ + path: `/events`, + method: "GET", + format: "json", + ...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({ + path: `/feeds`, + method: "GET", + format: "json", + ...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({ + path: `/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + */ + gistsCreate: (body: PostGist, params: RequestParams = {}) => + this.request({ + path: `/gists`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/gists/public`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/gists/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gists/${id}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/forks`, + method: "POST", + ...params, + }), + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + starDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gists/${id}/star`, + method: "GET", + ...params, + }), + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/gitignore/templates`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.request({ + path: `/gitignore/templates/${language}`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, + method: "GET", + format: "json", + ...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. */ + 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({ + path: `/legacy/repos/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/legacy/user/email/${email}`, + method: "GET", + format: "json", + ...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. */ + 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({ + path: `/legacy/user/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + */ + markdownCreate: (body: Markdown, params: RequestParams = {}) => + this.request({ + path: `/markdown`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + */ + postMarkdown: (params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/meta`, + method: "GET", + format: "json", + ...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({ + path: `/networks/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...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({ + path: `/notifications`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/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({ + path: `/notifications/threads/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/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({ + path: `/notifications/threads/${id}/subscription`, + method: "GET", + format: "json", + ...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({ + path: `/notifications/threads/${id}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/events`, + method: "GET", + format: "json", + ...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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/orgs/${org}/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/orgs/${org}/members`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/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({ + path: `/orgs/${org}/public_members`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/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({ + path: `/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?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/orgs/${org}/repos`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/orgs/${org}/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/teams`, + method: "GET", + format: "json", + ...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({ + path: `/orgs/${org}/teams`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/rate_limit`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/assignees`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/branches`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/branches/${branch}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/collaborators`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/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({ + path: `/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({ + path: `/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({ + path: `/repos/${owner}/${repo}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${ref}/status`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/compare/${baseId}...${headId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "DELETE", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/contributors`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "POST", + body: body, + type: ContentType.Json, + ...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({ + path: `/repos/${owner}/${repo}/downloads`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/forks`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/blobs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/blobs/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/commits`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/tags`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/tags/${shaCode}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/trees`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/repos/${owner}/${repo}/issues`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/comments`, + method: "GET", + query: query, + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/events`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/events/${eventId}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "PATCH", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "POST", + body: body, + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/events`, + method: "GET", + format: "json", + ...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({ + path: `/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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "GET", + format: "json", + ...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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsUpdate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + + /** + * @description Remove a label from an issue. + * + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + */ + issuesLabelsDelete2: (owner: string, repo: string, number: number, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get list of keys. + * + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + */ + keysDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a key. + * + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + */ + keysCreate: (owner: string, repo: string, body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a key. + * + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + */ + keysDelete: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a key + * + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + */ + keysDetail2: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all labels for this repository. + * + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + */ + labelsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a label. + * + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + */ + labelsCreate: (owner: string, repo: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a label. + * + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + */ + labelsDelete: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single label. + * + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + */ + labelsDetail2: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a label. + * + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + */ + labelsPartialUpdate: (owner: string, repo: string, name: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + */ + languagesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/languages`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Perform a merge. + * + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + */ + mergesCreate: (owner: string, repo: string, body: MergesBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/merges`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List milestones for a repository. + * + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + */ + milestonesDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a milestone. + * + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + */ + milestonesCreate: (owner: string, repo: string, body: MilestoneUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a milestone. + * + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single milestone. + * + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + */ + milestonesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a milestone. + * + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: MilestoneUpdate, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get labels for every issue in a milestone. + * + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + */ + milestonesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List your notifications in a repository List all notifications for the current user. + * + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + */ + notificationsDetail: ( + owner: string, + repo: string, + 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({ + path: `/repos/${owner}/${repo}/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + */ + notificationsUpdate: (owner: string, repo: string, body: NotificationMarkRead, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description List pull requests. + * + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + */ + pullsDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a pull request. + * + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + */ + pullsCreate: (owner: string, repo: string, body: PullsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + */ + pullsCommentsDetail: ( + 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({ + path: `/repos/${owner}/${repo}/pulls/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get a single pull request. + * + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + */ + pullsDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a pull request. + * + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + */ + pullsPartialUpdate: (owner: string, repo: string, number: number, body: PullUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a pull request. + * + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + */ + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: PullsCommentPost, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List commits on a pull request. + * + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + */ + pullsCommitsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/commits`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List pull requests files. + * + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + */ + pullsFilesDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/files`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get if a pull request has been merged. + * + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "GET", + ...params, + }), + + /** + * @description Merge a pull request (Merge Button's) + * + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeUpdate: (owner: string, repo: string, number: number, body: MergePullBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get the README. This method returns the preferred README for a repository. + * + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + */ + readmeDetail: ( + owner: string, + repo: string, + query?: { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/readme`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + */ + releasesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a release Users with push access to the repository can create a release. + * + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + */ + releasesCreate: (owner: string, repo: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a release asset + * + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release asset + * + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDetail: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: AssetPatch, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can delete a release. + * + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + */ + releasesDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release + * + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + */ + releasesDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can edit a release + * + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + */ + releasesPartialUpdate: (owner: string, repo: string, id: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List assets for a release + * + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + */ + releasesAssetsDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}/assets`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. + * + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + */ + stargazersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stargazers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + */ + statsCodeFrequencyDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/code_frequency`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + */ + statsCommitActivityDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/commit_activity`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get contributors list with additions, deletions, and commit counts. + * + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + */ + statsContributorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/contributors`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + */ + statsParticipationDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/participation`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + */ + statsPunchCardDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/punch_card`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Statuses for a specific Ref. + * + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Status. + * + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesCreate: (owner: string, repo: string, ref: string, body: HeadBranch, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List watchers. + * + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + */ + subscribersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscribers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a Repository Subscription. + * + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + */ + subscriptionDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a Repository Subscription. + * + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + */ + subscriptionDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Set a Repository Subscription + * + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + */ + subscriptionUpdate: (owner: string, repo: string, body: SubscriptionBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get list of tags. + * + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + */ + tagsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/tags`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of teams + * + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + */ + teamsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. New implementation. + * + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + */ + watchersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/watchers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: ( + owner: string, + repo: string, + archiveFormat: "tarball" | "zipball", + path: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/${archiveFormat}/${path}`, + method: "GET", + ...params, + }), + }; + repositories = { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * + * @name RepositoriesList + * @request GET:/repositories + */ + repositoriesList: ( + 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + search = { + /** + * @description Search code. + * + * @name CodeList + * @request GET:/search/code + */ + codeList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/code`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * + * @name IssuesList + * @request GET:/search/issues + */ + issuesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search repositories. + * + * @name RepositoriesList + * @request GET:/search/repositories + */ + repositoriesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search users. + * + * @name UsersList + * @request GET:/search/users + */ + usersList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + teams = { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + */ + teamsDelete: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team. + * + * @name TeamsDetail + * @request GET:/teams/{teamId} + */ + teamsDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + */ + teamsPartialUpdate: (teamId: number, body: EditTeam, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * + * @name MembersDetail + * @request GET:/teams/{teamId}/members + */ + membersDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + */ + membersDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + */ + membersDetail2: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "GET", + ...params, + }), + + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + */ + membersUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + */ + membershipsDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + */ + membershipsDetail: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + */ + membershipsUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "PUT", + format: "json", + ...params, + }), + + /** + * @description List team repos + * + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + */ + reposDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + */ + reposDelete: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if a team manages a repository + * + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + */ + reposUpdate: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "PUT", + ...params, + }), + }; + user = { + /** + * @description Get the authenticated user. + * + * @name UserList + * @request GET:/user + */ + userList: (params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update the authenticated user. + * + * @name UserPartialUpdate + * @request PATCH:/user + */ + userPartialUpdate: (body: UserUpdate, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * + * @name EmailsDelete + * @request DELETE:/user/emails + */ + emailsDelete: (body: UserEmails, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "DELETE", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * + * @name EmailsList + * @request GET:/user/emails + */ + emailsList: (params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "GET", + ...params, + }), + + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * + * @name EmailsCreate + * @request POST:/user/emails + */ + emailsCreate: (body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "POST", + body: body, + ...params, + }), + + /** + * @description List the authenticated user's followers + * + * @name FollowersList + * @request GET:/user/followers + */ + followersList: (params: RequestParams = {}) => + this.request({ + path: `/user/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List who the authenticated user is following. + * + * @name FollowingList + * @request GET:/user/following + */ + followingList: (params: RequestParams = {}) => + this.request({ + path: `/user/following`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingDelete + * @request DELETE:/user/following/{username} + */ + followingDelete: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are following a user. + * + * @name FollowingDetail + * @request GET:/user/following/{username} + */ + followingDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "GET", + ...params, + }), + + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingUpdate + * @request PUT:/user/following/{username} + */ + followingUpdate: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * + * @name IssuesList + * @request GET:/user/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/user/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * + * @name KeysList + * @request GET:/user/keys + */ + keysList: (params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a public key. + * + * @name KeysCreate + * @request POST:/user/keys + */ + keysCreate: (body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + */ + keysDelete: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single public key. + * + * @name KeysDetail + * @request GET:/user/keys/{keyId} + */ + keysDetail: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List public and private organizations for the authenticated user. + * + * @name OrgsList + * @request GET:/user/orgs + */ + orgsList: (params: RequestParams = {}) => + this.request({ + path: `/user/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * + * @name ReposList + * @request GET:/user/repos + */ + reposList: ( + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/user/repos + */ + reposCreate: (body: PostRepo, params: RequestParams = {}) => + this.request({ + path: `/user/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by the authenticated user. + * + * @name StarredList + * @request GET:/user/starred + */ + starredList: ( + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Unstar a repository + * + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + */ + starredDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are starring a repository. + * + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + */ + starredDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Star a repository. + * + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + */ + starredUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List repositories being watched by the authenticated user. + * + * @name SubscriptionsList + * @request GET:/user/subscriptions + */ + subscriptionsList: (params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Stop watching a repository + * + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are watching a repository. + * + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Watch a repository. + * + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * + * @name TeamsList + * @request GET:/user/teams + */ + teamsList: (params: RequestParams = {}) => + this.request({ + path: `/user/teams`, + method: "GET", + format: "json", + ...params, + }), + }; + users = { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * + * @name UsersList + * @request GET:/users + */ + usersList: ( + query?: { + /** The integer ID of the last user that you've seen. */ + since?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get a single user. + * + * @name UsersDetail + * @request GET:/users/{username} + */ + usersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * + * @name EventsDetail + * @request GET:/users/{username}/events + */ + eventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events`, + method: "GET", + ...params, + }), + + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + */ + eventsOrgsDetail: (username: string, org: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events/orgs/${org}`, + method: "GET", + ...params, + }), + + /** + * @description List a user's followers + * + * @name FollowersDetail + * @request GET:/users/{username}/followers + */ + followersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Check if one user follows another. + * + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + */ + followingDetail: (username: string, targetUser: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/following/${targetUser}`, + method: "GET", + ...params, + }), + + /** + * @description List a users gists. + * + * @name GistsDetail + * @request GET:/users/{username}/gists + */ + gistsDetail: ( + username: 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * + * @name KeysDetail + * @request GET:/users/{username}/keys + */ + keysDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all public organizations for a user. + * + * @name OrgsDetail + * @request GET:/users/{username}/orgs + */ + orgsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description These are events that you'll only see public events. + * + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + */ + receivedEventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events`, + method: "GET", + ...params, + }), + + /** + * @description List public events that a user has received + * + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + */ + receivedEventsPublicDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events/public`, + method: "GET", + ...params, + }), + + /** + * @description List public repositories for the specified user. + * + * @name ReposDetail + * @request GET:/users/{username}/repos + */ + reposDetail: ( + username: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by a user. + * + * @name StarredDetail + * @request GET:/users/{username}/starred + */ + starredDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/starred`, + method: "GET", + ...params, + }), + + /** + * @description List repositories being watched by a user. + * + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + */ + subscriptionsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/subscriptions`, + method: "GET", + ...params, + }), + }; +} diff --git a/tests/spec/patch/test.js b/tests/spec/patch/test.js index db24795d..2c2c4858 100644 --- a/tests/spec/patch/test.js +++ b/tests/spec/patch/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { patch: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/readonly/expected.ts b/tests/spec/readonly/expected.ts new file mode 100644 index 00000000..c0f1b4d5 --- /dev/null +++ b/tests/spec/readonly/expected.ts @@ -0,0 +1,18 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface Pet { + /** @format int64 */ + readonly id: number; + readonly name: string; + readonly tag?: string; + readonly multiple?: string | number; +} diff --git a/tests/spec/readonly/schema.json b/tests/spec/readonly/schema.json index 283278d5..25ea5647 100644 --- a/tests/spec/readonly/schema.json +++ b/tests/spec/readonly/schema.json @@ -47,13 +47,16 @@ "format": "int64" }, "name": { - "type": "string" + "type": "string", + "readOnly": true }, "tag": { - "type": "string" + "type": "string", + "readOnly": true }, "multiple": { - "type": ["string", "number"] + "type": ["string", "number"], + "readOnly": true } } } diff --git a/tests/spec/readonly/schema.ts b/tests/spec/readonly/schema.ts index a23fad81..c0f1b4d5 100644 --- a/tests/spec/readonly/schema.ts +++ b/tests/spec/readonly/schema.ts @@ -12,7 +12,7 @@ export interface Pet { /** @format int64 */ readonly id: number; - name: string; - tag?: string; - multiple?: string | number; + readonly name: string; + readonly tag?: string; + readonly multiple?: string | number; } diff --git a/tests/spec/readonly/test.js b/tests/spec/readonly/test.js index 1db17e9a..25986c73 100644 --- a/tests/spec/readonly/test.js +++ b/tests/spec/readonly/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/responses/expected.ts b/tests/spec/responses/expected.ts new file mode 100644 index 00000000..45b54e2c --- /dev/null +++ b/tests/spec/responses/expected.ts @@ -0,0 +1,723 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Authentiq ID in JWT format, self-signed. + */ +export interface AuthentiqID { + /** device token for push messages */ + devtoken?: string; + /** UUID and public signing key */ + sub: string; +} + +/** + * Claim in JWT format, self- or issuer-signed. + */ +export interface Claims { + email?: string; + phone?: string; + /** claim scope */ + scope: string; + /** UUID */ + sub: string; + type?: string; +} + +export interface Error { + detail?: string; + error: number; + title?: string; + /** unique uri for this error */ + type?: string; +} + +/** + * PushToken in JWT format, self-signed. + */ +export interface PushToken { + /** audience (URI) */ + aud: string; + exp?: number; + iat?: number; + /** issuer (URI) */ + iss: string; + nbf?: number; + /** UUID and public signing key */ + sub: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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://6-dot-authentiqio.appspot.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Authentiq + * @version 6 + * @license Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://authentiq.com/terms/ + * @baseUrl https://6-dot-authentiqio.appspot.com + * @contact Authentiq team (http://authentiq.io/support) + * + * Strong authentication, without the passwords. + */ +export class Api extends HttpClient { + key = { + /** + * @description Revoke an Authentiq ID using email & phone. If called with `email` and `phone` only, a verification code will be sent by email. Do a second call adding `code` to complete the revocation. + * + * @tags key, delete + * @name KeyRevokeNosecret + * @request DELETE:/key + * @response `200` `{ + \** pending or done *\ + status?: string, + +}` Successfully deleted + * @response `401` `Error` Authentication error `auth-error` + * @response `404` `Error` Unknown key `unknown-key` + * @response `409` `Error` Confirm with code sent `confirm-first` + * @response `default` `Error` + */ + keyRevokeNosecret: ( + query: { + /** primary email associated to Key (ID) */ + email: string; + /** primary phone number, international representation */ + phone: string; + /** verification code sent by email */ + code?: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** pending or done */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyRegister + * @request POST:/key + * @response `201` `{ + \** revoke key *\ + secret?: string, + \** registered *\ + status?: string, + +}` Successfully registered + * @response `409` `Error` Key already registered `duplicate-key` + * @response `default` `Error` + */ + keyRegister: (body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + Error + >({ + path: `/key`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Revoke an Identity (Key) with a revocation secret + * + * @tags key, delete + * @name KeyRevoke + * @request DELETE:/key/{PK} + * @response `200` `{ + \** done *\ + status?: string, + +}` Successful response + * @response `401` `Error` Key not found / wrong code `auth-error` + * @response `404` `Error` Unknown key `unknown-key` + * @response `default` `Error` + */ + keyRevoke: ( + pk: string, + query: { + /** revokation secret */ + secret: string; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "DELETE", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get public details of an Authentiq ID. + * + * @tags key, get + * @name GetKey + * @request GET:/key/{PK} + * @response `200` `{ + \** @format date-time *\ + since?: string, + status?: string, + \** base64safe encoded public signing key *\ + sub?: string, + +}` Successfully retrieved + * @response `404` `Error` Unknown key `unknown-key` + * @response `410` `Error` Key is revoked (gone). `revoked-key` + * @response `default` `Error` + */ + getKey: (pk: string, params: RequestParams = {}) => + this.request< + { + /** @format date-time */ + since?: string; + status?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD info on Authentiq ID + * + * @tags key, head + * @name HeadKey + * @request HEAD:/key/{PK} + * @response `200` `void` Key exists + * @response `404` `Error` Unknown key `unknown-key` + * @response `410` `Error` Key is revoked `revoked-key` + * @response `default` `Error` + */ + headKey: (pk: string, params: RequestParams = {}) => + this.request({ + path: `/key/${pk}`, + method: "HEAD", + ...params, + }), + + /** + * @description update properties of an Authentiq ID. (not operational in v4; use PUT for now) v5: POST issuer-signed email & phone scopes in a self-signed JWT See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyUpdate + * @request POST:/key/{PK} + * @response `200` `{ + \** confirmed *\ + status?: string, + +}` Successfully updated + * @response `404` `Error` Unknown key `unknown-key` + * @response `default` `Error` + */ + keyUpdate: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Update Authentiq ID by replacing the object. v4: `JWT(sub,email,phone)` to bind email/phone hash; v5: POST issuer-signed email & phone scopes and PUT to update registration `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, put + * @name KeyBind + * @request PUT:/key/{PK} + * @response `200` `{ + \** confirmed *\ + status?: string, + +}` Successfully updated + * @response `404` `Error` Unknown key `unknown-key` + * @response `409` `Error` Already bound to another key `duplicate-hash` + * @response `default` `Error` + */ + keyBind: (pk: string, body: AuthentiqID, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/key/${pk}`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + }; + login = { + /** + * @description push sign-in request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags login, post + * @name PushLoginRequest + * @request POST:/login + * @response `200` `{ + \** sent *\ + status?: string, + +}` Successful response + * @response `401` `Error` Unauthorized for this callback audience `aud-error` or JWT should be self-signed `auth-error` + * @response `default` `Error` + */ + pushLoginRequest: ( + query: { + /** URI App will connect to */ + callback: string; + }, + body: PushToken, + params: RequestParams = {}, + ) => + this.request< + { + /** sent */ + status?: string; + }, + Error + >({ + path: `/login`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + }; + scope = { + /** + * @description scope verification request See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, post + * @name SignRequest + * @request POST:/scope + * @response `201` `{ + \** 20-character ID *\ + job?: string, + \** waiting *\ + status?: string, + +}` Successful response + * @response `429` `Error` Too Many Requests on same address / number `rate-limit` + * @response `default` `Error` + */ + signRequest: ( + body: Claims, + query?: { + /** test only mode, using test issuer */ + test?: number; + }, + params: RequestParams = {}, + ) => + this.request< + { + /** 20-character ID */ + job?: string; + /** waiting */ + status?: string; + }, + Error + >({ + path: `/scope`, + method: "POST", + query: query, + body: body, + format: "json", + ...params, + }), + + /** + * @description delete a verification job + * + * @tags scope, delete + * @name SignDelete + * @request DELETE:/scope/{job} + * @response `200` `{ + \** done *\ + status?: string, + +}` Successfully deleted + * @response `404` `Error` Job not found `unknown-job` + * @response `default` `Error` + */ + signDelete: (job: string, params: RequestParams = {}) => + this.request< + { + /** done */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "DELETE", + format: "json", + ...params, + }), + + /** + * @description get the status / current content of a verification job + * + * @tags scope, get + * @name SignRetrieve + * @request GET:/scope/{job} + * @response `200` `{ + exp?: number, + field?: string, + \** base64safe encoded public signing key *\ + sub?: string, + +}` Successful response (JWT) + * @response `204` `void` Confirmed, waiting for signing + * @response `404` `Error` Job not found `unknown-job` + * @response `default` `Error` + */ + signRetrieve: (job: string, params: RequestParams = {}) => + this.request< + { + exp?: number; + field?: string; + /** base64safe encoded public signing key */ + sub?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description HEAD to get the status of a verification job + * + * @tags scope, head + * @name SignRetrieveHead + * @request HEAD:/scope/{job} + * @response `200` `void` Confirmed and signed + * @response `204` `void` Confirmed, waiting for signing + * @response `404` `Error` Job not found `unknown-job` + * @response `default` `Error` + */ + signRetrieveHead: (job: string, params: RequestParams = {}) => + this.request({ + path: `/scope/${job}`, + method: "HEAD", + ...params, + }), + + /** + * @description this is a scope confirmation + * + * @tags scope, post + * @name SignConfirm + * @request POST:/scope/{job} + * @response `202` `{ + \** confirmed *\ + status?: string, + +}` Successfully confirmed + * @response `401` `Error` Confirmation error `auth-error` + * @response `404` `Error` Job not found `unknown-job` + * @response `405` `Error` JWT POSTed to scope `not-supported` + * @response `default` `Error` + */ + signConfirm: (job: string, params: RequestParams = {}) => + this.request< + { + /** confirmed */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "POST", + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description authority updates a JWT with its signature See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags scope, put + * @name SignUpdate + * @request PUT:/scope/{job} + * @response `200` `{ + \** result is JWT or JSON?? *\ + jwt?: string, + \** ready *\ + status?: string, + +}` Successfully updated + * @response `404` `Error` Job not found `unknown-job` + * @response `409` `Error` Job not confirmed yet `confirm-first` + * @response `default` `Error` + */ + signUpdate: (job: string, params: RequestParams = {}) => + this.request< + { + /** result is JWT or JSON?? */ + jwt?: string; + /** ready */ + status?: string; + }, + Error + >({ + path: `/scope/${job}`, + method: "PUT", + ...params, + }), + }; +} diff --git a/tests/spec/responses/schema.ts b/tests/spec/responses/schema.ts index 46026c9b..45b54e2c 100644 --- a/tests/spec/responses/schema.ts +++ b/tests/spec/responses/schema.ts @@ -277,7 +277,7 @@ export class Api extends HttpClient extends HttpClient extends HttpClient extends HttpClient this.request< @@ -351,7 +351,7 @@ export class Api extends HttpClient extends HttpClient extends HttpClient extends HttpClient this.request< @@ -441,7 +441,7 @@ export class Api extends HttpClient extends HttpClient this.request< @@ -470,7 +470,7 @@ export class Api extends HttpClient extends HttpClient this.request< @@ -501,7 +501,7 @@ export class Api extends HttpClient extends HttpClient extends HttpClient extends HttpClient extends HttpClient extends HttpClient this.request< @@ -608,7 +608,7 @@ export class Api extends HttpClient extends HttpClient this.request< @@ -659,7 +659,7 @@ export class Api extends HttpClient extends HttpClient this.request< @@ -690,7 +690,7 @@ export class Api extends HttpClient extends HttpClient this.request< diff --git a/tests/spec/responses/test.js b/tests/spec/responses/test.js index ddd0b8ae..ff67ee80 100644 --- a/tests/spec/responses/test.js +++ b/tests/spec/responses/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,6 +16,7 @@ schemas.forEach(({ absolutePath, apiFileName }) => { }) .then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }) .catch((e) => { console.error("responses option test failed."); diff --git a/tests/spec/routeTypes/expected.ts b/tests/spec/routeTypes/expected.ts new file mode 100644 index 00000000..140905bb --- /dev/null +++ b/tests/spec/routeTypes/expected.ts @@ -0,0 +1,7144 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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[]; + +export namespace 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 + */ + export namespace SomeTestList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = { + 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; + }; + }; + }; + }; + }; + }; + }; + } +} + +export namespace PathParams { + /** + * @description Lists all the emojis available to use on GitHub. + * @name PathParamsList + * @request GET:/path-params + */ + export namespace PathParamsList { + export type RequestParams = { + /** + * ID of pet to return + * @format int64 + */ + petId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + /** Tik Token */ + "X-Auth": string; + }; + export type ResponseBody = Emojis; + } +} + +export namespace Events { + /** + * @description List public events. + * @name EventsList + * @request GET:/events + */ + export namespace EventsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Events; + } +} + +export namespace 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 + */ + export namespace FeedsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Feeds; + } +} + +export namespace Gists { + /** + * @description List the authenticated user's gists or if called anonymously, this will return all public gists. + * @name GistsList + * @request GET:/gists + */ + export namespace GistsList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + * + */ + since?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gists; + } + /** + * @description Create a gist. + * @name GistsCreate + * @request POST:/gists + */ + export namespace GistsCreate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = PostGist; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gist; + } + /** + * @description List all public gists. + * @name PublicList + * @request GET:/gists/public + */ + export namespace PublicList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + * + */ + since?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gists; + } + /** + * @description List the authenticated user's starred gists. + * @name StarredList + * @request GET:/gists/starred + */ + export namespace StarredList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * Timestamp in ISO 8601 format YYYY-MM-DDTHH:MM:SSZ. + * Only gists updated at or after this time are returned. + * + */ + since?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gists; + } + /** + * @description Delete a gist. + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + export namespace GistsDelete { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single gist. + * @name GistsDetail + * @request GET:/gists/{id} + */ + export namespace GistsDetail { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gist; + } + /** + * @description Edit a gist. + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + export namespace GistsPartialUpdate { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = PatchGist; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gist; + } + /** + * @description List comments on a gist. + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + export namespace CommentsDetail { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Comments; + } + /** + * @description Create a commen + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + export namespace CommentsCreate { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = CommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Comment; + } + /** + * @description Delete a comment. + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + export namespace CommentsDelete { + export type RequestParams = { + /** Id of gist. */ + id: number; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single comment. + * @name CommentsDetail2 + * @request GET:/gists/{id}/comments/{commentId} + * @originalName commentsDetail + * @duplicate + */ + export namespace CommentsDetail2 { + export type RequestParams = { + /** Id of gist. */ + id: number; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Comment; + } + /** + * @description Edit a comment. + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + export namespace CommentsPartialUpdate { + export type RequestParams = { + /** Id of gist. */ + id: number; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = Comment; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Comment; + } + /** + * @description Fork a gist. + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + export namespace ForksCreate { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Unstar a gist. + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + export namespace StarDelete { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if a gist is starred. + * @name StarDetail + * @request GET:/gists/{id}/star + */ + export namespace StarDetail { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Star a gist. + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + export namespace StarUpdate { + export type RequestParams = { + /** Id of gist. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } +} + +export namespace Gitignore { + /** + * @description Listing available templates. List all templates available to pass as an option when creating a repository. + * @name TemplatesList + * @request GET:/gitignore/templates + */ + export namespace TemplatesList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description Get a single template. + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + export namespace TemplatesDetail { + export type RequestParams = { + language: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = GitignoreLang; + } +} + +export namespace Issues { + /** + * @description List issues. List all issues across all the authenticated user's visible repositories. + * @name IssuesList + * @request GET:/issues + */ + export namespace IssuesList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issues; + } +} + +export namespace Legacy { + /** + * @description Find issues by state and keyword. + * @name IssuesSearchDetail + * @request GET:/legacy/issues/search/{owner}/{repository}/{state}/{keyword} + * @deprecated + */ + export namespace IssuesSearchDetail { + export type RequestParams = { + /** The search term. */ + keyword: string; + /** Indicates the state of the issues to return. Can be either open or closed. */ + state: "open" | "closed"; + owner: string; + repository: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchIssuesByKeyword; + } + /** + * @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 + */ + export namespace ReposSearchDetail { + export type RequestParams = { + /** The search term */ + keyword: string; + }; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or 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"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchRepositoriesByKeyword; + } + /** + * @description This API call is added for compatibility reasons only. + * @name UserEmailDetail + * @request GET:/legacy/user/email/{email} + * @deprecated + */ + export namespace UserEmailDetail { + export type RequestParams = { + /** The email address */ + email: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchUserByEmail; + } + /** + * @description Find users by keyword. + * @name UserSearchDetail + * @request GET:/legacy/user/search/{keyword} + * @deprecated + */ + export namespace UserSearchDetail { + export type RequestParams = { + /** The search term */ + keyword: string; + }; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or 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"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchUsersByKeyword; + } +} + +export namespace Markdown { + /** + * @description Render an arbitrary Markdown document + * @name MarkdownCreate + * @request POST:/markdown + */ + export namespace MarkdownCreate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = Markdown; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Render a Markdown document in raw mode + * @name PostMarkdown + * @request POST:/markdown/raw + */ + export namespace PostMarkdown { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } +} + +export namespace Meta { + /** + * @description This gives some information about GitHub.com, the service. + * @name MetaList + * @request GET:/meta + */ + export namespace MetaList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Meta; + } +} + +export namespace Networks { + /** + * @description List public events for a network of repositories. + * @name EventsDetail + * @request GET:/networks/{owner}/{repo}/events + */ + export namespace EventsDetail { + export type RequestParams = { + /** Name of the owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Events; + } +} + +export namespace Notifications { + /** + * @description List your notifications. List all notifications for the current user, grouped by repository. + * @name NotificationsList + * @request GET:/notifications + */ + export namespace NotificationsList { + export type RequestParams = {}; + export type RequestQuery = { + /** 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Notifications; + } + /** + * @description Mark as read. Marking a notification as "read" removes it from the default view on GitHub.com. + * @name NotificationsUpdate + * @request PUT:/notifications + */ + export namespace NotificationsUpdate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = NotificationMarkRead; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description View a single thread. + * @name ThreadsDetail + * @request GET:/notifications/threads/{id} + */ + export namespace ThreadsDetail { + export type RequestParams = { + /** Id of thread. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Notifications; + } + /** + * @description Mark a thread as read + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + export namespace ThreadsPartialUpdate { + export type RequestParams = { + /** Id of thread. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Delete a Thread Subscription. + * @name ThreadsSubscriptionDelete + * @request DELETE:/notifications/threads/{id}/subscription + */ + export namespace ThreadsSubscriptionDelete { + export type RequestParams = { + /** Id of thread. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a Thread Subscription. + * @name ThreadsSubscriptionDetail + * @request GET:/notifications/threads/{id}/subscription + */ + export namespace ThreadsSubscriptionDetail { + export type RequestParams = { + /** Id of thread. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Subscription; + } + /** + * @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 + */ + export namespace ThreadsSubscriptionUpdate { + export type RequestParams = { + /** Id of thread. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = PutSubscription; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Subscription; + } +} + +export namespace Orgs { + /** + * @description Get an Organization. + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + export namespace OrgsDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Organization; + } + /** + * @description Edit an Organization. + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + export namespace OrgsPartialUpdate { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = PatchOrg; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Organization; + } + /** + * @description List public events for an organization. + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + export namespace EventsDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Events; + } + /** + * @description List issues. List all issues for a given organization for the authenticated user. + * @name IssuesDetail + * @request GET:/orgs/{org}/issues + */ + export namespace IssuesDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issues; + } + /** + * @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 + */ + export namespace MembersDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @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} + */ + export namespace MembersDelete { + export type RequestParams = { + /** Name of organisation. */ + org: string; + /** Name of the user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @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 + */ + export namespace MembersDetail2 { + export type RequestParams = { + /** Name of organisation. */ + org: string; + /** Name of the user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @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 + */ + export namespace PublicMembersDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Conceal a user's membership. + * @name PublicMembersDelete + * @request DELETE:/orgs/{org}/public_members/{username} + */ + export namespace PublicMembersDelete { + export type RequestParams = { + /** Name of organisation. */ + org: string; + /** Name of the user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check public membership. + * @name PublicMembersDetail2 + * @request GET:/orgs/{org}/public_members/{username} + * @originalName publicMembersDetail + * @duplicate + */ + export namespace PublicMembersDetail2 { + export type RequestParams = { + /** Name of organisation. */ + org: string; + /** Name of the user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Publicize a user's membership. + * @name PublicMembersUpdate + * @request PUT:/orgs/{org}/public_members/{username} + */ + export namespace PublicMembersUpdate { + export type RequestParams = { + /** Name of organisation. */ + org: string; + /** Name of the user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List repositories for the specified org. + * @name ReposDetail + * @request GET:/orgs/{org}/repos + */ + export namespace ReposDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * @name ReposCreate + * @request POST:/orgs/{org}/repos + */ + export namespace ReposCreate { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = PostRepo; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description List teams. + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + export namespace TeamsDetail { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Teams; + } + /** + * @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 + */ + export namespace TeamsCreate { + export type RequestParams = { + /** Name of organisation. */ + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = OrgTeamsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Team; + } +} + +export namespace 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 + */ + export namespace RateLimitList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RateLimit; + } +} + +export namespace 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} + */ + export namespace ReposDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get repository. + * @name ReposDetail + * @request GET:/repos/{owner}/{repo} + */ + export namespace ReposDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repo; + } + /** + * @description Edit repository. + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + export namespace ReposPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = RepoEdit; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repo; + } + /** + * @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 + */ + export namespace AssigneesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Assignees; + } + /** + * @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 + */ + export namespace AssigneesDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Login of the assignee. */ + assignee: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get list of branches + * @name BranchesDetail + * @request GET:/repos/{owner}/{repo}/branches + */ + export namespace BranchesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Branches; + } + /** + * @description Get Branch + * @name BranchesDetail2 + * @request GET:/repos/{owner}/{repo}/branches/{branch} + * @originalName branchesDetail + * @duplicate + */ + export namespace BranchesDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Name of the branch. */ + branch: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Branch; + } + /** + * @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 + */ + export namespace CollaboratorsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Remove collaborator. + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + export namespace CollaboratorsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Login of the user. */ + user: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if user is a collaborator + * @name CollaboratorsDetail2 + * @request GET:/repos/{owner}/{repo}/collaborators/{user} + * @originalName collaboratorsDetail + * @duplicate + */ + export namespace CollaboratorsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Login of the user. */ + user: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Add collaborator. + * @name CollaboratorsUpdate + * @request PUT:/repos/{owner}/{repo}/collaborators/{user} + */ + export namespace CollaboratorsUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Login of the user. */ + user: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List commit comments for a repository. Comments are ordered by ascending ID. + * @name CommentsDetail + * @request GET:/repos/{owner}/{repo}/comments + */ + export namespace CommentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RepoComments; + } + /** + * @description Delete a commit comment + * @name CommentsDelete + * @request DELETE:/repos/{owner}/{repo}/comments/{commentId} + */ + export namespace CommentsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single commit comment. + * @name CommentsDetail2 + * @request GET:/repos/{owner}/{repo}/comments/{commentId} + * @originalName commentsDetail + * @duplicate + */ + export namespace CommentsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CommitComment; + } + /** + * @description Update a commit comment. + * @name CommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/comments/{commentId} + */ + export namespace CommentsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = CommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CommitComment; + } + /** + * @description List commits on a repository. + * @name CommitsDetail + * @request GET:/repos/{owner}/{repo}/commits + */ + export namespace CommitsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** + * 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Commits; + } + /** + * @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 + */ + export namespace CommitsStatusDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RefStatus; + } + /** + * @description Get a single commit. + * @name CommitsDetail2 + * @request GET:/repos/{owner}/{repo}/commits/{shaCode} + * @originalName commitsDetail + * @duplicate + */ + export namespace CommitsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** SHA-1 code of the commit. */ + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Commit; + } + /** + * @description List comments for a single commitList comments for a single commit. + * @name CommitsCommentsDetail + * @request GET:/repos/{owner}/{repo}/commits/{shaCode}/comments + */ + export namespace CommitsCommentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** SHA-1 code of the commit. */ + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RepoComments; + } + /** + * @description Create a commit comment. + * @name CommitsCommentsCreate + * @request POST:/repos/{owner}/{repo}/commits/{shaCode}/comments + */ + export namespace CommitsCommentsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** SHA-1 code of the commit. */ + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = CommitCommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CommitComment; + } + /** + * @description Compare two commits + * @name CompareDetail + * @request GET:/repos/{owner}/{repo}/compare/{baseId}...{headId} + */ + export namespace CompareDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + baseId: string; + headId: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CompareCommits; + } + /** + * @description Delete a file. This method deletes a file in a repository. + * @name ContentsDelete + * @request DELETE:/repos/{owner}/{repo}/contents/{path} + */ + export namespace ContentsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + path: string; + }; + export type RequestQuery = {}; + export type RequestBody = DeleteFileBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = DeleteFile; + } + /** + * @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} + */ + export namespace ContentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + path: string; + }; + export type RequestQuery = { + /** The content path. */ + path?: string; + /** The String name of the Commit/Branch/Tag. Defaults to 'master'. */ + ref?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = ContentsPath; + } + /** + * @description Create a file. + * @name ContentsUpdate + * @request PUT:/repos/{owner}/{repo}/contents/{path} + */ + export namespace ContentsUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + path: string; + }; + export type RequestQuery = {}; + export type RequestBody = CreateFileBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CreateFile; + } + /** + * @description Get list of contributors. + * @name ContributorsDetail + * @request GET:/repos/{owner}/{repo}/contributors + */ + export namespace ContributorsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** Set to 1 or true to include anonymous contributors in results. */ + anon: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Users with pull access can view deployments for a repository + * @name DeploymentsDetail + * @request GET:/repos/{owner}/{repo}/deployments + */ + export namespace DeploymentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RepoDeployments; + } + /** + * @description Users with push access can create a deployment for a given ref + * @name DeploymentsCreate + * @request POST:/repos/{owner}/{repo}/deployments + */ + export namespace DeploymentsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = Deployment; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = DeploymentResp; + } + /** + * @description Users with pull access can view deployment statuses for a deployment + * @name DeploymentsStatusesDetail + * @request GET:/repos/{owner}/{repo}/deployments/{id}/statuses + */ + export namespace DeploymentsStatusesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** The Deployment ID to list the statuses from. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = DeploymentStatuses; + } + /** + * @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 + */ + export namespace DeploymentsStatusesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** The Deployment ID to list the statuses from. */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = DeploymentStatusesCreate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Deprecated. List downloads for a repository. + * @name DownloadsDetail + * @request GET:/repos/{owner}/{repo}/downloads + * @deprecated + */ + export namespace DownloadsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Downloads; + } + /** + * @description Deprecated. Delete a download. + * @name DownloadsDelete + * @request DELETE:/repos/{owner}/{repo}/downloads/{downloadId} + * @deprecated + */ + export namespace DownloadsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of download. */ + downloadId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Deprecated. Get a single download. + * @name DownloadsDetail2 + * @request GET:/repos/{owner}/{repo}/downloads/{downloadId} + * @deprecated + * @originalName downloadsDetail + * @duplicate + */ + export namespace DownloadsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of download. */ + downloadId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Download; + } + /** + * @description Get list of repository events. + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + export namespace EventsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Events; + } + /** + * @description List forks. + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + export namespace ForksDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + sort?: "newes" | "oldes" | "watchers"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Forks; + } + /** + * @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 + */ + export namespace ForksCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = ForkBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repo; + } + /** + * @description Create a Blob. + * @name GitBlobsCreate + * @request POST:/repos/{owner}/{repo}/git/blobs + */ + export namespace GitBlobsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = Blob; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Blobs; + } + /** + * @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} + */ + export namespace GitBlobsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** SHA-1 code. */ + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Blob; + } + /** + * @description Create a Commit. + * @name GitCommitsCreate + * @request POST:/repos/{owner}/{repo}/git/commits + */ + export namespace GitCommitsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = RepoCommitBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = GitCommit; + } + /** + * @description Get a Commit. + * @name GitCommitsDetail + * @request GET:/repos/{owner}/{repo}/git/commits/{shaCode} + */ + export namespace GitCommitsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** SHA-1 code. */ + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = RepoCommit; + } + /** + * @description Get all References + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + export namespace GitRefsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Refs; + } + /** + * @description Create a Reference + * @name GitRefsCreate + * @request POST:/repos/{owner}/{repo}/git/refs + */ + export namespace GitRefsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = RefsBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = HeadBranch; + } + /** + * @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} + */ + export namespace GitRefsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a Reference + * @name GitRefsDetail2 + * @request GET:/repos/{owner}/{repo}/git/refs/{ref} + * @originalName gitRefsDetail + * @duplicate + */ + export namespace GitRefsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = HeadBranch; + } + /** + * @description Update a Reference + * @name GitRefsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/git/refs/{ref} + */ + export namespace GitRefsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = GitRefPatch; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = HeadBranch; + } + /** + * @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 + */ + export namespace GitTagsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = TagBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Tag; + } + /** + * @description Get a Tag. + * @name GitTagsDetail + * @request GET:/repos/{owner}/{repo}/git/tags/{shaCode} + */ + export namespace GitTagsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + shaCode: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Tag; + } + /** + * @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 + */ + export namespace GitTreesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = Tree; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Trees; + } + /** + * @description Get a Tree. + * @name GitTreesDetail + * @request GET:/repos/{owner}/{repo}/git/trees/{shaCode} + */ + export namespace GitTreesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Tree SHA. */ + shaCode: string; + }; + export type RequestQuery = { + /** Get a Tree Recursively. (0 or 1) */ + recursive?: number; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Tree; + } + /** + * @description Get list of hooks. + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + export namespace HooksDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Hook; + } + /** + * @description Create a hook. + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + export namespace HooksCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = HookBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Hook; + } + /** + * @description Delete a hook. + * @name HooksDelete + * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} + */ + export namespace HooksDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of hook. */ + hookId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get single hook. + * @name HooksDetail2 + * @request GET:/repos/{owner}/{repo}/hooks/{hookId} + * @originalName hooksDetail + * @duplicate + */ + export namespace HooksDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of hook. */ + hookId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Hook; + } + /** + * @description Edit a hook. + * @name HooksPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/hooks/{hookId} + */ + export namespace HooksPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of hook. */ + hookId: number; + }; + export type RequestQuery = {}; + export type RequestBody = HookBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Hook; + } + /** + * @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 + */ + export namespace HooksTestsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of hook. */ + hookId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List issues for a repository. + * @name IssuesDetail + * @request GET:/repos/{owner}/{repo}/issues + */ + export namespace IssuesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issues; + } + /** + * @description Create an issue. Any user with pull access to a repository can create an issue. + * @name IssuesCreate + * @request POST:/repos/{owner}/{repo}/issues + */ + export namespace IssuesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = Issue; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issue; + } + /** + * @description List comments in a repository. + * @name IssuesCommentsDetail + * @request GET:/repos/{owner}/{repo}/issues/comments + */ + export namespace IssuesCommentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComments; + } + /** + * @description Delete a comment. + * @name IssuesCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/comments/{commentId} + */ + export namespace IssuesCommentsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** ID of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single comment. + * @name IssuesCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/issues/comments/{commentId} + * @originalName issuesCommentsDetail + * @duplicate + */ + export namespace IssuesCommentsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** ID of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComment; + } + /** + * @description Edit a comment. + * @name IssuesCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/issues/comments/{commentId} + */ + export namespace IssuesCommentsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** ID of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = CommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComment; + } + /** + * @description List issue events for a repository. + * @name IssuesEventsDetail + * @request GET:/repos/{owner}/{repo}/issues/events + */ + export namespace IssuesEventsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssueEvents; + } + /** + * @description Get a single event. + * @name IssuesEventsDetail2 + * @request GET:/repos/{owner}/{repo}/issues/events/{eventId} + * @originalName issuesEventsDetail + * @duplicate + */ + export namespace IssuesEventsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of the event. */ + eventId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssueEvent; + } + /** + * @description Get a single issue + * @name IssuesDetail2 + * @request GET:/repos/{owner}/{repo}/issues/{number} + * @originalName issuesDetail + * @duplicate + */ + export namespace IssuesDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issue; + } + /** + * @description Edit an issue. Issue owners and users with push access can edit an issue. + * @name IssuesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/issues/{number} + */ + export namespace IssuesPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = Issue; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issue; + } + /** + * @description List comments on an issue. + * @name IssuesCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/comments + * @originalName issuesCommentsDetail + * @duplicate + */ + export namespace IssuesCommentsDetail3 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComments; + } + /** + * @description Create a comment. + * @name IssuesCommentsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/comments + */ + export namespace IssuesCommentsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = CommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComment; + } + /** + * @description List events for an issue. + * @name IssuesEventsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/events + * @originalName issuesEventsDetail + * @duplicate + */ + export namespace IssuesEventsDetail3 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssueEvents; + } + /** + * @description Remove all labels from an issue. + * @name IssuesLabelsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels + */ + export namespace IssuesLabelsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List labels on an issue. + * @name IssuesLabelsDetail + * @request GET:/repos/{owner}/{repo}/issues/{number}/labels + */ + export namespace IssuesLabelsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Labels; + } + /** + * @description Add labels to an issue. + * @name IssuesLabelsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/labels + */ + export namespace IssuesLabelsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = EmailsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Label; + } + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + */ + export namespace IssuesLabelsUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = EmailsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Label; + } + /** + * @description Remove a label from an issue. + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + */ + export namespace IssuesLabelsDelete2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of issue. */ + number: number; + /** Name of the label. */ + name: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get list of keys. + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + */ + export namespace KeysDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Keys; + } + /** + * @description Create a key. + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + */ + export namespace KeysCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = UserKeysPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = UserKeysKeyId; + } + /** + * @description Delete a key. + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + */ + export namespace KeysDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of key. */ + keyId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a key + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + */ + export namespace KeysDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of key. */ + keyId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = UserKeysKeyId; + } + /** + * @description List all labels for this repository. + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + */ + export namespace LabelsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Labels; + } + /** + * @description Create a label. + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + */ + export namespace LabelsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = EmailsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Label; + } + /** + * @description Delete a label. + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + */ + export namespace LabelsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Name of the label. */ + name: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single label. + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + */ + export namespace LabelsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Name of the label. */ + name: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Label; + } + /** + * @description Update a label. + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + */ + export namespace LabelsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Name of the label. */ + name: string; + }; + export type RequestQuery = {}; + export type RequestBody = EmailsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Label; + } + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + */ + export namespace LanguagesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Languages; + } + /** + * @description Perform a merge. + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + */ + export namespace MergesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = MergesBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = MergesSuccessful; + } + /** + * @description List milestones for a repository. + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + */ + export namespace MilestonesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Milestone; + } + /** + * @description Create a milestone. + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + */ + export namespace MilestonesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = MilestoneUpdate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Milestone; + } + /** + * @description Delete a milestone. + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + */ + export namespace MilestonesDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of milestone. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single milestone. + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + */ + export namespace MilestonesDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of milestone. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Milestone; + } + /** + * @description Update a milestone. + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + */ + export namespace MilestonesPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of milestone. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = MilestoneUpdate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Milestone; + } + /** + * @description Get labels for every issue in a milestone. + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + */ + export namespace MilestonesLabelsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Number of milestone. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Labels; + } + /** + * @description List your notifications in a repository List all notifications for the current user. + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + */ + export namespace NotificationsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Notifications; + } + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + */ + export namespace NotificationsUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = NotificationMarkRead; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List pull requests. + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + */ + export namespace PullsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Pulls; + } + /** + * @description Create a pull request. + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + */ + export namespace PullsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = PullsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Pulls; + } + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + */ + export namespace PullsCommentsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = IssuesComments; + } + /** + * @description Delete a comment. + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + export namespace PullsCommentsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single comment. + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + */ + export namespace PullsCommentsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = PullsComment; + } + /** + * @description Edit a comment. + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + export namespace PullsCommentsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of comment. */ + commentId: number; + }; + export type RequestQuery = {}; + export type RequestBody = CommentBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = PullsComment; + } + /** + * @description Get a single pull request. + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + */ + export namespace PullsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = PullRequest; + } + /** + * @description Update a pull request. + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + */ + export namespace PullsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = PullUpdate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repo; + } + /** + * @description List comments on a pull request. + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + */ + export namespace PullsCommentsDetail3 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = PullsComment; + } + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + */ + export namespace PullsCommentsCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = PullsCommentPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = PullsComment; + } + /** + * @description List commits on a pull request. + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + */ + export namespace PullsCommitsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Commits; + } + /** + * @description List pull requests files. + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + */ + export namespace PullsFilesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Pulls; + } + /** + * @description Get if a pull request has been merged. + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + */ + export namespace PullsMergeDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Merge a pull request (Merge Button's) + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + */ + export namespace PullsMergeUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** Id of pull. */ + number: number; + }; + export type RequestQuery = {}; + export type RequestBody = MergePullBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Merge; + } + /** + * @description Get the README. This method returns the preferred README for a repository. + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + */ + export namespace ReadmeDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = ContentsPath; + } + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + */ + export namespace ReleasesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Releases; + } + /** + * @description Create a release Users with push access to the repository can create a release. + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + */ + export namespace ReleasesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = ReleaseCreate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Release; + } + /** + * @description Delete a release asset + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + */ + export namespace ReleasesAssetsDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single release asset + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + */ + export namespace ReleasesAssetsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Asset; + } + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + */ + export namespace ReleasesAssetsPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = AssetPatch; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Asset; + } + /** + * @description Users with push access to the repository can delete a release. + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + */ + export namespace ReleasesDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single release + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + */ + export namespace ReleasesDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Release; + } + /** + * @description Users with push access to the repository can edit a release + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + */ + export namespace ReleasesPartialUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = ReleaseCreate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Release; + } + /** + * @description List assets for a release + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + */ + export namespace ReleasesAssetsDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + id: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Assets; + } + /** + * @description List Stargazers. + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + */ + export namespace StargazersDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + */ + export namespace StatsCodeFrequencyDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CodeFrequencyStats; + } + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + */ + export namespace StatsCommitActivityDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CommitActivityStats; + } + /** + * @description Get contributors list with additions, deletions, and commit counts. + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + */ + export namespace StatsContributorsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = ContributorsStats; + } + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + */ + export namespace StatsParticipationDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = ParticipationStats; + } + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + */ + export namespace StatsPunchCardDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = CodeFrequencyStats; + } + /** + * @description List Statuses for a specific Ref. + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + */ + export namespace StatusesDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** + * Ref to list the statuses from. It can be a SHA, a branch name, or a tag name. + * + */ + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Ref; + } + /** + * @description Create a Status. + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + */ + export namespace StatusesCreate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + /** + * Ref to list the statuses from. It can be a SHA, a branch name, or a tag name. + * + */ + ref: string; + }; + export type RequestQuery = {}; + export type RequestBody = HeadBranch; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Ref; + } + /** + * @description List watchers. + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + */ + export namespace SubscribersDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Delete a Repository Subscription. + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + */ + export namespace SubscriptionDelete { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a Repository Subscription. + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + */ + export namespace SubscriptionDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Subscription; + } + /** + * @description Set a Repository Subscription + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + */ + export namespace SubscriptionUpdate { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = SubscriptionBody; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Subscription; + } + /** + * @description Get list of tags. + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + */ + export namespace TagsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Tags; + } + /** + * @description Get list of teams + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + */ + export namespace TeamsDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Teams; + } + /** + * @description List Stargazers. New implementation. + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + */ + export namespace WatchersDetail { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + */ + export namespace ReposDetail2 { + export type RequestParams = { + /** Name of repository owner. */ + owner: string; + /** Name of repository. */ + repo: string; + archiveFormat: "tarball" | "zipball"; + /** Valid Git reference, defaults to 'master'. */ + path: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } +} + +export namespace Repositories { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * @name RepositoriesList + * @request GET:/repositories + */ + export namespace RepositoriesList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } +} + +export namespace Search { + /** + * @description Search code. + * @name CodeList + * @request GET:/search/code + */ + export namespace CodeList { + export type RequestParams = {}; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchCode; + } + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * @name IssuesList + * @request GET:/search/issues + */ + export namespace IssuesList { + export type RequestParams = {}; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchIssues; + } + /** + * @description Search repositories. + * @name RepositoriesList + * @request GET:/search/repositories + */ + export namespace RepositoriesList { + export type RequestParams = {}; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchRepositories; + } + /** + * @description Search users. + * @name UsersList + * @request GET:/search/users + */ + export namespace UsersList { + export type RequestParams = {}; + export type RequestQuery = { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = SearchUsers; + } +} + +export namespace Teams { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + */ + export namespace TeamsDelete { + export type RequestParams = { + /** Id of team. */ + teamId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get team. + * @name TeamsDetail + * @request GET:/teams/{teamId} + */ + export namespace TeamsDetail { + export type RequestParams = { + /** Id of team. */ + teamId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Team; + } + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + */ + export namespace TeamsPartialUpdate { + export type RequestParams = { + /** Id of team. */ + teamId: number; + }; + export type RequestQuery = {}; + export type RequestBody = EditTeam; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Team; + } + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * @name MembersDetail + * @request GET:/teams/{teamId}/members + */ + export namespace MembersDetail { + export type RequestParams = { + /** Id of team. */ + teamId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + */ + export namespace MembersDelete { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + */ + export namespace MembersDetail2 { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + */ + export namespace MembersUpdate { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + */ + export namespace MembershipsDelete { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + */ + export namespace MembershipsDetail { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = TeamMembership; + } + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + */ + export namespace MembershipsUpdate { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a member. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = TeamMembership; + } + /** + * @description List team repos + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + */ + export namespace ReposDetail { + export type RequestParams = { + /** Id of team. */ + teamId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = TeamRepos; + } + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + */ + export namespace ReposDelete { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a repository owner. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if a team manages a repository + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + */ + export namespace ReposDetail2 { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a repository owner. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + */ + export namespace ReposUpdate { + export type RequestParams = { + /** Id of team. */ + teamId: number; + /** Name of a organization. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } +} + +export namespace User { + /** + * @description Get the authenticated user. + * @name UserList + * @request GET:/user + */ + export namespace UserList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = User; + } + /** + * @description Update the authenticated user. + * @name UserPartialUpdate + * @request PATCH:/user + */ + export namespace UserPartialUpdate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = UserUpdate; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = User; + } + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * @name EmailsDelete + * @request DELETE:/user/emails + */ + export namespace EmailsDelete { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = UserEmails; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * @name EmailsList + * @request GET:/user/emails + */ + export namespace EmailsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = UserEmails; + } + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * @name EmailsCreate + * @request POST:/user/emails + */ + export namespace EmailsCreate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = EmailsPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description List the authenticated user's followers + * @name FollowersList + * @request GET:/user/followers + */ + export namespace FollowersList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description List who the authenticated user is following. + * @name FollowingList + * @request GET:/user/following + */ + export namespace FollowingList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * @name FollowingDelete + * @request DELETE:/user/following/{username} + */ + export namespace FollowingDelete { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if you are following a user. + * @name FollowingDetail + * @request GET:/user/following/{username} + */ + export namespace FollowingDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * @name FollowingUpdate + * @request PUT:/user/following/{username} + */ + export namespace FollowingUpdate { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * @name IssuesList + * @request GET:/user/issues + */ + export namespace IssuesList { + export type RequestParams = {}; + export type RequestQuery = { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Issues; + } + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * @name KeysList + * @request GET:/user/keys + */ + export namespace KeysList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description Create a public key. + * @name KeysCreate + * @request POST:/user/keys + */ + export namespace KeysCreate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = UserKeysPost; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = UserKeysKeyId; + } + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + */ + export namespace KeysDelete { + export type RequestParams = { + /** ID of key. */ + keyId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Get a single public key. + * @name KeysDetail + * @request GET:/user/keys/{keyId} + */ + export namespace KeysDetail { + export type RequestParams = { + /** ID of key. */ + keyId: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = UserKeysKeyId; + } + /** + * @description List public and private organizations for the authenticated user. + * @name OrgsList + * @request GET:/user/orgs + */ + export namespace OrgsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * @name ReposList + * @request GET:/user/repos + */ + export namespace ReposList { + export type RequestParams = {}; + export type RequestQuery = { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * @name ReposCreate + * @request POST:/user/repos + */ + export namespace ReposCreate { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = PostRepo; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description List repositories being starred by the authenticated user. + * @name StarredList + * @request GET:/user/starred + */ + export namespace StarredList { + export type RequestParams = {}; + export type RequestQuery = { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description Unstar a repository + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + */ + export namespace StarredDelete { + export type RequestParams = { + /** Name of a repository owner. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if you are starring a repository. + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + */ + export namespace StarredDetail { + export type RequestParams = { + /** Name of a repository owner. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Star a repository. + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + */ + export namespace StarredUpdate { + export type RequestParams = { + /** Name of a repository owner. */ + owner: string; + /** Name of a repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List repositories being watched by the authenticated user. + * @name SubscriptionsList + * @request GET:/user/subscriptions + */ + export namespace SubscriptionsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description Stop watching a repository + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + export namespace SubscriptionsDelete { + export type RequestParams = { + /** Name of the owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Check if you are watching a repository. + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + export namespace SubscriptionsDetail { + export type RequestParams = { + /** Name of the owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description Watch a repository. + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + export namespace SubscriptionsUpdate { + export type RequestParams = { + /** Name of the owner. */ + owner: string; + /** Name of repository. */ + repo: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * @name TeamsList + * @request GET:/user/teams + */ + export namespace TeamsList { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = TeamsList; + } +} + +export namespace Users { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * @name UsersList + * @request GET:/users + */ + export namespace UsersList { + export type RequestParams = {}; + export type RequestQuery = { + /** The integer ID of the last user that you've seen. */ + since?: number; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Get a single user. + * @name UsersDetail + * @request GET:/users/{username} + */ + export namespace UsersDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = User; + } + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * @name EventsDetail + * @request GET:/users/{username}/events + */ + export namespace EventsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + */ + export namespace EventsOrgsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + org: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description List a user's followers + * @name FollowersDetail + * @request GET:/users/{username}/followers + */ + export namespace FollowersDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Users; + } + /** + * @description Check if one user follows another. + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + */ + export namespace FollowingDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + /** Name of user. */ + targetUser: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = void; + } + /** + * @description List a users gists. + * @name GistsDetail + * @request GET:/users/{username}/gists + */ + export namespace GistsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = { + /** + * 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; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gists; + } + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * @name KeysDetail + * @request GET:/users/{username}/keys + */ + export namespace KeysDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description List all public organizations for a user. + * @name OrgsDetail + * @request GET:/users/{username}/orgs + */ + export namespace OrgsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Gitignore; + } + /** + * @description These are events that you'll only see public events. + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + */ + export namespace ReceivedEventsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description List public events that a user has received + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + */ + export namespace ReceivedEventsPublicDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description List public repositories for the specified user. + * @name ReposDetail + * @request GET:/users/{username}/repos + */ + export namespace ReposDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = Repos; + } + /** + * @description List repositories being starred by a user. + * @name StarredDetail + * @request GET:/users/{username}/starred + */ + export namespace StarredDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } + /** + * @description List repositories being watched by a user. + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + */ + export namespace SubscriptionsDetail { + export type RequestParams = { + /** Name of user. */ + username: string; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = { + /** Is used to set specified media type. */ + Accept?: string; + }; + export type ResponseBody = any; + } +} diff --git a/tests/spec/routeTypes/test.js b/tests/spec/routeTypes/test.js index 0287b7db..58aae114 100644 --- a/tests/spec/routeTypes/test.js +++ b/tests/spec/routeTypes/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/singleHttpClient/expected.ts b/tests/spec/singleHttpClient/expected.ts new file mode 100644 index 00000000..5ed79f80 --- /dev/null +++ b/tests/spec/singleHttpClient/expected.ts @@ -0,0 +1,262 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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://6-dot-authentiqio.appspot.com"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title Authentiq + * @version 6 + * @license Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0.html) + * @termsOfService http://authentiq.com/terms/ + * @baseUrl https://6-dot-authentiqio.appspot.com + * @contact Authentiq team (http://authentiq.io/support) + * + * Strong authentication, without the passwords. + */ +export class Api { + http: HttpClient; + + constructor(http: HttpClient) { + this.http = http; + } + + key = { + /** + * @description Register a new ID `JWT(sub, devtoken)` v5: `JWT(sub, pk, devtoken, ...)` See: https://github.com/skion/authentiq/wiki/JWT-Examples + * + * @tags key, post + * @name KeyRegister + * @request POST:/key + */ + keyRegister: (body: any, params: RequestParams = {}) => + this.http.request< + { + /** revoke key */ + secret?: string; + /** registered */ + status?: string; + }, + any + >({ + path: `/key`, + method: "POST", + body: body, + format: "json", + ...params, + }), + }; +} diff --git a/tests/spec/singleHttpClient/test.js b/tests/spec/singleHttpClient/test.js index ed806e55..e50f0e05 100644 --- a/tests/spec/singleHttpClient/test.js +++ b/tests/spec/singleHttpClient/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { singleHttpClient: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/specProperty/expected.ts b/tests/spec/specProperty/expected.ts new file mode 100644 index 00000000..f5ad7f5d --- /dev/null +++ b/tests/spec/specProperty/expected.ts @@ -0,0 +1,119 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type Pet = NewPet & { + /** @format int64 */ + id: number; +}; + +export interface NewPet { + name: string; + tag?: string; +} + +export interface Error { + /** @format int32 */ + code: number; + message: string; +} + +/** + * Page«TemplateResponseDto» + */ +export interface PageTemplateResponseDto { + content?: any[]; + empty?: boolean; + first?: boolean; + last?: boolean; + /** @format int32 */ + number?: number; + /** @format int32 */ + numberOfElements?: number; + pageable?: any; + /** @format int32 */ + size?: number; + sort?: any; + /** @format int64 */ + totalElements?: number; + /** @format int32 */ + totalPages?: number; +} + +export namespace Pets { + /** + * @description Returns all pets from the system that the user has access to Nam sed condimentum est. Maecenas tempor sagittis sapien, nec rhoncus sem sagittis sit amet. Aenean at gravida augue, ac iaculis sem. Curabitur odio lorem, ornare eget elementum nec, cursus id lectus. Duis mi turpis, pulvinar ac eros ac, tincidunt varius justo. In hac habitasse platea dictumst. Integer at adipiscing ante, a sagittis ligula. Aenean pharetra tempor ante molestie imperdiet. Vivamus id aliquam diam. Cras quis velit non tortor eleifend sagittis. Praesent at enim pharetra urna volutpat venenatis eget eget mauris. In eleifend fermentum facilisis. Praesent enim enim, gravida ac sodales sed, placerat id erat. Suspendisse lacus dolor, consectetur non augue vel, vehicula interdum libero. Morbi euismod sagittis libero sed lacinia. Sed tempus felis lobortis leo pulvinar rutrum. Nam mattis velit nisl, eu condimentum ligula luctus nec. Phasellus semper velit eget aliquet faucibus. In a mattis elit. Phasellus vel urna viverra, condimentum lorem id, rhoncus nibh. Ut pellentesque posuere elementum. Sed a varius odio. Morbi rhoncus ligula libero, vel eleifend nunc tristique vitae. Fusce et sem dui. Aenean nec scelerisque tortor. Fusce malesuada accumsan magna vel tempus. Quisque mollis felis eu dolor tristique, sit amet auctor felis gravida. Sed libero lorem, molestie sed nisl in, accumsan tempor nisi. Fusce sollicitudin massa ut lacinia mattis. Sed vel eleifend lorem. Pellentesque vitae felis pretium, pulvinar elit eu, euismod sapien. + * @name FindPets + * @request GET:/pets + */ + export namespace FindPets { + export type RequestParams = {}; + export type RequestQuery = { + /** tags to filter by */ + tags?: string[]; + /** + * maximum number of results to return + * @format int32 + */ + limit?: number; + }; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Pet[]; + } + /** + * @description Creates a new pet in the store. Duplicates are allowed + * @name AddPet + * @request POST:/pets + */ + export namespace AddPet { + export type RequestParams = {}; + export type RequestQuery = {}; + export type RequestBody = NewPet; + export type RequestHeaders = {}; + export type ResponseBody = Pet; + } + /** + * @description Returns a user based on a single ID, if the user does not have access to the pet + * @name FindPetById + * @request GET:/pets/{id} + */ + export namespace FindPetById { + export type RequestParams = { + /** + * ID of pet to fetch + * @format int64 + */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = Pet; + } + /** + * @description deletes a single pet based on the ID supplied + * @name DeletePet + * @request DELETE:/pets/{id} + */ + export namespace DeletePet { + export type RequestParams = { + /** + * ID of pet to delete + * @format int64 + */ + id: number; + }; + export type RequestQuery = {}; + export type RequestBody = never; + export type RequestHeaders = {}; + export type ResponseBody = void; + } +} diff --git a/tests/spec/specProperty/test.js b/tests/spec/specProperty/test.js index ea14bd85..f514018a 100644 --- a/tests/spec/specProperty/test.js +++ b/tests/spec/specProperty/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -16,5 +17,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateClient: false, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/templates/expected.ts b/tests/spec/templates/expected.ts new file mode 100644 index 00000000..ac7617fd --- /dev/null +++ b/tests/spec/templates/expected.ts @@ -0,0 +1,6679 @@ +/* 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 { + color?: string; + name?: string; + url?: string; +} + +export type Labels = { + 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[]; + +/* CUSTOM TEMPLATE */ + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/* HTTP CLIENT TEMPLATE */ + +/** + * @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 { + emojis = { + /** + * @description Lists all the emojis available to use on GitHub. + * + * @name EmojisList + * @request GET:/emojis + */ + emojisList: (params: RequestParams = {}) => + this.request({ + path: `/emojis`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + */ + eventsList: (params: RequestParams = {}) => + this.request({ + path: `/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/feeds`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + */ + gistsCreate: (body: PostGist, params: RequestParams = {}) => + this.request({ + path: `/gists`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/gists/public`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/gists/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + */ + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + */ + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/gists/${id}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + */ + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/forks`, + method: "POST", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + */ + starDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/star`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if a gist is starred. + * + * @name StarDetail + * @request GET:/gists/{id}/star + */ + starDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/star`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/star`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/gitignore/templates`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.request({ + path: `/gitignore/templates/${language}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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. */ + 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({ + path: `/legacy/repos/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/legacy/user/email/${email}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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. */ + 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({ + path: `/legacy/user/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + */ + markdownCreate: (body: Markdown, params: RequestParams = {}) => + this.request({ + path: `/markdown`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + */ + postMarkdown: (params: RequestParams = {}) => + this.request({ + path: `/markdown/raw`, + method: "POST", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + meta = { + /** + * @description This gives some information about GitHub.com, the service. + * + * @name MetaList + * @request GET:/meta + */ + metaList: (params: RequestParams = {}) => + this.request({ + path: `/meta`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/networks/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description View a single thread. + * + * @name ThreadsDetail + * @request GET:/notifications/threads/{id} + */ + threadsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}`, + method: "PATCH", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a Thread Subscription. + * + * @name ThreadsSubscriptionDelete + * @request DELETE:/notifications/threads/{id}/subscription + */ + threadsSubscriptionDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}/subscription`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a Thread Subscription. + * + * @name ThreadsSubscriptionDetail + * @request GET:/notifications/threads/{id}/subscription + */ + threadsSubscriptionDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/notifications/threads/${id}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + */ + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/orgs/${org}/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/members`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/members/${username}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/members/${username}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/public_members`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Conceal a user's membership. + * + * @name PublicMembersDelete + * @request DELETE:/orgs/{org}/public_members/{username} + */ + publicMembersDelete: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members/${username}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/public_members/${username}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Publicize a user's membership. + * + * @name PublicMembersUpdate + * @request PUT:/orgs/{org}/public_members/{username} + */ + publicMembersUpdate: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members/${username}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories for the specified org. + * + * @name ReposDetail + * @request GET:/orgs/{org}/repos + */ + reposDetail: ( + org: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/orgs/${org}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/orgs/${org}/teams`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/rate_limit`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + 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({ + path: `/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get repository. + * + * @name ReposDetail + * @request GET:/repos/{owner}/{repo} + */ + reposDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + */ + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/assignees`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/assignees/${assignee}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of branches + * + * @name BranchesDetail + * @request GET:/repos/{owner}/{repo}/branches + */ + branchesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/branches`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/branches/${branch}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/collaborators`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/collaborators/${user}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/collaborators/${user}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Add collaborator. + * + * @name CollaboratorsUpdate + * @request PUT:/repos/{owner}/{repo}/collaborators/{user} + */ + collaboratorsUpdate: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/collaborators/${user}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/commits`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/commits/${ref}/status`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/compare/${baseId}...${headId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "DELETE", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/contributors`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/deployments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/downloads`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/forks`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a Blob. + * + * @name GitBlobsCreate + * @request POST:/repos/{owner}/{repo}/git/blobs + */ + gitBlobsCreate: (owner: string, repo: string, body: Blob, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/blobs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/blobs/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a Commit. + * + * @name GitCommitsCreate + * @request POST:/repos/{owner}/{repo}/git/commits + */ + gitCommitsCreate: (owner: string, repo: string, body: RepoCommitBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/commits`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a Reference + * + * @name GitRefsCreate + * @request POST:/repos/{owner}/{repo}/git/refs + */ + gitRefsCreate: (owner: string, repo: string, body: RefsBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/tags`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/tags/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/trees`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + */ + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a hook. + * + * @name HooksDelete + * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} + */ + hooksDelete: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/hooks/${hookId}/tests`, + method: "POST", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/repos/${owner}/${repo}/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/events/${eventId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/events`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @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({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + */ + issuesLabelsUpdate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Remove a label from an issue. + * + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + */ + issuesLabelsDelete2: (owner: string, repo: string, number: number, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of keys. + * + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + */ + keysDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a key. + * + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + */ + keysCreate: (owner: string, repo: string, body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a key. + * + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + */ + keysDelete: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a key + * + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + */ + keysDetail2: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List all labels for this repository. + * + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + */ + labelsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a label. + * + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + */ + labelsCreate: (owner: string, repo: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a label. + * + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + */ + labelsDelete: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single label. + * + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + */ + labelsDetail2: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Update a label. + * + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + */ + labelsPartialUpdate: (owner: string, repo: string, name: string, body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + */ + languagesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/languages`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Perform a merge. + * + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + */ + mergesCreate: (owner: string, repo: string, body: MergesBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/merges`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List milestones for a repository. + * + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + */ + milestonesDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a milestone. + * + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + */ + milestonesCreate: (owner: string, repo: string, body: MilestoneUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a milestone. + * + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single milestone. + * + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + */ + milestonesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Update a milestone. + * + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + */ + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: MilestoneUpdate, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get labels for every issue in a milestone. + * + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + */ + milestonesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List your notifications in a repository List all notifications for the current user. + * + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + */ + notificationsDetail: ( + owner: string, + repo: string, + 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({ + path: `/repos/${owner}/${repo}/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + */ + notificationsUpdate: (owner: string, repo: string, body: NotificationMarkRead, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List pull requests. + * + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + */ + pullsDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a pull request. + * + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + */ + pullsCreate: (owner: string, repo: string, body: PullsPost, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + */ + pullsCommentsDetail: ( + 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({ + path: `/repos/${owner}/${repo}/pulls/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a comment. + * + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single comment. + * + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit a comment. + * + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + */ + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single pull request. + * + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + */ + pullsDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Update a pull request. + * + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + */ + pullsPartialUpdate: (owner: string, repo: string, number: number, body: PullUpdate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List comments on a pull request. + * + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + */ + pullsCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + */ + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: PullsCommentPost, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List commits on a pull request. + * + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + */ + pullsCommitsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/commits`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List pull requests files. + * + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + */ + pullsFilesDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/files`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get if a pull request has been merged. + * + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Merge a pull request (Merge Button's) + * + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + */ + pullsMergeUpdate: (owner: string, repo: string, number: number, body: MergePullBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get the README. This method returns the preferred README for a repository. + * + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + */ + readmeDetail: ( + owner: string, + repo: string, + query?: { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/readme`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + */ + releasesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a release Users with push access to the repository can create a release. + * + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + */ + releasesCreate: (owner: string, repo: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a release asset + * + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single release asset + * + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsDetail: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + */ + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: AssetPatch, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Users with push access to the repository can delete a release. + * + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + */ + releasesDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single release + * + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + */ + releasesDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Users with push access to the repository can edit a release + * + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + */ + releasesPartialUpdate: (owner: string, repo: string, id: string, body: ReleaseCreate, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List assets for a release + * + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + */ + releasesAssetsDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}/assets`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List Stargazers. + * + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + */ + stargazersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stargazers`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + */ + statsCodeFrequencyDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/code_frequency`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + */ + statsCommitActivityDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/commit_activity`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get contributors list with additions, deletions, and commit counts. + * + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + */ + statsContributorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/contributors`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + */ + statsParticipationDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/participation`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + */ + statsPunchCardDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/punch_card`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List Statuses for a specific Ref. + * + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a Status. + * + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + */ + statusesCreate: (owner: string, repo: string, ref: string, body: HeadBranch, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List watchers. + * + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + */ + subscribersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscribers`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a Repository Subscription. + * + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + */ + subscriptionDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a Repository Subscription. + * + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + */ + subscriptionDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Set a Repository Subscription + * + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + */ + subscriptionUpdate: (owner: string, repo: string, body: SubscriptionBody, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of tags. + * + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + */ + tagsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/tags`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get list of teams + * + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + */ + teamsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List Stargazers. New implementation. + * + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + */ + watchersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/watchers`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: ( + owner: string, + repo: string, + archiveFormat: "tarball" | "zipball", + path: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/${archiveFormat}/${path}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + repositories = { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * + * @name RepositoriesList + * @request GET:/repositories + */ + repositoriesList: ( + 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + search = { + /** + * @description Search code. + * + * @name CodeList + * @request GET:/search/code + */ + codeList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/code`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * + * @name IssuesList + * @request GET:/search/issues + */ + issuesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Search repositories. + * + * @name RepositoriesList + * @request GET:/search/repositories + */ + repositoriesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Search users. + * + * @name UsersList + * @request GET:/search/users + */ + usersList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + teams = { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + */ + teamsDelete: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get team. + * + * @name TeamsDetail + * @request GET:/teams/{teamId} + */ + teamsDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + */ + teamsPartialUpdate: (teamId: number, body: EditTeam, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * + * @name MembersDetail + * @request GET:/teams/{teamId}/members + */ + membersDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + */ + membersDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + */ + membersDetail2: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + */ + membersUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + */ + membershipsDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + */ + membershipsDetail: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + */ + membershipsUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "PUT", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List team repos + * + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + */ + reposDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + */ + reposDelete: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if a team manages a repository + * + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + */ + reposDetail2: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + */ + reposUpdate: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + user = { + /** + * @description Get the authenticated user. + * + * @name UserList + * @request GET:/user + */ + userList: (params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Update the authenticated user. + * + * @name UserPartialUpdate + * @request PATCH:/user + */ + userPartialUpdate: (body: UserUpdate, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * + * @name EmailsDelete + * @request DELETE:/user/emails + */ + emailsDelete: (body: UserEmails, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "DELETE", + body: body, + type: ContentType.Json, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * + * @name EmailsList + * @request GET:/user/emails + */ + emailsList: (params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * + * @name EmailsCreate + * @request POST:/user/emails + */ + emailsCreate: (body: EmailsPost, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "POST", + body: body, + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List the authenticated user's followers + * + * @name FollowersList + * @request GET:/user/followers + */ + followersList: (params: RequestParams = {}) => + this.request({ + path: `/user/followers`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List who the authenticated user is following. + * + * @name FollowingList + * @request GET:/user/following + */ + followingList: (params: RequestParams = {}) => + this.request({ + path: `/user/following`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingDelete + * @request DELETE:/user/following/{username} + */ + followingDelete: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if you are following a user. + * + * @name FollowingDetail + * @request GET:/user/following/{username} + */ + followingDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingUpdate + * @request PUT:/user/following/{username} + */ + followingUpdate: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * + * @name IssuesList + * @request GET:/user/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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/user/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * + * @name KeysList + * @request GET:/user/keys + */ + keysList: (params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a public key. + * + * @name KeysCreate + * @request POST:/user/keys + */ + keysCreate: (body: UserKeysPost, params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + */ + keysDelete: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single public key. + * + * @name KeysDetail + * @request GET:/user/keys/{keyId} + */ + keysDetail: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List public and private organizations for the authenticated user. + * + * @name OrgsList + * @request GET:/user/orgs + */ + orgsList: (params: RequestParams = {}) => + this.request({ + path: `/user/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * + * @name ReposList + * @request GET:/user/repos + */ + reposList: ( + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/user/repos + */ + reposCreate: (body: PostRepo, params: RequestParams = {}) => + this.request({ + path: `/user/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories being starred by the authenticated user. + * + * @name StarredList + * @request GET:/user/starred + */ + starredList: ( + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Unstar a repository + * + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + */ + starredDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if you are starring a repository. + * + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + */ + starredDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Star a repository. + * + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + */ + starredUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories being watched by the authenticated user. + * + * @name SubscriptionsList + * @request GET:/user/subscriptions + */ + subscriptionsList: (params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Stop watching a repository + * + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if you are watching a repository. + * + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Watch a repository. + * + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + */ + subscriptionsUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * + * @name TeamsList + * @request GET:/user/teams + */ + teamsList: (params: RequestParams = {}) => + this.request({ + path: `/user/teams`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; + users = { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * + * @name UsersList + * @request GET:/users + */ + usersList: ( + query?: { + /** The integer ID of the last user that you've seen. */ + since?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Get a single user. + * + * @name UsersDetail + * @request GET:/users/{username} + */ + usersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * + * @name EventsDetail + * @request GET:/users/{username}/events + */ + eventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + */ + eventsOrgsDetail: (username: string, org: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events/orgs/${org}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List a user's followers + * + * @name FollowersDetail + * @request GET:/users/{username}/followers + */ + followersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/followers`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description Check if one user follows another. + * + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + */ + followingDetail: (username: string, targetUser: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/following/${targetUser}`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List a users gists. + * + * @name GistsDetail + * @request GET:/users/{username}/gists + */ + gistsDetail: ( + username: 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * + * @name KeysDetail + * @request GET:/users/{username}/keys + */ + keysDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List all public organizations for a user. + * + * @name OrgsDetail + * @request GET:/users/{username}/orgs + */ + orgsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description These are events that you'll only see public events. + * + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + */ + receivedEventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List public events that a user has received + * + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + */ + receivedEventsPublicDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events/public`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List public repositories for the specified user. + * + * @name ReposDetail + * @request GET:/users/{username}/repos + */ + reposDetail: ( + username: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories being starred by a user. + * + * @name StarredDetail + * @request GET:/users/{username}/starred + */ + starredDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/starred`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + + /** + * @description List repositories being watched by a user. + * + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + */ + subscriptionsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/subscriptions`, + method: "GET", + ...params, + }), + + /* CUSTOM TEMPLATE */ + }; +} + +/* CUSTOM TEMPLATE */ diff --git a/tests/spec/templates/test.js b/tests/spec/templates/test.js index a13fb91d..ff4ab6a6 100644 --- a/tests/spec/templates/test.js +++ b/tests/spec/templates/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,14 +16,8 @@ schemas.forEach(({ absolutePath, apiFileName, Exception }) => { // because this script was called from package.json folder templates: "./tests/spec/templates/spec_templates", }) - .then((output) => { - if (!output.files[0]) throw new Exception("Failed. no output file") - if (!output.files[0].content) throw new Exception("Failed. no output file content") - - const matches = output.files[0].content.match(/\/\* CUSTOM TEMPLATE \*\//g) - - if (!matches || matches.length < 4) throw Exception("Failed. too few comment matches") - + .then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/typeSuffixPrefix/expected.ts b/tests/spec/typeSuffixPrefix/expected.ts new file mode 100644 index 00000000..706112be --- /dev/null +++ b/tests/spec/typeSuffixPrefix/expected.ts @@ -0,0 +1,6950 @@ +/* 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 SwaggerTypeActorGeneratedDataContract { + 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 SwaggerTypeAssetGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; + url?: string; +} + +export interface SwaggerTypeAssetPatchGeneratedDataContract { + label?: string; + name: string; +} + +export type SwaggerTypeAssetsGeneratedDataContract = SwaggerTypeAssetGeneratedDataContract[]; + +export type SwaggerTypeAssigneesGeneratedDataContract = SwaggerTypeUserGeneratedDataContract[]; + +export interface SwaggerTypeBlobGeneratedDataContract { + content?: string; + encoding?: "utf-8" | "base64"; + sha?: string; + size?: number; +} + +export interface SwaggerTypeBlobsGeneratedDataContract { + sha?: string; +} + +export interface SwaggerTypeBranchGeneratedDataContract { + _links?: { + html?: string; + self?: string; + }; + commit?: { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; + }; + name?: string; +} + +export type SwaggerTypeBranchesGeneratedDataContract = { + commit?: { + sha?: string; + url?: string; + }; + name?: string; +}[]; + +export type SwaggerTypeCodeFrequencyStatsGeneratedDataContract = number[]; + +export interface SwaggerTypeCommentGeneratedDataContract { + body?: string; +} + +export interface SwaggerTypeCommentBodyGeneratedDataContract { + body: string; +} + +export type SwaggerTypeCommentsGeneratedDataContract = { + body?: string; + /** ISO 8601. */ + created_at?: string; + id?: number; + url?: string; + /** A GitHub user */ + user?: SwaggerTypeUserGeneratedDataContract; +}[]; + +export interface SwaggerTypeCommitGeneratedDataContract { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + 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 SwaggerTypeCommitActivityStatsGeneratedDataContract = { + days?: number[]; + total?: number; + week?: number; +}[]; + +export interface SwaggerTypeCommitCommentGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; +} + +export interface SwaggerTypeCommitCommentBodyGeneratedDataContract { + 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 SwaggerTypeCommitsGeneratedDataContract = { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; +}[]; + +export interface SwaggerTypeCompareCommitsGeneratedDataContract { + ahead_by?: number; + base_commit?: { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; + }; + behind_by?: number; + commits?: { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + 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 SwaggerTypeContentsPathGeneratedDataContract { + _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 SwaggerTypeContributorsStatsGeneratedDataContract = { + 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 SwaggerTypeCreateFileGeneratedDataContract { + 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 SwaggerTypeCreateFileBodyGeneratedDataContract { + committer?: { + email?: string; + name?: string; + }; + content?: string; + message?: string; +} + +export interface SwaggerTypeDeleteFileGeneratedDataContract { + 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 SwaggerTypeDeleteFileBodyGeneratedDataContract { + committer?: { + email?: string; + name?: string; + }; + message?: string; + sha?: string; +} + +export interface SwaggerTypeDeploymentGeneratedDataContract { + description?: string; + payload?: { + deploy_user?: string; + environment?: string; + room_id?: number; + }; + ref?: string; +} + +export interface SwaggerTypeDeploymentRespGeneratedDataContract { + created_at?: string; + /** A GitHub user */ + creator?: SwaggerTypeUserGeneratedDataContract; + description?: string; + id?: number; + payload?: string; + sha?: string; + statuses_url?: string; + updated_at?: string; + url?: string; +} + +export type SwaggerTypeDeploymentStatusesGeneratedDataContract = { + created_at?: string; + /** A GitHub user */ + creator?: SwaggerTypeUserGeneratedDataContract; + description?: string; + id?: number; + payload?: string; + state?: string; + target_url?: string; + updated_at?: string; + url?: string; +}[]; + +export interface SwaggerTypeDeploymentStatusesCreateGeneratedDataContract { + description?: string; + state?: string; + target_url?: string; +} + +export interface SwaggerTypeDownloadGeneratedDataContract { + content_type?: string; + description?: string; + download_count?: number; + html_url?: string; + id?: number; + name?: string; + size?: number; + url?: string; +} + +export type SwaggerTypeDownloadsGeneratedDataContract = SwaggerTypeDownloadGeneratedDataContract[]; + +export interface SwaggerTypeEditTeamGeneratedDataContract { + name: string; + permission?: "pull" | "push" | "admin"; +} + +export type SwaggerTypeEmailsPostGeneratedDataContract = string[]; + +export type SwaggerTypeEmojisGeneratedDataContract = Record; + +export interface SwaggerTypeEventGeneratedDataContract { + /** A user or organization */ + actor?: SwaggerTypeActorGeneratedDataContract; + created_at?: object; + id?: number; + /** A GitHub organization */ + org?: SwaggerTypeOrganizationGeneratedDataContract; + payload?: object; + public?: boolean; + repo?: { + id?: number; + name?: string; + url?: string; + }; + type?: string; +} + +export type SwaggerTypeEventsGeneratedDataContract = SwaggerTypeEventGeneratedDataContract[]; + +export interface SwaggerTypeFeedsGeneratedDataContract { + _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 SwaggerTypeForkBodyGeneratedDataContract { + organization?: string; +} + +export type SwaggerTypeForksGeneratedDataContract = SwaggerTypeReposGeneratedDataContract; + +export interface SwaggerTypeGistGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; + }[]; + 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?: SwaggerTypeUserGeneratedDataContract; + version?: string; + }[]; + html_url?: string; + id?: string; + public?: boolean; + url?: string; + /** A GitHub user */ + user?: SwaggerTypeUserGeneratedDataContract; +} + +export type SwaggerTypeGistsGeneratedDataContract = { + 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?: SwaggerTypeUserGeneratedDataContract; +}[]; + +export interface SwaggerTypeGitCommitGeneratedDataContract { + author?: { + date?: string; + email?: string; + name?: string; + }; + message?: string; + parents?: string; + tree?: string; +} + +export interface SwaggerTypeGitRefPatchGeneratedDataContract { + force?: boolean; + sha?: string; +} + +export type SwaggerTypeGitignoreGeneratedDataContract = any[]; + +export interface SwaggerTypeGitignoreLangGeneratedDataContract { + name?: string; + source?: string; +} + +export interface SwaggerTypeHeadBranchGeneratedDataContract { + object?: { + sha?: string; + type?: string; + url?: string; + }; + ref?: string; + url?: string; +} + +export type SwaggerTypeHookGeneratedDataContract = { + 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 SwaggerTypeHookBodyGeneratedDataContract { + active?: boolean; + add_events?: string[]; +} + +export interface SwaggerTypeIssueGeneratedDataContract { + assignee?: string; + body?: string; + labels?: string[]; + milestone?: number; + title?: string; +} + +export interface SwaggerTypeIssueEventGeneratedDataContract { + /** A user or organization */ + actor?: SwaggerTypeActorGeneratedDataContract; + commit_id?: string; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + event?: string; + issue?: { + /** A GitHub user */ + assignee?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + }; + url?: string; +} + +export type SwaggerTypeIssueEventsGeneratedDataContract = SwaggerTypeIssueEventGeneratedDataContract[]; + +export type SwaggerTypeIssuesGeneratedDataContract = { + /** A GitHub user */ + assignee?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; +}[]; + +export interface SwaggerTypeIssuesCommentGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; +} + +export type SwaggerTypeIssuesCommentsGeneratedDataContract = { + _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?: SwaggerTypeUserGeneratedDataContract; +}[]; + +export type SwaggerTypeKeysGeneratedDataContract = { + id?: number; + key?: string; + title?: string; + url?: string; +}[]; + +export interface SwaggerTypeLabelGeneratedDataContract { + color?: string; + name?: string; + url?: string; +} + +export type SwaggerTypeLabelsGeneratedDataContract = { + color?: string; + name?: string; + url?: string; +}[]; + +export type SwaggerTypeLanguagesGeneratedDataContract = Record; + +export interface SwaggerTypeMarkdownGeneratedDataContract { + context?: string; + mode?: string; + text?: string; +} + +export interface SwaggerTypeMergeGeneratedDataContract { + merged?: boolean; + message?: string; + sha?: string; +} + +export interface SwaggerTypeMergePullBodyGeneratedDataContract { + commit_message?: string; +} + +export interface SwaggerTypeMergesBodyGeneratedDataContract { + base?: string; + commit_message?: string; + head?: string; +} + +export interface SwaggerTypeMergesConflictGeneratedDataContract { + /** Error message */ + message?: string; +} + +export interface SwaggerTypeMergesSuccessfulGeneratedDataContract { + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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?: SwaggerTypeUserGeneratedDataContract; + merged?: boolean; + message?: string; + parents?: { + sha?: string; + url?: string; + }[]; + sha?: string; + url?: string; +} + +export interface SwaggerTypeMetaGeneratedDataContract { + git?: string[]; + hooks?: string[]; +} + +export interface SwaggerTypeMilestoneGeneratedDataContract { + closed_issues?: number; + /** ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ */ + created_at?: string; + /** A GitHub user */ + creator?: SwaggerTypeUserGeneratedDataContract; + 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 SwaggerTypeMilestoneUpdateGeneratedDataContract { + description?: string; + due_on?: string; + state?: string; + title?: string; +} + +export interface SwaggerTypeNotificationMarkReadGeneratedDataContract { + last_read_at?: string; +} + +export interface SwaggerTypeNotificationsGeneratedDataContract { + 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?: SwaggerTypeActorGeneratedDataContract; + private?: boolean; + url?: string; + }; + subject?: { + latest_comment_url?: string; + title?: string; + type?: string; + url?: string; + }; + unread?: boolean; + updated_at?: string; + url?: string; +} + +export interface SwaggerTypeOrgTeamsPostGeneratedDataContract { + name: string; + permission?: "pull" | "push" | "admin"; + repo_names?: string[]; +} + +/** + * A GitHub organization + */ +export type SwaggerTypeOrganizationGeneratedDataContract = SwaggerTypeActorGeneratedDataContract; + +export interface SwaggerTypeOrganizationAsTeamMemberGeneratedDataContract { + errors?: { + code?: string; + field?: string; + resource?: string; + }[]; + message?: string; +} + +export interface SwaggerTypeParticipationStatsGeneratedDataContract { + all?: number[]; + owner?: number[]; +} + +export interface SwaggerTypePatchGistGeneratedDataContract { + 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 SwaggerTypePatchOrgGeneratedDataContract { + /** 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 SwaggerTypePostGistGeneratedDataContract { + description?: string; + files?: { + "file1.txt"?: { + content?: string; + }; + }; + public?: boolean; +} + +export interface SwaggerTypePostRepoGeneratedDataContract { + /** 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 SwaggerTypePullRequestGeneratedDataContract { + _links?: { + comments?: { + href?: string; + }; + html?: { + href?: string; + }; + review_comments?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + additions?: number; + base?: { + label?: string; + ref?: string; + repo?: SwaggerTypeRepoGeneratedDataContract; + 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?: SwaggerTypeRepoGeneratedDataContract; + 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 SwaggerTypePullUpdateGeneratedDataContract { + body?: string; + state?: string; + title?: string; +} + +export type SwaggerTypePullsGeneratedDataContract = { + _links?: { + comments?: { + href?: string; + }; + html?: { + href?: string; + }; + review_comments?: { + href?: string; + }; + self?: { + href?: string; + }; + }; + base?: { + label?: string; + ref?: string; + repo?: SwaggerTypeRepoGeneratedDataContract; + 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?: SwaggerTypeRepoGeneratedDataContract; + 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 SwaggerTypePullsCommentGeneratedDataContract { + _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 SwaggerTypePullsCommentPostGeneratedDataContract { + body?: string; + commit_id?: string; + path?: string; + position?: number; +} + +export type SwaggerTypePullsCommentsGeneratedDataContract = { + _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 SwaggerTypePullsPostGeneratedDataContract { + base?: string; + body?: string; + head?: string; + title?: string; +} + +export interface SwaggerTypePutSubscriptionGeneratedDataContract { + created_at?: string; + ignored?: boolean; + reason?: object; + subscribed?: boolean; + thread_url?: string; + url?: string; +} + +export interface SwaggerTypeRateLimitGeneratedDataContract { + rate?: { + limit?: number; + remaining?: number; + reset?: number; + }; +} + +export type SwaggerTypeRefGeneratedDataContract = { + /** 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 SwaggerTypeRefStatusGeneratedDataContract = { + 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 SwaggerTypeRefsGeneratedDataContract = { + object?: { + sha?: string; + type?: string; + url?: string; + }; + ref?: string; + url?: string; +}[]; + +export interface SwaggerTypeRefsBodyGeneratedDataContract { + ref?: string; + sha?: string; +} + +export interface SwaggerTypeReleaseGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; + url?: string; + }[]; + assets_url?: string; + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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 SwaggerTypeReleaseCreateGeneratedDataContract { + body?: string; + draft?: boolean; + name?: string; + prerelease?: boolean; + tag_name?: string; + target_commitish?: string; +} + +export type SwaggerTypeReleasesGeneratedDataContract = { + 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?: SwaggerTypeUserGeneratedDataContract; + url?: string; + }[]; + assets_url?: string; + /** A GitHub user */ + author?: SwaggerTypeUserGeneratedDataContract; + 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 SwaggerTypeRepoGeneratedDataContract { + 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?: SwaggerTypeOrganizationGeneratedDataContract; + /** A user or organization */ + owner?: SwaggerTypeActorGeneratedDataContract; + /** Is present when the repo is a fork. Parent is the repo this repo was forked from. */ + parent?: SwaggerTypeRepoGeneratedDataContract; + 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?: SwaggerTypeRepoGeneratedDataContract; + 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 SwaggerTypeRepoDeploymentsGeneratedDataContract = { + created_at?: string; + /** A GitHub user */ + creator?: SwaggerTypeUserGeneratedDataContract; + description?: string; + id?: number; + payload?: string; + sha?: string; + statuses_url?: string; + updated_at?: string; + url?: string; +}[]; + +export type SwaggerTypeRepoCommentsGeneratedDataContract = { + 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?: SwaggerTypeUserGeneratedDataContract; +}[]; + +export interface SwaggerTypeRepoCommitGeneratedDataContract { + 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 SwaggerTypeRepoCommitBodyGeneratedDataContract { + author?: { + date?: string; + email?: string; + name?: string; + }; + message: string; + parents: string[]; + tree: string; +} + +export interface SwaggerTypeRepoEditGeneratedDataContract { + description?: string; + has_downloads?: boolean; + has_issues?: boolean; + has_wiki?: boolean; + homepage?: string; + name?: string; + private?: boolean; +} + +export type SwaggerTypeReposGeneratedDataContract = SwaggerTypeRepoGeneratedDataContract[]; + +export interface SwaggerTypeSearchCodeGeneratedDataContract { + 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?: SwaggerTypeActorGeneratedDataContract; + 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 SwaggerTypeSearchIssuesGeneratedDataContract { + 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?: SwaggerTypeUserGeneratedDataContract; + }[]; + total_count?: number; +} + +export interface SwaggerTypeSearchIssuesByKeywordGeneratedDataContract { + 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 SwaggerTypeSearchRepositoriesGeneratedDataContract { + items?: SwaggerTypeRepoGeneratedDataContract[]; + total_count?: number; +} + +export interface SwaggerTypeSearchRepositoriesByKeywordGeneratedDataContract { + repositories?: SwaggerTypeRepoGeneratedDataContract[]; +} + +export interface SwaggerTypeSearchUserByEmailGeneratedDataContract { + /** A GitHub user */ + user?: SwaggerTypeUserGeneratedDataContract; +} + +export interface SwaggerTypeSearchUsersGeneratedDataContract { + items?: SwaggerTypeUsersGeneratedDataContract; + total_count?: number; +} + +export interface SwaggerTypeSearchUsersByKeywordGeneratedDataContract { + users?: SwaggerTypeUsersGeneratedDataContract; +} + +export interface SwaggerTypeSubscriptionGeneratedDataContract { + /** 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 SwaggerTypeSubscriptionBodyGeneratedDataContract { + ignored?: boolean; + subscribed?: boolean; +} + +export interface SwaggerTypeTagGeneratedDataContract { + /** 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 SwaggerTypeTagBodyGeneratedDataContract { + /** 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 SwaggerTypeTagsGeneratedDataContract = SwaggerTypeTagGeneratedDataContract[]; + +export interface SwaggerTypeTeamGeneratedDataContract { + id?: number; + members_count?: number; + name?: string; + permission?: string; + repos_count?: number; + url?: string; +} + +export interface SwaggerTypeTeamMembershipGeneratedDataContract { + state?: string; + url?: string; +} + +export type SwaggerTypeTeamReposGeneratedDataContract = SwaggerTypeReposGeneratedDataContract; + +export type SwaggerTypeTeamsGeneratedDataContract = { + id?: number; + name?: string; + url?: string; +}[]; + +export type SwaggerTypeTeamsListGeneratedDataContract = { + 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 SwaggerTypeTreeGeneratedDataContract { + 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 SwaggerTypeTreesGeneratedDataContract { + base_tree?: string; + /** SHA1 checksum ID of the object in the tree. */ + sha?: string; + tree?: SwaggerTypeTreeGeneratedDataContract[]; + url?: string; +} + +/** + * A GitHub user + */ +export type SwaggerTypeUserGeneratedDataContract = SwaggerTypeActorGeneratedDataContract; + +export type SwaggerTypeUserEmailsGeneratedDataContract = string[]; + +export interface SwaggerTypeUserKeysKeyIdGeneratedDataContract { + id?: number; + key?: string; + title?: string; + url?: string; +} + +export interface SwaggerTypeUserKeysPostGeneratedDataContract { + key?: string; + title?: string; +} + +export interface SwaggerTypeUserUpdateGeneratedDataContract { + bio?: string; + blog?: string; + company?: string; + email?: string; + hireable?: boolean; + location?: string; + name?: string; +} + +export type SwaggerTypeUsersGeneratedDataContract = SwaggerTypeUserGeneratedDataContract[]; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @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 + * @response `200` `{ + 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, + +}, + +}, + +}, + +}, + +}, + +}, + +}` Success + */ + 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; + }; + }; + }; + }; + }; + }; + }, + any + >({ + path: `/some-test`, + method: "GET", + format: "json", + ...params, + }), + }; + pathParams = { + /** + * @description Lists all the emojis available to use on GitHub. + * + * @name PathParamsList + * @request GET:/path-params + * @response `200` `SwaggerTypeEmojisGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pathParamsList: (petId: number, params: RequestParams = {}) => + this.request({ + path: `/path-params`, + method: "GET", + format: "json", + ...params, + }), + }; + events = { + /** + * @description List public events. + * + * @name EventsList + * @request GET:/events + * @response `200` `SwaggerTypeEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsList: (params: RequestParams = {}) => + this.request({ + path: `/events`, + method: "GET", + format: "json", + ...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 + * @response `200` `SwaggerTypeFeedsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + feedsList: (params: RequestParams = {}) => + this.request({ + path: `/feeds`, + method: "GET", + format: "json", + ...params, + }), + }; + gists = { + /** + * @description List the authenticated user's gists or if called anonymously, this will return all public gists. + * + * @name GistsList + * @request GET:/gists + * @response `200` `SwaggerTypeGistsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a gist. + * + * @name GistsCreate + * @request POST:/gists + * @response `201` `SwaggerTypeGistGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gistsCreate: (body: SwaggerTypePostGistGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/gists`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List all public gists. + * + * @name PublicList + * @request GET:/gists/public + * @response `200` `SwaggerTypeGistsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/gists/public`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List the authenticated user's starred gists. + * + * @name StarredList + * @request GET:/gists/starred + * @response `200` `SwaggerTypeGistsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/gists/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a gist. + * + * @name GistsDelete + * @request DELETE:/gists/{id} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gistsDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single gist. + * + * @name GistsDetail + * @request GET:/gists/{id} + * @response `200` `SwaggerTypeGistGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gistsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a gist. + * + * @name GistsPartialUpdate + * @request PATCH:/gists/{id} + * @response `200` `SwaggerTypeGistGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gistsPartialUpdate: (id: number, body: SwaggerTypePatchGistGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a gist. + * + * @name CommentsDetail + * @request GET:/gists/{id}/comments + * @response `200` `SwaggerTypeCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a commen + * + * @name CommentsCreate + * @request POST:/gists/{id}/comments + * @response `201` `SwaggerTypeCommentGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsCreate: (id: number, body: SwaggerTypeCommentBodyGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name CommentsDelete + * @request DELETE:/gists/{id}/comments/{commentId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDelete: (id: number, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name CommentsDetail2 + * @request GET:/gists/{id}/comments/{commentId} + * @originalName commentsDetail + * @duplicate + * @response `200` `SwaggerTypeCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDetail2: (id: number, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/gists/{id}/comments/{commentId} + * @response `200` `SwaggerTypeCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsPartialUpdate: ( + id: number, + commentId: number, + body: SwaggerTypeCommentGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/gists/${id}/comments/${commentId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Fork a gist. + * + * @name ForksCreate + * @request POST:/gists/{id}/forks + * @response `204` `void` Exists. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Not exists. + */ + forksCreate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/forks`, + method: "POST", + ...params, + }), + + /** + * @description Unstar a gist. + * + * @name StarDelete + * @request DELETE:/gists/{id}/star + * @response `204` `void` Item removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/star`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if a gist is starred. + * + * @name StarDetail + * @request GET:/gists/{id}/star + * @response `204` `void` Exists. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Not exists. + */ + starDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/gists/${id}/star`, + method: "GET", + ...params, + }), + + /** + * @description Star a gist. + * + * @name StarUpdate + * @request PUT:/gists/{id}/star + * @response `204` `void` Starred. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + templatesList: (params: RequestParams = {}) => + this.request({ + path: `/gitignore/templates`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single template. + * + * @name TemplatesDetail + * @request GET:/gitignore/templates/{language} + * @response `200` `SwaggerTypeGitignoreLangGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + templatesDetail: (language: string, params: RequestParams = {}) => + this.request({ + path: `/gitignore/templates/${language}`, + method: "GET", + format: "json", + ...params, + }), + }; + issues = { + /** + * @description List issues. List all issues across all the authenticated user's visible repositories. + * + * @name IssuesList + * @request GET:/issues + * @response `200` `SwaggerTypeIssuesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesList: ( + query: { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + legacy = { + /** + * @description Find issues by state and keyword. + * + * @name IssuesSearchDetail + * @request GET:/legacy/issues/search/{owner}/{repository}/{state}/{keyword} + * @deprecated + * @response `200` `SwaggerTypeSearchIssuesByKeywordGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesSearchDetail: ( + keyword: string, + state: "open" | "closed", + owner: string, + repository: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/legacy/issues/search/${owner}/${repository}/${state}/${keyword}`, + method: "GET", + format: "json", + ...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 + * @response `200` `SwaggerTypeSearchRepositoriesByKeywordGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposSearchDetail: ( + keyword: string, + query?: { + /** The sort field. if sort param is provided. Can be either asc or 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({ + path: `/legacy/repos/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description This API call is added for compatibility reasons only. + * + * @name UserEmailDetail + * @request GET:/legacy/user/email/{email} + * @deprecated + * @response `200` `SwaggerTypeSearchUserByEmailGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + userEmailDetail: (email: string, params: RequestParams = {}) => + this.request({ + path: `/legacy/user/email/${email}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Find users by keyword. + * + * @name UserSearchDetail + * @request GET:/legacy/user/search/{keyword} + * @deprecated + * @response `200` `SwaggerTypeSearchUsersByKeywordGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + userSearchDetail: ( + keyword: string, + query?: { + /** The sort field. if sort param is provided. Can be either asc or 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({ + path: `/legacy/user/search/${keyword}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + markdown = { + /** + * @description Render an arbitrary Markdown document + * + * @name MarkdownCreate + * @request POST:/markdown + * @response `200` `void` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + markdownCreate: (body: SwaggerTypeMarkdownGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/markdown`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description Render a Markdown document in raw mode + * + * @name PostMarkdown + * @request POST:/markdown/raw + * @response `200` `void` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + postMarkdown: (params: RequestParams = {}) => + this.request({ + path: `/markdown/raw`, + method: "POST", + ...params, + }), + }; + meta = { + /** + * @description This gives some information about GitHub.com, the service. + * + * @name MetaList + * @request GET:/meta + * @response `200` `SwaggerTypeMetaGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + metaList: (params: RequestParams = {}) => + this.request({ + path: `/meta`, + method: "GET", + format: "json", + ...params, + }), + }; + networks = { + /** + * @description List public events for a network of repositories. + * + * @name EventsDetail + * @request GET:/networks/{owner}/{repo}/events + * @response `200` `SwaggerTypeEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/networks/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + }; + notifications = { + /** + * @description List your notifications. List all notifications for the current user, grouped by repository. + * + * @name NotificationsList + * @request GET:/notifications + * @response `200` `SwaggerTypeNotificationsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Mark as read. Marking a notification as "read" removes it from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/notifications + * @response `205` `void` Marked as read. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + notificationsUpdate: (body: SwaggerTypeNotificationMarkReadGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description View a single thread. + * + * @name ThreadsDetail + * @request GET:/notifications/threads/{id} + * @response `200` `SwaggerTypeNotificationsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + threadsDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Mark a thread as read + * + * @name ThreadsPartialUpdate + * @request PATCH:/notifications/threads/{id} + * @response `205` `void` Thread marked as read. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + threadsPartialUpdate: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}`, + method: "PATCH", + ...params, + }), + + /** + * @description Delete a Thread Subscription. + * + * @name ThreadsSubscriptionDelete + * @request DELETE:/notifications/threads/{id}/subscription + * @response `204` `void` No Content + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + threadsSubscriptionDelete: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}/subscription`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a Thread Subscription. + * + * @name ThreadsSubscriptionDetail + * @request GET:/notifications/threads/{id}/subscription + * @response `200` `SwaggerTypeSubscriptionGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + threadsSubscriptionDetail: (id: number, params: RequestParams = {}) => + this.request({ + path: `/notifications/threads/${id}/subscription`, + method: "GET", + format: "json", + ...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 + * @response `200` `SwaggerTypeSubscriptionGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + threadsSubscriptionUpdate: ( + id: number, + body: SwaggerTypePutSubscriptionGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/notifications/threads/${id}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + }; + orgs = { + /** + * @description Get an Organization. + * + * @name OrgsDetail + * @request GET:/orgs/{org} + * @response `200` `SwaggerTypeOrganizationGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + orgsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit an Organization. + * + * @name OrgsPartialUpdate + * @request PATCH:/orgs/{org} + * @response `200` `SwaggerTypeOrganizationGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + orgsPartialUpdate: (org: string, body: SwaggerTypePatchOrgGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List public events for an organization. + * + * @name EventsDetail + * @request GET:/orgs/{org}/events + * @response `200` `SwaggerTypeEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List issues. List all issues for a given organization for the authenticated user. + * + * @name IssuesDetail + * @request GET:/orgs/{org}/issues + * @response `200` `SwaggerTypeIssuesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/orgs/${org}/issues`, + method: "GET", + query: query, + format: "json", + ...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 + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `302` `void` Response if requester is not an organization member. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + membersDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/members`, + method: "GET", + format: "json", + ...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} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + membersDelete: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `204` `void` No content. Response if requester is an organization member and user is a member + * @response `302` `void` Found. Response if requester is not an organization member + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Not Found. a. Response if requester is an organization member and user is not a member b. Response if requester is not an organization member and is inquiring about themselves + */ + membersDetail2: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + publicMembersDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Conceal a user's membership. + * + * @name PublicMembersDelete + * @request DELETE:/orgs/{org}/public_members/{username} + * @response `204` `void` Concealed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + publicMembersDelete: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check public membership. + * + * @name PublicMembersDetail2 + * @request GET:/orgs/{org}/public_members/{username} + * @originalName publicMembersDetail + * @duplicate + * @response `204` `void` User is a public member. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` User is not a public member. + */ + publicMembersDetail2: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members/${username}`, + method: "GET", + ...params, + }), + + /** + * @description Publicize a user's membership. + * + * @name PublicMembersUpdate + * @request PUT:/orgs/{org}/public_members/{username} + * @response `204` `void` Publicized. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + publicMembersUpdate: (org: string, username: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/public_members/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description List repositories for the specified org. + * + * @name ReposDetail + * @request GET:/orgs/{org}/repos + * @response `200` `SwaggerTypeReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail: ( + org: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/orgs/${org}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/orgs/{org}/repos + * @response `201` `SwaggerTypeReposGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposCreate: (org: string, body: SwaggerTypePostRepoGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List teams. + * + * @name TeamsDetail + * @request GET:/orgs/{org}/teams + * @response `200` `SwaggerTypeTeamsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsDetail: (org: string, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/teams`, + method: "GET", + format: "json", + ...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 + * @response `201` `SwaggerTypeTeamGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsCreate: (org: string, body: SwaggerTypeOrgTeamsPostGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/orgs/${org}/teams`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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 + * @response `200` `SwaggerTypeRateLimitGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + rateLimitList: (params: RequestParams = {}) => + this.request({ + path: `/rate_limit`, + method: "GET", + format: "json", + ...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} + * @response `204` `void` Item removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get repository. + * + * @name ReposDetail + * @request GET:/repos/{owner}/{repo} + * @response `200` `SwaggerTypeRepoGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit repository. + * + * @name ReposPartialUpdate + * @request PATCH:/repos/{owner}/{repo} + * @response `200` `SwaggerTypeRepoGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposPartialUpdate: ( + owner: string, + repo: string, + body: SwaggerTypeRepoEditGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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 + * @response `200` `SwaggerTypeAssigneesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + assigneesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/assignees`, + method: "GET", + format: "json", + ...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 + * @response `204` `void` User is an assignee. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` User isn't an assignee. + */ + assigneesDetail2: (owner: string, repo: string, assignee: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/assignees/${assignee}`, + method: "GET", + ...params, + }), + + /** + * @description Get list of branches + * + * @name BranchesDetail + * @request GET:/repos/{owner}/{repo}/branches + * @response `200` `SwaggerTypeBranchesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + branchesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/branches`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get Branch + * + * @name BranchesDetail2 + * @request GET:/repos/{owner}/{repo}/branches/{branch} + * @originalName branchesDetail + * @duplicate + * @response `200` `SwaggerTypeBranchGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + branchesDetail2: (owner: string, repo: string, branch: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/branches/${branch}`, + method: "GET", + format: "json", + ...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 + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + collaboratorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/collaborators`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Remove collaborator. + * + * @name CollaboratorsDelete + * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} + * @response `204` `void` Collaborator removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + collaboratorsDelete: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `204` `void` User is a collaborator. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` User is not a collaborator. + */ + collaboratorsDetail2: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/collaborators/${user}`, + method: "GET", + ...params, + }), + + /** + * @description Add collaborator. + * + * @name CollaboratorsUpdate + * @request PUT:/repos/{owner}/{repo}/collaborators/{user} + * @response `204` `void` Collaborator added. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + collaboratorsUpdate: (owner: string, repo: string, user: string, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeRepoCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a commit comment + * + * @name CommentsDelete + * @request DELETE:/repos/{owner}/{repo}/comments/{commentId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeCommitCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a commit comment. + * + * @name CommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/comments/{commentId} + * @response `200` `SwaggerTypeCommitCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: SwaggerTypeCommentBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List commits on a repository. + * + * @name CommitsDetail + * @request GET:/repos/{owner}/{repo}/commits + * @response `200` `SwaggerTypeCommitsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/repos/${owner}/${repo}/commits`, + method: "GET", + query: query, + format: "json", + ...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 + * @response `200` `SwaggerTypeRefStatusGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commitsStatusDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/commits/${ref}/status`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single commit. + * + * @name CommitsDetail2 + * @request GET:/repos/{owner}/{repo}/commits/{shaCode} + * @originalName commitsDetail + * @duplicate + * @response `200` `SwaggerTypeCommitGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commitsDetail2: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List comments for a single commitList comments for a single commit. + * + * @name CommitsCommentsDetail + * @request GET:/repos/{owner}/{repo}/commits/{shaCode}/comments + * @response `200` `SwaggerTypeRepoCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commitsCommentsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a commit comment. + * + * @name CommitsCommentsCreate + * @request POST:/repos/{owner}/{repo}/commits/{shaCode}/comments + * @response `201` `SwaggerTypeCommitCommentGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + commitsCommentsCreate: ( + owner: string, + repo: string, + shaCode: string, + body: SwaggerTypeCommitCommentBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Compare two commits + * + * @name CompareDetail + * @request GET:/repos/{owner}/{repo}/compare/{baseId}...{headId} + * @response `200` `SwaggerTypeCompareCommitsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + compareDetail: (owner: string, repo: string, baseId: string, headId: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/compare/${baseId}...${headId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a file. This method deletes a file in a repository. + * + * @name ContentsDelete + * @request DELETE:/repos/{owner}/{repo}/contents/{path} + * @response `200` `SwaggerTypeDeleteFileGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + contentsDelete: ( + owner: string, + repo: string, + path: string, + body: SwaggerTypeDeleteFileBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "DELETE", + body: body, + type: ContentType.Json, + format: "json", + ...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} + * @response `200` `SwaggerTypeContentsPathGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a file. + * + * @name ContentsUpdate + * @request PUT:/repos/{owner}/{repo}/contents/{path} + * @response `200` `SwaggerTypeCreateFileGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + contentsUpdate: ( + owner: string, + repo: string, + path: string, + body: SwaggerTypeCreateFileBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/contents/${path}`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get list of contributors. + * + * @name ContributorsDetail + * @request GET:/repos/{owner}/{repo}/contributors + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + contributorsDetail: ( + owner: string, + repo: string, + query: { + /** Set to 1 or true to include anonymous contributors in results. */ + anon: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/contributors`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Users with pull access can view deployments for a repository + * + * @name DeploymentsDetail + * @request GET:/repos/{owner}/{repo}/deployments + * @response `200` `SwaggerTypeRepoDeploymentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + deploymentsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/deployments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Users with push access can create a deployment for a given ref + * + * @name DeploymentsCreate + * @request POST:/repos/{owner}/{repo}/deployments + * @response `201` `SwaggerTypeDeploymentRespGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + deploymentsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeDeploymentGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/deployments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Users with pull access can view deployment statuses for a deployment + * + * @name DeploymentsStatusesDetail + * @request GET:/repos/{owner}/{repo}/deployments/{id}/statuses + * @response `200` `SwaggerTypeDeploymentStatusesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + deploymentsStatusesDetail: (owner: string, repo: string, id: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "GET", + format: "json", + ...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 + * @response `201` `void` ok + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + deploymentsStatusesCreate: ( + owner: string, + repo: string, + id: number, + body: SwaggerTypeDeploymentStatusesCreateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, + method: "POST", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description Deprecated. List downloads for a repository. + * + * @name DownloadsDetail + * @request GET:/repos/{owner}/{repo}/downloads + * @deprecated + * @response `200` `SwaggerTypeDownloadsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + downloadsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/downloads`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Deprecated. Delete a download. + * + * @name DownloadsDelete + * @request DELETE:/repos/{owner}/{repo}/downloads/{downloadId} + * @deprecated + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + downloadsDelete: (owner: string, repo: string, downloadId: number, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeDownloadGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + downloadsDetail2: (owner: string, repo: string, downloadId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/downloads/${downloadId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of repository events. + * + * @name EventsDetail + * @request GET:/repos/{owner}/{repo}/events + * @response `200` `SwaggerTypeEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List forks. + * + * @name ForksDetail + * @request GET:/repos/{owner}/{repo}/forks + * @response `200` `SwaggerTypeForksGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + forksDetail: ( + owner: string, + repo: string, + query?: { + sort?: "newes" | "oldes" | "watchers"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "GET", + query: query, + format: "json", + ...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 + * @response `201` `SwaggerTypeRepoGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + forksCreate: ( + owner: string, + repo: string, + body: SwaggerTypeForkBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/forks`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Create a Blob. + * + * @name GitBlobsCreate + * @request POST:/repos/{owner}/{repo}/git/blobs + * @response `201` `SwaggerTypeBlobsGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitBlobsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeBlobGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/blobs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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} + * @response `200` `SwaggerTypeBlobGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitBlobsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/blobs/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Commit. + * + * @name GitCommitsCreate + * @request POST:/repos/{owner}/{repo}/git/commits + * @response `201` `SwaggerTypeGitCommitGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitCommitsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeRepoCommitBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/commits`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get a Commit. + * + * @name GitCommitsDetail + * @request GET:/repos/{owner}/{repo}/git/commits/{shaCode} + * @response `200` `SwaggerTypeRepoCommitGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitCommitsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/commits/${shaCode}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get all References + * + * @name GitRefsDetail + * @request GET:/repos/{owner}/{repo}/git/refs + * @response `200` `SwaggerTypeRefsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitRefsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Reference + * + * @name GitRefsCreate + * @request POST:/repos/{owner}/{repo}/git/refs + * @response `201` `SwaggerTypeHeadBranchGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitRefsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeRefsBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...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} + * @response `204` `void` No Content + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitRefsDelete: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeHeadBranchGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitRefsDetail2: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a Reference + * + * @name GitRefsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/git/refs/{ref} + * @response `200` `SwaggerTypeHeadBranchGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitRefsPartialUpdate: ( + owner: string, + repo: string, + ref: string, + body: SwaggerTypeGitRefPatchGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/refs/${ref}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...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 + * @response `201` `SwaggerTypeTagGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitTagsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeTagBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/tags`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get a Tag. + * + * @name GitTagsDetail + * @request GET:/repos/{owner}/{repo}/git/tags/{shaCode} + * @response `200` `SwaggerTypeTagGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitTagsDetail: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/git/tags/${shaCode}`, + method: "GET", + format: "json", + ...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 + * @response `201` `SwaggerTypeTreesGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitTreesCreate: ( + owner: string, + repo: string, + body: SwaggerTypeTreeGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/trees`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get a Tree. + * + * @name GitTreesDetail + * @request GET:/repos/{owner}/{repo}/git/trees/{shaCode} + * @response `200` `SwaggerTypeTreeGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gitTreesDetail: ( + owner: string, + repo: string, + shaCode: string, + query?: { + /** Get a Tree Recursively. (0 or 1) */ + recursive?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get list of hooks. + * + * @name HooksDetail + * @request GET:/repos/{owner}/{repo}/hooks + * @response `200` `SwaggerTypeHookGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a hook. + * + * @name HooksCreate + * @request POST:/repos/{owner}/{repo}/hooks + * @response `201` `SwaggerTypeHookGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksCreate: ( + owner: string, + repo: string, + body: SwaggerTypeHookBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/hooks`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a hook. + * + * @name HooksDelete + * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksDelete: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get single hook. + * + * @name HooksDetail2 + * @request GET:/repos/{owner}/{repo}/hooks/{hookId} + * @originalName hooksDetail + * @duplicate + * @response `200` `SwaggerTypeHookGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksDetail2: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a hook. + * + * @name HooksPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/hooks/{hookId} + * @response `200` `SwaggerTypeHookGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksPartialUpdate: ( + owner: string, + repo: string, + hookId: number, + body: SwaggerTypeHookBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}`, + method: "PATCH", + body: body, + format: "json", + ...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 + * @response `204` `void` Hook is triggered. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + hooksTestsCreate: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/hooks/${hookId}/tests`, + method: "POST", + ...params, + }), + + /** + * @description List issues for a repository. + * + * @name IssuesDetail + * @request GET:/repos/{owner}/{repo}/issues + * @response `200` `SwaggerTypeIssuesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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 + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/repos/${owner}/${repo}/issues`, + method: "GET", + query: query, + format: "json", + ...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 + * @response `201` `SwaggerTypeIssueGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCreate: ( + owner: string, + repo: string, + body: SwaggerTypeIssueGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List comments in a repository. + * + * @name IssuesCommentsDetail + * @request GET:/repos/{owner}/{repo}/issues/comments + * @response `200` `SwaggerTypeIssuesCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + 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({ + path: `/repos/${owner}/${repo}/issues/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name IssuesCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/comments/{commentId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeIssuesCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name IssuesCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/issues/comments/{commentId} + * @response `200` `SwaggerTypeIssuesCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: SwaggerTypeCommentBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List issue events for a repository. + * + * @name IssuesEventsDetail + * @request GET:/repos/{owner}/{repo}/issues/events + * @response `200` `SwaggerTypeIssueEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesEventsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single event. + * + * @name IssuesEventsDetail2 + * @request GET:/repos/{owner}/{repo}/issues/events/{eventId} + * @originalName issuesEventsDetail + * @duplicate + * @response `200` `SwaggerTypeIssueEventGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesEventsDetail2: (owner: string, repo: string, eventId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/events/${eventId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get a single issue + * + * @name IssuesDetail2 + * @request GET:/repos/{owner}/{repo}/issues/{number} + * @originalName issuesDetail + * @duplicate + * @response `200` `SwaggerTypeIssueGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "GET", + format: "json", + ...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} + * @response `200` `SwaggerTypeIssueGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeIssueGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List comments on an issue. + * + * @name IssuesCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/comments + * @originalName issuesCommentsDetail + * @duplicate + * @response `200` `SwaggerTypeIssuesCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a comment. + * + * @name IssuesCommentsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/comments + * @response `201` `SwaggerTypeIssuesCommentGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeCommentBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/comments`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List events for an issue. + * + * @name IssuesEventsDetail3 + * @request GET:/repos/{owner}/{repo}/issues/{number}/events + * @originalName issuesEventsDetail + * @duplicate + * @response `200` `SwaggerTypeIssueEventsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesEventsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/events`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Remove all labels from an issue. + * + * @name IssuesLabelsDelete + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesLabelsDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/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 + * @response `200` `SwaggerTypeLabelsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Add labels to an issue. + * + * @name IssuesLabelsCreate + * @request POST:/repos/{owner}/{repo}/issues/{number}/labels + * @response `201` `SwaggerTypeLabelGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesLabelsCreate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeEmailsPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Replace all labels for an issue. Sending an empty array ([]) will remove all Labels from the Issue. + * + * @name IssuesLabelsUpdate + * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels + * @response `201` `SwaggerTypeLabelGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesLabelsUpdate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeEmailsPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels`, + method: "PUT", + body: body, + format: "json", + ...params, + }), + + /** + * @description Remove a label from an issue. + * + * @name IssuesLabelsDelete2 + * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} + * @originalName issuesLabelsDelete + * @duplicate + * @response `204` `void` Item removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesLabelsDelete2: (owner: string, repo: string, number: number, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/issues/${number}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get list of keys. + * + * @name KeysDetail + * @request GET:/repos/{owner}/{repo}/keys + * @response `200` `SwaggerTypeKeysGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a key. + * + * @name KeysCreate + * @request POST:/repos/{owner}/{repo}/keys + * @response `201` `SwaggerTypeUserKeysKeyIdGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysCreate: ( + owner: string, + repo: string, + body: SwaggerTypeUserKeysPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a key. + * + * @name KeysDelete + * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDelete: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a key + * + * @name KeysDetail2 + * @request GET:/repos/{owner}/{repo}/keys/{keyId} + * @originalName keysDetail + * @duplicate + * @response `200` `SwaggerTypeUserKeysKeyIdGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDetail2: (owner: string, repo: string, keyId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all labels for this repository. + * + * @name LabelsDetail + * @request GET:/repos/{owner}/{repo}/labels + * @response `200` `SwaggerTypeLabelsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + labelsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a label. + * + * @name LabelsCreate + * @request POST:/repos/{owner}/{repo}/labels + * @response `201` `SwaggerTypeLabelGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + labelsCreate: ( + owner: string, + repo: string, + body: SwaggerTypeEmailsPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/labels`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a label. + * + * @name LabelsDelete + * @request DELETE:/repos/{owner}/{repo}/labels/{name} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + labelsDelete: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single label. + * + * @name LabelsDetail2 + * @request GET:/repos/{owner}/{repo}/labels/{name} + * @originalName labelsDetail + * @duplicate + * @response `200` `SwaggerTypeLabelGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + labelsDetail2: (owner: string, repo: string, name: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a label. + * + * @name LabelsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/labels/{name} + * @response `200` `SwaggerTypeLabelGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + labelsPartialUpdate: ( + owner: string, + repo: string, + name: string, + body: SwaggerTypeEmailsPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/labels/${name}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List languages. List languages for the specified repository. The value on the right of a language is the number of bytes of code written in that language. + * + * @name LanguagesDetail + * @request GET:/repos/{owner}/{repo}/languages + * @response `200` `SwaggerTypeLanguagesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + languagesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/languages`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Perform a merge. + * + * @name MergesCreate + * @request POST:/repos/{owner}/{repo}/merges + * @response `201` `SwaggerTypeMergesSuccessfulGeneratedDataContract` Successful Response (The resulting merge commit) + * @response `204` `void` No-op response (base already contains the head, nothing to merge) + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `SwaggerTypeMergesConflictGeneratedDataContract` Missing base response or missing head response + * @response `409` `SwaggerTypeMergesConflictGeneratedDataContract` Merge conflict response. + */ + mergesCreate: ( + owner: string, + repo: string, + body: SwaggerTypeMergesBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request< + SwaggerTypeMergesSuccessfulGeneratedDataContract, + void | SwaggerTypeMergesConflictGeneratedDataContract + >({ + path: `/repos/${owner}/${repo}/merges`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List milestones for a repository. + * + * @name MilestonesDetail + * @request GET:/repos/{owner}/{repo}/milestones + * @response `200` `SwaggerTypeMilestoneGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "due_date" | "completeness"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a milestone. + * + * @name MilestonesCreate + * @request POST:/repos/{owner}/{repo}/milestones + * @response `201` `SwaggerTypeMilestoneGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesCreate: ( + owner: string, + repo: string, + body: SwaggerTypeMilestoneUpdateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a milestone. + * + * @name MilestonesDelete + * @request DELETE:/repos/{owner}/{repo}/milestones/{number} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesDelete: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single milestone. + * + * @name MilestonesDetail2 + * @request GET:/repos/{owner}/{repo}/milestones/{number} + * @originalName milestonesDetail + * @duplicate + * @response `200` `SwaggerTypeMilestoneGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a milestone. + * + * @name MilestonesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/milestones/{number} + * @response `200` `SwaggerTypeMilestoneGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeMilestoneUpdateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get labels for every issue in a milestone. + * + * @name MilestonesLabelsDetail + * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels + * @response `200` `SwaggerTypeLabelsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + milestonesLabelsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/milestones/${number}/labels`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List your notifications in a repository List all notifications for the current user. + * + * @name NotificationsDetail + * @request GET:/repos/{owner}/{repo}/notifications + * @response `200` `SwaggerTypeNotificationsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + notificationsDetail: ( + owner: string, + repo: string, + 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({ + path: `/repos/${owner}/${repo}/notifications`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Mark notifications as read in a repository. Marking all notifications in a repository as "read" removes them from the default view on GitHub.com. + * + * @name NotificationsUpdate + * @request PUT:/repos/{owner}/{repo}/notifications + * @response `205` `void` Marked as read. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + notificationsUpdate: ( + owner: string, + repo: string, + body: SwaggerTypeNotificationMarkReadGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/notifications`, + method: "PUT", + body: body, + ...params, + }), + + /** + * @description List pull requests. + * + * @name PullsDetail + * @request GET:/repos/{owner}/{repo}/pulls + * @response `200` `SwaggerTypePullsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsDetail: ( + owner: string, + repo: string, + query?: { + /** String to filter by state. */ + state?: "open" | "closed"; + /** + * Filter pulls by head user and branch name in the format of 'user:ref-name'. + * Example: github:new-script-format. + * + */ + head?: string; + /** Filter pulls by base branch name. Example - gh-pages. */ + base?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a pull request. + * + * @name PullsCreate + * @request POST:/repos/{owner}/{repo}/pulls + * @response `201` `SwaggerTypePullsGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCreate: ( + owner: string, + repo: string, + body: SwaggerTypePullsPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments in a repository. By default, Review Comments are ordered by ascending ID. + * + * @name PullsCommentsDetail + * @request GET:/repos/{owner}/{repo}/pulls/comments + * @response `200` `SwaggerTypeIssuesCommentsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsDetail: ( + 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({ + path: `/repos/${owner}/${repo}/pulls/comments`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Delete a comment. + * + * @name PullsCommentsDelete + * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsDelete: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single comment. + * + * @name PullsCommentsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @originalName pullsCommentsDetail + * @duplicate + * @response `200` `SwaggerTypePullsCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsDetail2: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a comment. + * + * @name PullsCommentsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} + * @response `200` `SwaggerTypePullsCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: SwaggerTypeCommentBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description Get a single pull request. + * + * @name PullsDetail2 + * @request GET:/repos/{owner}/{repo}/pulls/{number} + * @originalName pullsDetail + * @duplicate + * @response `200` `SwaggerTypePullRequestGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsDetail2: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update a pull request. + * + * @name PullsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/pulls/{number} + * @response `200` `SwaggerTypeRepoGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypePullUpdateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List comments on a pull request. + * + * @name PullsCommentsDetail3 + * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments + * @originalName pullsCommentsDetail + * @duplicate + * @response `200` `SwaggerTypePullsCommentGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsDetail3: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a comment. #TODO Alternative input ( http://developer.github.com/v3/pulls/comments/ ) description: | Alternative Input. Instead of passing commit_id, path, and position you can reply to an existing Pull Request Comment like this: body Required string in_reply_to Required number - Comment id to reply to. + * + * @name PullsCommentsCreate + * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments + * @response `201` `SwaggerTypePullsCommentGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypePullsCommentPostGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/comments`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List commits on a pull request. + * + * @name PullsCommitsDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits + * @response `200` `SwaggerTypeCommitsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsCommitsDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/commits`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List pull requests files. + * + * @name PullsFilesDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/files + * @response `200` `SwaggerTypePullsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + pullsFilesDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/files`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get if a pull request has been merged. + * + * @name PullsMergeDetail + * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge + * @response `204` `void` Pull request has been merged. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Pull request has not been merged. + */ + pullsMergeDetail: (owner: string, repo: string, number: number, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "GET", + ...params, + }), + + /** + * @description Merge a pull request (Merge Button's) + * + * @name PullsMergeUpdate + * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge + * @response `200` `SwaggerTypeMergeGeneratedDataContract` Response if merge was successful. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `405` `SwaggerTypeMergeGeneratedDataContract` Response if merge cannot be performed. + */ + pullsMergeUpdate: ( + owner: string, + repo: string, + number: number, + body: SwaggerTypeMergePullBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/pulls/${number}/merge`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get the README. This method returns the preferred README for a repository. + * + * @name ReadmeDetail + * @request GET:/repos/{owner}/{repo}/readme + * @response `200` `SwaggerTypeContentsPathGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + readmeDetail: ( + owner: string, + repo: string, + query?: { + /** The String name of the Commit/Branch/Tag. Defaults to master. */ + ref?: string; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/readme`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository will receive all releases (i.e., published releases and draft releases). Users with pull access will receive published releases only + * + * @name ReleasesDetail + * @request GET:/repos/{owner}/{repo}/releases + * @response `200` `SwaggerTypeReleasesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a release Users with push access to the repository can create a release. + * + * @name ReleasesCreate + * @request POST:/repos/{owner}/{repo}/releases + * @response `201` `SwaggerTypeReleaseGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesCreate: ( + owner: string, + repo: string, + body: SwaggerTypeReleaseCreateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a release asset + * + * @name ReleasesAssetsDelete + * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} + * @response `204` `void` No Content + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesAssetsDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release asset + * + * @name ReleasesAssetsDetail + * @request GET:/repos/{owner}/{repo}/releases/assets/{id} + * @response `200` `SwaggerTypeAssetGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesAssetsDetail: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit a release asset Users with push access to the repository can edit a release asset. + * + * @name ReleasesAssetsPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} + * @response `200` `SwaggerTypeAssetGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: SwaggerTypeAssetPatchGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases/assets/${id}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can delete a release. + * + * @name ReleasesDelete + * @request DELETE:/repos/{owner}/{repo}/releases/{id} + * @response `204` `void` No Content + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesDelete: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single release + * + * @name ReleasesDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id} + * @originalName releasesDetail + * @duplicate + * @response `200` `SwaggerTypeReleaseGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Users with push access to the repository can edit a release + * + * @name ReleasesPartialUpdate + * @request PATCH:/repos/{owner}/{repo}/releases/{id} + * @response `200` `SwaggerTypeReleaseGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: SwaggerTypeReleaseCreateGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}`, + method: "PATCH", + body: body, + format: "json", + ...params, + }), + + /** + * @description List assets for a release + * + * @name ReleasesAssetsDetail2 + * @request GET:/repos/{owner}/{repo}/releases/{id}/assets + * @originalName releasesAssetsDetail + * @duplicate + * @response `200` `SwaggerTypeAssetsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + releasesAssetsDetail2: (owner: string, repo: string, id: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/releases/${id}/assets`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. + * + * @name StargazersDetail + * @request GET:/repos/{owner}/{repo}/stargazers + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + stargazersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stargazers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of additions and deletions per week. Returns a weekly aggregate of the number of additions and deletions pushed to a repository. + * + * @name StatsCodeFrequencyDetail + * @request GET:/repos/{owner}/{repo}/stats/code_frequency + * @response `200` `SwaggerTypeCodeFrequencyStatsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statsCodeFrequencyDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/code_frequency`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the last year of commit activity data. Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday. + * + * @name StatsCommitActivityDetail + * @request GET:/repos/{owner}/{repo}/stats/commit_activity + * @response `200` `SwaggerTypeCommitActivityStatsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statsCommitActivityDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/commit_activity`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get contributors list with additions, deletions, and commit counts. + * + * @name StatsContributorsDetail + * @request GET:/repos/{owner}/{repo}/stats/contributors + * @response `200` `SwaggerTypeContributorsStatsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statsContributorsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/contributors`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the weekly commit count for the repo owner and everyone else. + * + * @name StatsParticipationDetail + * @request GET:/repos/{owner}/{repo}/stats/participation + * @response `200` `SwaggerTypeParticipationStatsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statsParticipationDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/participation`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get the number of commits per hour in each day. Each array contains the day number, hour number, and number of commits 0-6 Sunday - Saturday 0-23 Hour of day Number of commits For example, [2, 14, 25] indicates that there were 25 total commits, during the 2.00pm hour on Tuesdays. All times are based on the time zone of individual commits. + * + * @name StatsPunchCardDetail + * @request GET:/repos/{owner}/{repo}/stats/punch_card + * @response `200` `SwaggerTypeCodeFrequencyStatsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statsPunchCardDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/stats/punch_card`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Statuses for a specific Ref. + * + * @name StatusesDetail + * @request GET:/repos/{owner}/{repo}/statuses/{ref} + * @response `200` `SwaggerTypeRefGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statusesDetail: (owner: string, repo: string, ref: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a Status. + * + * @name StatusesCreate + * @request POST:/repos/{owner}/{repo}/statuses/{ref} + * @response `201` `SwaggerTypeRefGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + statusesCreate: ( + owner: string, + repo: string, + ref: string, + body: SwaggerTypeHeadBranchGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/statuses/${ref}`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List watchers. + * + * @name SubscribersDetail + * @request GET:/repos/{owner}/{repo}/subscribers + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscribersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscribers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Delete a Repository Subscription. + * + * @name SubscriptionDelete + * @request DELETE:/repos/{owner}/{repo}/subscription + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a Repository Subscription. + * + * @name SubscriptionDetail + * @request GET:/repos/{owner}/{repo}/subscription + * @response `200` `SwaggerTypeSubscriptionGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Set a Repository Subscription + * + * @name SubscriptionUpdate + * @request PUT:/repos/{owner}/{repo}/subscription + * @response `200` `SwaggerTypeSubscriptionGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionUpdate: ( + owner: string, + repo: string, + body: SwaggerTypeSubscriptionBodyGeneratedDataContract, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/subscription`, + method: "PUT", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Get list of tags. + * + * @name TagsDetail + * @request GET:/repos/{owner}/{repo}/tags + * @response `200` `SwaggerTypeTagsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + tagsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/tags`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get list of teams + * + * @name TeamsDetail + * @request GET:/repos/{owner}/{repo}/teams + * @response `200` `SwaggerTypeTeamsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/teams`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List Stargazers. New implementation. + * + * @name WatchersDetail + * @request GET:/repos/{owner}/{repo}/watchers + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + watchersDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/repos/${owner}/${repo}/watchers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Get archive link. This method will return a 302 to a URL to download a tarball or zipball archive for a repository. Please make sure your HTTP framework is configured to follow redirects or you will need to use the Location header to make a second GET request. Note: For private repositories, these links are temporary and expire quickly. + * + * @name ReposDetail2 + * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} + * @originalName reposDetail + * @duplicate + * @response `302` `void` Found. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail2: ( + owner: string, + repo: string, + archiveFormat: "tarball" | "zipball", + path: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/repos/${owner}/${repo}/${archiveFormat}/${path}`, + method: "GET", + ...params, + }), + }; + repositories = { + /** + * @description List all public repositories. This provides a dump of every public repository, in the order that they were created. Note: Pagination is powered exclusively by the since parameter. is the Link header to get the URL for the next page of repositories. + * + * @name RepositoriesList + * @request GET:/repositories + * @response `200` `SwaggerTypeReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + repositoriesList: ( + 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + search = { + /** + * @description Search code. + * + * @name CodeList + * @request GET:/search/code + * @response `200` `SwaggerTypeSearchCodeGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + codeList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported code + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier + * you can restrict the search to just the file contents, the file path, + * or both. + * 'Languages' Searches code based on the language it's written in. + * 'Forks' Filters repositories based on the number of forks, and/or + * whether code from forked repositories should be included in the results + * at all. + * 'Size' Finds files that match a certain size (in bytes). + * 'Path' Specifies the path that the resulting file must be at. + * 'Extension' Matches files with a certain extension. + * 'Users' or 'Repositories' Limits searches to a specific user or repository. + * + */ + q: string; + /** + * Can only be 'indexed', which indicates how recently a file has been indexed + * by the GitHub search infrastructure. If not provided, results are sorted + * by best match. + * + */ + sort?: "indexed"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/code`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Find issues by state and keyword. (This method returns up to 100 results per page.) + * + * @name IssuesList + * @request GET:/search/issues + * @response `200` `SwaggerTypeSearchIssuesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** The q search term can also contain any combination of the supported issue search qualifiers: */ + q: string; + /** The sort field. Can be comments, created, or updated. Default: results are sorted by best match. */ + sort?: "updated" | "created" | "comments"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search repositories. + * + * @name RepositoriesList + * @request GET:/search/repositories + * @response `200` `SwaggerTypeSearchRepositoriesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + repositoriesList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported repository + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the repository name, description, readme, + * or any combination of these. + * 'Size' Finds repositories that match a certain size (in kilobytes). + * 'Forks' Filters repositories based on the number of forks, and/or whether + * forked repositories should be included in the results at all. + * 'Created' and 'Last Updated' Filters repositories based on times of + * creation, or when they were last updated. + * 'Users or Repositories' Limits searches to a specific user or repository. + * 'Languages' Searches repositories based on the language they are written in. + * 'Stars' Searches repositories based on the number of stars. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "stars" | "forks" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/repositories`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Search users. + * + * @name UsersList + * @request GET:/search/users + * @response `200` `SwaggerTypeSearchUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + usersList: ( + query: { + /** The sort field. if sort param is provided. Can be either asc or desc. */ + order?: "desc" | "asc"; + /** + * The search terms. This can be any combination of the supported user + * search parameters: + * 'Search In' Qualifies which fields are searched. With this qualifier you + * can restrict the search to just the username, public email, full name, + * location, or any combination of these. + * 'Repository count' Filters users based on the number of repositories they + * have. + * 'Location' Filter users by the location indicated in their profile. + * 'Language' Search for users that have repositories that match a certain + * language. + * 'Created' Filter users based on when they joined. + * 'Followers' Filter users based on the number of followers they have. + * + */ + q: string; + /** If not provided, results are sorted by best match. */ + sort?: "followers" | "repositories" | "joined"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/search/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + }; + teams = { + /** + * @description Delete team. In order to delete a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsDelete + * @request DELETE:/teams/{teamId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsDelete: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team. + * + * @name TeamsDetail + * @request GET:/teams/{teamId} + * @response `200` `SwaggerTypeTeamGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Edit team. In order to edit a team, the authenticated user must be an owner of the org that the team is associated with. + * + * @name TeamsPartialUpdate + * @request PATCH:/teams/{teamId} + * @response `200` `SwaggerTypeTeamGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsPartialUpdate: (teamId: number, body: SwaggerTypeEditTeamGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description List team members. In order to list members in a team, the authenticated user must be a member of the team. + * + * @name MembersDetail + * @request GET:/teams/{teamId}/members + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + membersDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description The "Remove team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Remove team membership API instead. It allows you to remove both active and pending memberships. Remove team member. In order to remove a user from a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. NOTE This does not delete the user, it just remove them from the team. + * + * @name MembersDelete + * @request DELETE:/teams/{teamId}/members/{username} + * @deprecated + * @response `204` `void` Team member removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + membersDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description The "Get team member" API is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Get team membership API instead. It allows you to get both active and pending memberships. Get team member. In order to get if a user is a member of a team, the authenticated user mus be a member of the team. + * + * @name MembersDetail2 + * @request GET:/teams/{teamId}/members/{username} + * @deprecated + * @originalName membersDetail + * @duplicate + * @response `204` `void` User is a member. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` User is not a member. + */ + membersDetail2: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "GET", + ...params, + }), + + /** + * @description The API (described below) is deprecated and is scheduled for removal in the next major version of the API. We recommend using the Add team membership API instead. It allows you to invite new organization members to your teams. Add team member. In order to add a user to a team, the authenticated user must have 'admin' permissions to the team or be an owner of the org that the team is associated with. + * + * @name MembersUpdate + * @request PUT:/teams/{teamId}/members/{username} + * @deprecated + * @response `204` `void` Team member added. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `422` `SwaggerTypeOrganizationAsTeamMemberGeneratedDataContract` If you attempt to add an organization to a team, you will get this. + */ + membersUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/members/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description Remove team membership. In order to remove a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. NOTE: This does not delete the user, it just removes their membership from the team. + * + * @name MembershipsDelete + * @request DELETE:/teams/{teamId}/memberships/{username} + * @response `204` `void` Team member removed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + membershipsDelete: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get team membership. In order to get a user's membership with a team, the authenticated user must be a member of the team or an owner of the team's organization. + * + * @name MembershipsDetail + * @request GET:/teams/{teamId}/memberships/{username} + * @response `200` `SwaggerTypeTeamMembershipGeneratedDataContract` User is a member. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` User has no membership with team + */ + membershipsDetail: (teamId: number, username: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/memberships/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Add team membership. In order to add a membership between a user and a team, the authenticated user must have 'admin' permissions to the team or be an owner of the organization that the team is associated with. If the user is already a part of the team's organization (meaning they're on at least one other team in the organization), this endpoint will add the user to the team. If the user is completely unaffiliated with the team's organization (meaning they're on none of the organization's teams), this endpoint will send an invitation to the user via email. This newly-created membership will be in the 'pending' state until the user accepts the invitation, at which point the membership will transition to the 'active' state and the user will be added as a member of the team. + * + * @name MembershipsUpdate + * @request PUT:/teams/{teamId}/memberships/{username} + * @response `200` `SwaggerTypeTeamMembershipGeneratedDataContract` Team member added. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `422` `SwaggerTypeOrganizationAsTeamMemberGeneratedDataContract` If you attempt to add an organization to a team, you will get this. + */ + membershipsUpdate: (teamId: number, username: string, params: RequestParams = {}) => + this.request< + SwaggerTypeTeamMembershipGeneratedDataContract, + void | SwaggerTypeOrganizationAsTeamMemberGeneratedDataContract + >({ + path: `/teams/${teamId}/memberships/${username}`, + method: "PUT", + format: "json", + ...params, + }), + + /** + * @description List team repos + * + * @name ReposDetail + * @request GET:/teams/{teamId}/repos + * @response `200` `SwaggerTypeTeamReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail: (teamId: number, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description In order to remove a repository from a team, the authenticated user must be an owner of the org that the team is associated with. NOTE: This does not delete the repository, it just removes it from the team. + * + * @name ReposDelete + * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDelete: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if a team manages a repository + * + * @name ReposDetail2 + * @request GET:/teams/{teamId}/repos/{owner}/{repo} + * @originalName reposDetail + * @duplicate + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail2: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description In order to add a repository to a team, the authenticated user must be an owner of the org that the team is associated with. Also, the repository must be owned by the organization, or a direct fork of a repository owned by the organization. + * + * @name ReposUpdate + * @request PUT:/teams/{teamId}/repos/{owner}/{repo} + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposUpdate: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/teams/${teamId}/repos/${owner}/${repo}`, + method: "PUT", + ...params, + }), + }; + user = { + /** + * @description Get the authenticated user. + * + * @name UserList + * @request GET:/user + * @response `200` `SwaggerTypeUserGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + userList: (params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Update the authenticated user. + * + * @name UserPartialUpdate + * @request PATCH:/user + * @response `200` `SwaggerTypeUserGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + userPartialUpdate: (body: SwaggerTypeUserUpdateGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/user`, + method: "PATCH", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }), + + /** + * @description Delete email address(es). You can include a single email address or an array of addresses. + * + * @name EmailsDelete + * @request DELETE:/user/emails + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + emailsDelete: (body: SwaggerTypeUserEmailsGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "DELETE", + body: body, + type: ContentType.Json, + ...params, + }), + + /** + * @description List email addresses for a user. In the final version of the API, this method will return an array of hashes with extended information for each email address indicating if the address has been verified and if it's primary email address for GitHub. Until API v3 is finalized, use the application/vnd.github.v3 media type to get other response format. + * + * @name EmailsList + * @request GET:/user/emails + * @response `200` `SwaggerTypeUserEmailsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + emailsList: (params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "GET", + ...params, + }), + + /** + * @description Add email address(es). You can post a single email address or an array of addresses. + * + * @name EmailsCreate + * @request POST:/user/emails + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + emailsCreate: (body: SwaggerTypeEmailsPostGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/user/emails`, + method: "POST", + body: body, + ...params, + }), + + /** + * @description List the authenticated user's followers + * + * @name FollowersList + * @request GET:/user/followers + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + followersList: (params: RequestParams = {}) => + this.request({ + path: `/user/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List who the authenticated user is following. + * + * @name FollowingList + * @request GET:/user/following + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + followingList: (params: RequestParams = {}) => + this.request({ + path: `/user/following`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Unfollow a user. Unfollowing a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingDelete + * @request DELETE:/user/following/{username} + * @response `204` `void` User unfollowed. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + followingDelete: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are following a user. + * + * @name FollowingDetail + * @request GET:/user/following/{username} + * @response `204` `void` Response if you are following this user. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Response if you are not following this user. + */ + followingDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "GET", + ...params, + }), + + /** + * @description Follow a user. Following a user requires the user to be logged in and authenticated with basic auth or OAuth with the user:follow scope. + * + * @name FollowingUpdate + * @request PUT:/user/following/{username} + * @response `204` `void` You are now following the user. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + followingUpdate: (username: string, params: RequestParams = {}) => + this.request({ + path: `/user/following/${username}`, + method: "PUT", + ...params, + }), + + /** + * @description List issues. List all issues across owned and member repositories for the authenticated user. + * + * @name IssuesList + * @request GET:/user/issues + * @response `200` `SwaggerTypeIssuesGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + issuesList: ( + query: { + /** + * Issues assigned to you / created by you / mentioning you / you're + * subscribed to updates for / All issues the authenticated user can see + * + */ + filter: "assigned" | "created" | "mentioned" | "subscribed" | "all"; + state: "open" | "closed"; + /** String list of comma separated Label names. Example - bug,ui,@high. */ + labels: string; + sort: "created" | "updated" | "comments"; + 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({ + path: `/user/issues`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List your public keys. Lists the current user's keys. Management of public keys via the API requires that you are authenticated through basic auth, or OAuth with the 'user', 'write:public_key' scopes. + * + * @name KeysList + * @request GET:/user/keys + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysList: (params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Create a public key. + * + * @name KeysCreate + * @request POST:/user/keys + * @response `201` `SwaggerTypeUserKeysKeyIdGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysCreate: (body: SwaggerTypeUserKeysPostGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/user/keys`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description Delete a public key. Removes a public key. Requires that you are authenticated via Basic Auth or via OAuth with at least admin:public_key scope. + * + * @name KeysDelete + * @request DELETE:/user/keys/{keyId} + * @response `204` `void` No content. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDelete: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "DELETE", + ...params, + }), + + /** + * @description Get a single public key. + * + * @name KeysDetail + * @request GET:/user/keys/{keyId} + * @response `200` `SwaggerTypeUserKeysKeyIdGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDetail: (keyId: number, params: RequestParams = {}) => + this.request({ + path: `/user/keys/${keyId}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List public and private organizations for the authenticated user. + * + * @name OrgsList + * @request GET:/user/orgs + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + orgsList: (params: RequestParams = {}) => + this.request({ + path: `/user/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List repositories for the authenticated user. Note that this does not include repositories owned by organizations which the user can access. You can lis user organizations and list organization repositories separately. + * + * @name ReposList + * @request GET:/user/repos + * @response `200` `SwaggerTypeReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposList: ( + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Create a new repository for the authenticated user. OAuth users must supply repo scope. + * + * @name ReposCreate + * @request POST:/user/repos + * @response `201` `SwaggerTypeReposGeneratedDataContract` Created + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposCreate: (body: SwaggerTypePostRepoGeneratedDataContract, params: RequestParams = {}) => + this.request({ + path: `/user/repos`, + method: "POST", + body: body, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by the authenticated user. + * + * @name StarredList + * @request GET:/user/starred + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starredList: ( + query?: { + /** Ignored without 'sort' parameter. */ + direction?: string; + sort?: "created" | "updated"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/user/starred`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Unstar a repository + * + * @name StarredDelete + * @request DELETE:/user/starred/{owner}/{repo} + * @response `204` `void` Unstarred. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starredDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are starring a repository. + * + * @name StarredDetail + * @request GET:/user/starred/{owner}/{repo} + * @response `204` `void` This repository is starred by you. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` This repository is not starred by you. + */ + starredDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Star a repository. + * + * @name StarredUpdate + * @request PUT:/user/starred/{owner}/{repo} + * @response `204` `void` Repository starred. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starredUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/starred/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List repositories being watched by the authenticated user. + * + * @name SubscriptionsList + * @request GET:/user/subscriptions + * @response `200` `SwaggerTypeReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionsList: (params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Stop watching a repository + * + * @name SubscriptionsDelete + * @request DELETE:/user/subscriptions/{owner}/{repo} + * @deprecated + * @response `204` `void` Unwatched. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionsDelete: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "DELETE", + ...params, + }), + + /** + * @description Check if you are watching a repository. + * + * @name SubscriptionsDetail + * @request GET:/user/subscriptions/{owner}/{repo} + * @deprecated + * @response `204` `void` Repository is watched by you. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Repository is not watched by you. + */ + subscriptionsDetail: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "GET", + ...params, + }), + + /** + * @description Watch a repository. + * + * @name SubscriptionsUpdate + * @request PUT:/user/subscriptions/{owner}/{repo} + * @deprecated + * @response `204` `void` Repository is watched. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionsUpdate: (owner: string, repo: string, params: RequestParams = {}) => + this.request({ + path: `/user/subscriptions/${owner}/${repo}`, + method: "PUT", + ...params, + }), + + /** + * @description List all of the teams across all of the organizations to which the authenticated user belongs. This method requires user or repo scope when authenticating via OAuth. + * + * @name TeamsList + * @request GET:/user/teams + * @response `200` `SwaggerTypeTeamsListGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + teamsList: (params: RequestParams = {}) => + this.request({ + path: `/user/teams`, + method: "GET", + format: "json", + ...params, + }), + }; + users = { + /** + * @description Get all users. This provides a dump of every user, in the order that they signed up for GitHub. Note: Pagination is powered exclusively by the since parameter. Use the Link header to get the URL for the next page of users. + * + * @name UsersList + * @request GET:/users + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + usersList: ( + query?: { + /** The integer ID of the last user that you've seen. */ + since?: number; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description Get a single user. + * + * @name UsersDetail + * @request GET:/users/{username} + * @response `200` `SwaggerTypeUserGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + usersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. + * + * @name EventsDetail + * @request GET:/users/{username}/events + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events`, + method: "GET", + ...params, + }), + + /** + * @description This is the user's organization dashboard. You must be authenticated as the user to view this. + * + * @name EventsOrgsDetail + * @request GET:/users/{username}/events/orgs/{org} + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + eventsOrgsDetail: (username: string, org: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/events/orgs/${org}`, + method: "GET", + ...params, + }), + + /** + * @description List a user's followers + * + * @name FollowersDetail + * @request GET:/users/{username}/followers + * @response `200` `SwaggerTypeUsersGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + followersDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/followers`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description Check if one user follows another. + * + * @name FollowingDetail + * @request GET:/users/{username}/following/{targetUser} + * @response `204` `void` Response if user follows target user. + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + * @response `404` `void` Response if user does not follow target user. + */ + followingDetail: (username: string, targetUser: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/following/${targetUser}`, + method: "GET", + ...params, + }), + + /** + * @description List a users gists. + * + * @name GistsDetail + * @request GET:/users/{username}/gists + * @response `200` `SwaggerTypeGistsGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + gistsDetail: ( + username: 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; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/gists`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List public keys for a user. Lists the verified public keys for a user. This is accessible by anyone. + * + * @name KeysDetail + * @request GET:/users/{username}/keys + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + keysDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/keys`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description List all public organizations for a user. + * + * @name OrgsDetail + * @request GET:/users/{username}/orgs + * @response `200` `SwaggerTypeGitignoreGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + orgsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/orgs`, + method: "GET", + format: "json", + ...params, + }), + + /** + * @description These are events that you'll only see public events. + * + * @name ReceivedEventsDetail + * @request GET:/users/{username}/received_events + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + receivedEventsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events`, + method: "GET", + ...params, + }), + + /** + * @description List public events that a user has received + * + * @name ReceivedEventsPublicDetail + * @request GET:/users/{username}/received_events/public + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + receivedEventsPublicDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/received_events/public`, + method: "GET", + ...params, + }), + + /** + * @description List public repositories for the specified user. + * + * @name ReposDetail + * @request GET:/users/{username}/repos + * @response `200` `SwaggerTypeReposGeneratedDataContract` OK + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + reposDetail: ( + username: string, + query?: { + type?: "all" | "public" | "private" | "forks" | "sources" | "member"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/users/${username}/repos`, + method: "GET", + query: query, + format: "json", + ...params, + }), + + /** + * @description List repositories being starred by a user. + * + * @name StarredDetail + * @request GET:/users/{username}/starred + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + starredDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/starred`, + method: "GET", + ...params, + }), + + /** + * @description List repositories being watched by a user. + * + * @name SubscriptionsDetail + * @request GET:/users/{username}/subscriptions + * @response `403` `void` API rate limit exceeded. See http://developer.github.com/v3/#rate-limiting for details. + */ + subscriptionsDetail: (username: string, params: RequestParams = {}) => + this.request({ + path: `/users/${username}/subscriptions`, + method: "GET", + ...params, + }), + }; +} diff --git a/tests/spec/typeSuffixPrefix/schema.ts b/tests/spec/typeSuffixPrefix/schema.ts index c1ef6ca7..706112be 100644 --- a/tests/spec/typeSuffixPrefix/schema.ts +++ b/tests/spec/typeSuffixPrefix/schema.ts @@ -2126,7 +2126,7 @@ export class Api extends HttpClient { generateClient: true, generateResponses: true, }).then((output) => { - const content = _.split(output.files[0].content, "\n"); - const reservedTypes = [ - "QueryParamsType", - "ResponseFormat", - "FullRequestParams", - "RequestParams", - "ApiConfig", - "HttpResponse", - ]; - - for (const line of content) { - if (_.startsWith(line, "export interface") || _.startsWith(line, "export type")) { - const typeName = _.split(_.split(line, " ")[2], "<")[0] || ""; - - if (!_.includes(reservedTypes, typeName)) { - if ( - !_.startsWith(typeName, "SwaggerType") || - !_.endsWith(typeName, "GeneratedDataContract") - ) { - throw new Exception( - `Not at all data contracts have type prefix and type suffix`, - `\n${content.indexOf(line) + 1}: ${line} ->`, - `\n ${typeName} <-`, - ); - } - } - } - } - validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); }); diff --git a/tests/spec/unionEnums/expected.ts b/tests/spec/unionEnums/expected.ts new file mode 100644 index 00000000..334e0277 --- /dev/null +++ b/tests/spec/unionEnums/expected.ts @@ -0,0 +1,236 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export type StringEnum = "String1" | "String2" | "String3" | "String4"; + +export type NumberEnum = 1 | 2 | 3 | 4; + +export type BooleanEnum = true | false; + +/** + * FooBar + * @format int32 + */ +export type IntEnumWithNames = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: ResponseFormat; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType | null) => Promise | RequestParams | void; + customFetch?: typeof fetch; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +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 = "http://localhost:8080/api/v1"; + private securityData: SecurityDataType | null = null; + private securityWorker?: ApiConfig["securityWorker"]; + private abortControllers = new Map(); + private customFetch = (...fetchParams: Parameters) => fetch(...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 encodeQueryParam(key: string, value: any) { + const encodedKey = encodeURIComponent(key); + return `${encodedKey}=${encodeURIComponent(typeof value === "number" ? value : `${value}`)}`; + } + + protected addQueryParam(query: QueryParamsType, key: string) { + return this.encodeQueryParam(key, query[key]); + } + + protected addArrayQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + return value.map((v: any) => this.encodeQueryParam(key, v)).join("&"); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => (Array.isArray(query[key]) ? this.addArrayQueryParam(query, key) : this.addQueryParam(query, key))) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((formData, key) => { + const property = input[key]; + formData.append( + key, + property instanceof Blob + ? property + : typeof property === "object" && property !== null + ? JSON.stringify(property) + : `${property}`, + ); + return formData; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + 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 ({ + body, + secure, + path, + type, + query, + format, + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = + ((typeof secure === "boolean" ? secure : this.baseApiParams.secure) && + this.securityWorker && + (await this.securityWorker(this.securityData))) || + {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + const responseFormat = format || requestParams.format; + + return this.customFetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(requestParams.headers || {}), + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : requestParams.signal, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = null as unknown as T; + r.error = null as unknown as E; + + const data = !responseFormat + ? r + : await response[responseFormat]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title No title + * @baseUrl http://localhost:8080/api/v1 + */ +export class Api extends HttpClient {} diff --git a/tests/spec/unionEnums/test.js b/tests/spec/unionEnums/test.js index 6db4d913..8f11b56c 100644 --- a/tests/spec/unionEnums/test.js +++ b/tests/spec/unionEnums/test.js @@ -2,6 +2,7 @@ const { generateApiForTest } = require("../../helpers/generateApiForTest"); const { resolve } = require("path"); const validateGeneratedModule = require("../../helpers/validateGeneratedModule"); const createSchemaInfos = require("../../helpers/createSchemaInfos"); +const assertGeneratedModule = require("../../helpers/assertGeneratedModule"); const schemas = createSchemaInfos({ absolutePathToSchemas: resolve(__dirname, "./") }); @@ -15,5 +16,6 @@ schemas.forEach(({ absolutePath, apiFileName }) => { generateUnionEnums: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); + assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); }); });