diff --git a/.vscode/launch.json b/.vscode/launch.json index a89367f3..359e9934 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,13 +5,22 @@ "version": "0.2.0", "configurations": [ { - "name": "Launch via npm", + "name": "Debug generate", "type": "node", "request": "launch", "cwd": "${workspaceFolder}", "runtimeExecutable": "npm", "runtimeArgs": ["run-script", "generate:debug"], "port": 9229 + }, + { + "name": "Debug CLI", + "type": "node", + "request": "launch", + "cwd": "${workspaceFolder}", + "runtimeExecutable": "npm", + "runtimeArgs": ["run-script", "cli:debug"], + "port": 9229 } ] } \ No newline at end of file diff --git a/package.json b/package.json index fb5a4bcf..aeb70815 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "description": "Create typescript api module from swagger schema", "scripts": { "cli": "node index.js -p ./tests/schemas/v3.0/personal-api-example.json -n swagger-test-cli.ts", + "cli:debug": "node --nolazy --inspect-brk=9229 index.js -p ./tests/schemas/v2.0/adafruit.yaml -n swagger-test-cli.ts", "cli:help": "node index.js -h", "test:all": "npm-run-all generate validate test:routeTypes test:noClient --continue-on-error", "generate": "node tests/generate.js", diff --git a/src/components.js b/src/components.js new file mode 100644 index 00000000..172d538e --- /dev/null +++ b/src/components.js @@ -0,0 +1,60 @@ +const _ = require("lodash"); +const { parseSchema } = require("./schema"); +const { addToConfig } = require("./config"); + +/** + * + * @typedef TypeInfo + * { + * typeName: "Foo", + * componentName: "schemas", + * rawTypeData: {...}, + * typeData: {...} (result parseSchema()) + * } + */ + +/** + * @returns {{ "#/components/schemas/Foo": TypeInfo, ... }} + */ +const createComponentsMap = components => { + const componentsMap = _.reduce(components, (map, component, componentName) => { + _.each(component, (rawTypeData, typeName) => { + // only map data for now + map[`#/components/${componentName}/${typeName}`] = { + typeName, + rawTypeData, + componentName, + typeData: null, + } + }) + return map; + }, {}) + + addToConfig({ componentsMap }) + + return componentsMap; +} + + + +/** + * @returns {TypeInfo[]} + */ +const filterComponentsMap = (componentsMap, componentName) => + _.filter(componentsMap, (v, ref) => _.startsWith(ref, `#/components/${componentName}`)) + + +/** @returns {{ type, typeIdentifier, name, description, content }} */ +const getTypeData = typeInfo => { + if (!typeInfo.typeData) { + typeInfo.typeData = parseSchema(typeInfo.rawTypeData, typeInfo.typeName) + } + + return typeInfo.typeData; +} + +module.exports = { + getTypeData, + createComponentsMap, + filterComponentsMap, +} \ No newline at end of file diff --git a/src/config.js b/src/config.js new file mode 100644 index 00000000..4777b16d --- /dev/null +++ b/src/config.js @@ -0,0 +1,17 @@ + +const config = { + /** CLI flag */ + generateRouteTypes: false, + /** CLI flag */ + generateClient: true, + /** parsed swagger schema from getSwaggerObject() */ + swaggerSchema: null, + /** { "#/components/schemas/Foo": @TypeInfo, ... } */ + componentsMap: {}, +} + +/** needs to use data everywhere in project */ +module.exports = { + addToConfig: configParts => Object.assign(config, configParts), + config, +} \ No newline at end of file diff --git a/src/files.js b/src/files.js new file mode 100644 index 00000000..dc6fb783 --- /dev/null +++ b/src/files.js @@ -0,0 +1,22 @@ +const _ = require("lodash"); +const fs = require("fs"); +const { resolve } = require("path"); + +const getFileContent = path => + fs.readFileSync(path, { encoding: 'UTF-8' }) + +const pathIsExist = path => + path && fs.existsSync(path) + +const createFile = (pathTo, fileName, content) => + fs.writeFileSync(resolve(__dirname, pathTo, `./${fileName}`), content, _.noop) + +const getTemplate = templateName => + getFileContent(resolve(__dirname, `./templates/${templateName}.mustache`)) + +module.exports = { + getTemplate, + createFile, + pathIsExist, + getFileContent, +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index d70d0c0d..843f127e 100644 --- a/src/index.js +++ b/src/index.js @@ -1,12 +1,13 @@ const mustache = require("mustache"); const _ = require("lodash"); -const fs = require("fs"); -const path = require("path"); -const { parseSchema } = require('./schema'); +const { parseSchemas } = require('./schema'); const { parseRoutes, groupRoutes } = require('./routes'); const { createApiConfig } = require('./apiConfig'); const { getModelType } = require('./modelTypes'); const { getSwaggerObject } = require('./swagger'); +const { createComponentsMap, filterComponentsMap } = require("./components"); +const { getTemplate, createFile, pathIsExist } = require('./files'); +const { addToConfig, config: defaults } = require("./config"); mustache.escape = value => value @@ -16,25 +17,34 @@ module.exports = { output, url, name, - generateRouteTypes = true, - generateClient = true, + generateRouteTypes = defaults.generateRouteTypes, + generateClient = defaults.generateClient, }) => new Promise((resolve, reject) => { - getSwaggerObject(input, url).then(({ info, paths, servers, components }) => { + addToConfig({ + generateRouteTypes, + generateClient, + }) + getSwaggerObject(input, url).then(swaggerSchema => { + addToConfig({ swaggerSchema }); + const { info, paths, servers, components } = swaggerSchema; console.log('☄️ start generating your typescript api') - const apiTemplate = fs.readFileSync(path.resolve(__dirname, './templates/api.mustache'), 'utf-8'); - const clientTemplate = fs.readFileSync(path.resolve(__dirname, './templates/client.mustache'), 'utf-8'); - const routeTypesTemplate = fs.readFileSync(path.resolve(__dirname, './templates/route-types.mustache'), 'utf-8'); + const apiTemplate = getTemplate('api'); + const clientTemplate = getTemplate('client'); + const routeTypesTemplate = getTemplate('route-types'); + + const componentsMap = createComponentsMap(components); + const schemasMap = filterComponentsMap(componentsMap, "schemas") - const parsedSchemas = _.map(_.get(components, "schemas"), parseSchema) - const routes = parseRoutes(paths, parsedSchemas, components); + const parsedSchemas = parseSchemas(components); + const routes = parseRoutes(swaggerSchema, parsedSchemas, componentsMap, components); const hasSecurityRoutes = routes.some(route => route.security); const hasQueryRoutes = routes.some(route => route.hasQuery); const apiConfig = createApiConfig({ info, servers }, hasSecurityRoutes); const configuration = { apiConfig, - modelTypes: _.map(parsedSchemas, getModelType), + modelTypes: _.map(schemasMap, getModelType), hasSecurityRoutes, hasQueryRoutes, routes: groupRoutes(routes), @@ -46,8 +56,8 @@ module.exports = { generateClient ? mustache.render(clientTemplate, configuration) : '', ].join(''); - if (output && fs.existsSync(output)) { - fs.writeFileSync(path.resolve(__dirname, output, `./${name}`), sourceFile, _.noop) + if (pathIsExist(output)) { + createFile(output, name, sourceFile); console.log(`✔️ your typescript api file created in "${output}"`) } diff --git a/src/modelTypes.js b/src/modelTypes.js index 3834085f..32aae35c 100644 --- a/src/modelTypes.js +++ b/src/modelTypes.js @@ -1,6 +1,7 @@ const _ = require('lodash'); const { formatters } = require("./typeFormatters"); const { checkAndRenameModelName } = require("./modelNames"); +const { getTypeData } = require('./components'); const CONTENT_KEYWORD = '__CONTENT__'; @@ -10,8 +11,9 @@ const contentWrapersByTypeIdentifier = { 'type': `= ${CONTENT_KEYWORD}`, } -// { typeIdentifier, name, content, type } -const getModelType = ({ typeIdentifier, name: originalName, content, type, description }) => { +const getModelType = typeInfo => { + const { typeIdentifier, name: originalName, content, type, description } = getTypeData(typeInfo); + if (!contentWrapersByTypeIdentifier[typeIdentifier]) { throw new Error(`${typeIdentifier} - type identifier is unknown for this utility`) } diff --git a/src/routes.js b/src/routes.js index 8447f13c..ba56432c 100644 --- a/src/routes.js +++ b/src/routes.js @@ -2,6 +2,7 @@ const _ = require("lodash"); const { collect } = require("./utils"); const { parseSchema, getRefType } = require("./schema"); const { checkAndRenameModelName } = require("./modelNames"); +const { getTypeData, typeInfoIsIn } = require("./components"); const { inlineExtraFormatters } = require("./typeFormatters"); const methodAliases = { @@ -12,10 +13,21 @@ const methodAliases = { delete: (pathName, hasPathInserts) => _.camelCase(`${pathName}_delete`) } +const getSchemaFromRequestType = requestType => { + const content = _.get(requestType, "content") + + if (!content) return null; + + const contentByType = _.find(content, contentByType => contentByType.schema); + + return contentByType && contentByType.schema; +} + const getTypeFromRequestInfo = (requestInfo, parsedSchemas, operationId, contentType) => { // TODO: make more flexible pick schema without content type - const schema = _.get(requestInfo, `content["${contentType}"].schema`); - const refType = getRefType(requestInfo); + const schema = getSchemaFromRequestType(requestInfo); + // const refType = getRefTypeName(requestInfo); + const refTypeInfo = getRefType(requestInfo); if (schema) { const extractedSchema = _.get(schema, 'additionalProperties', schema); @@ -28,11 +40,24 @@ const getTypeFromRequestInfo = (requestInfo, parsedSchemas, operationId, content return checkAndRenameModelName(foundSchema ? foundSchema.name : content); } - if (refType) { - // TODO: its temp solution because sometimes `swagger2openapi` create refs as operationId + name - const refTypeWithoutOpId = refType.replace(operationId, ''); - const foundedSchemaByName = _.find(parsedSchemas, ({ name }) => name === refType || name === refTypeWithoutOpId) - return foundedSchemaByName && foundedSchemaByName.name ? checkAndRenameModelName(foundedSchemaByName.name) : 'any' + if (refTypeInfo) { + // const refTypeWithoutOpId = refType.replace(operationId, ''); + // const foundedSchemaByName = _.find(parsedSchemas, ({ name }) => name === refType || name === refTypeWithoutOpId) + + // TODO:HACK fix problem of swagger2opeanpi + const typeNameWithoutOpId = _.replace(refTypeInfo.typeName, operationId, '') + if (_.find(parsedSchemas, schema => schema.name === typeNameWithoutOpId)) + return checkAndRenameModelName(typeNameWithoutOpId); + + switch (refTypeInfo.componentName) { + case "schemas": + return checkAndRenameModelName(refTypeInfo.typeName); + case "responses": + case "requestBodies": + return parseSchema(getSchemaFromRequestType(refTypeInfo.rawTypeData), 'none', inlineExtraFormatters).content + default: + return parseSchema(refTypeInfo.rawTypeData, 'none', inlineExtraFormatters).content + } } return 'any'; @@ -55,10 +80,9 @@ const getRouteName = (operationId, method, route, moduleName) => { return createCustomOperationId(method, route, moduleName); } -const parseRoutes = (routes, parsedSchemas, components) => - _.entries(routes) +const parseRoutes = ({ paths }, parsedSchemas) => + _.entries(paths) .reduce((routes, [route, requestInfoByMethodsMap]) => { - const globalParametersMap = _.get(components, "parameters", {}); parameters = _.get(requestInfoByMethodsMap, 'parameters'); // TODO: refactor that hell @@ -90,16 +114,14 @@ const parseRoutes = (routes, parsedSchemas, components) => const pathParams = collect(parameters, parameter => { if (parameter.in === 'path') return parameter; - const refTypeName = getRefType(parameter); - const globalParam = refTypeName && globalParametersMap[refTypeName] - return globalParam && globalParametersMap[refTypeName].in === "path" && globalParam + const refTypeInfo = getRefType(parameter); + return refTypeInfo && refTypeInfo.rawTypeData.in === "path" && refTypeInfo.rawTypeData }) const queryParams = collect(parameters, parameter => { if (parameter.in === 'query') return parameter; - const refTypeName = getRefType(parameter); - const globalParam = refTypeName && globalParametersMap[refTypeName] - return globalParam && globalParametersMap[refTypeName].in === "query" && globalParam; + const refTypeInfo = getRefType(parameter); + return refTypeInfo && refTypeInfo.rawTypeData.in === "query" && refTypeInfo.rawTypeData }) const moduleName = _.camelCase(route.split('/').filter(Boolean)[0]); diff --git a/src/schema.js b/src/schema.js index 5666070b..93442ca1 100644 --- a/src/schema.js +++ b/src/schema.js @@ -1,22 +1,31 @@ const _ = require("lodash"); const { inlineExtraFormatters } = require("./typeFormatters"); -const { isValidName } = require("./modelNames") +const { isValidName } = require("./modelNames"); +const { checkAndRenameModelName } = require("./modelNames"); +const { config } = require("./config"); + const jsTypes = ['number', 'boolean', 'string', 'object']; const jsEmptyTypes = ['null', 'undefined']; +const typeAliases = { + "integer": "number", +} const findSchemaType = schema => { - if (schema.enum) return 'enum'; - if (schema.properties) return 'object'; - if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) { - return 'complex' - } + if (schema.enum) + return 'enum'; + if (schema.properties) + return 'object'; + if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) + return 'complex'; + return 'primitive'; } -const typeAliases = { - "integer": "number", + +const getPrimitiveType = property => { + const type = _.get(property, "type") + return typeAliases[type] || type || 'any' } -const getPrimitiveType = type => typeAliases[type] || type || 'any' const specificObjectTypes = { 'array': ({ items }) => { @@ -25,53 +34,61 @@ const specificObjectTypes = { } } -const getRefType = (property) => { - if (!property || !property["$ref"]) return null; - return _.last(_.split(property["$ref"], '/')); +const getRefType = property => { + const ref = property && property["$ref"] + return (ref && config.componentsMap[ref]) || null; +} + +const getRefTypeName = property => { + const refTypeInfo = getRefType(property); + return refTypeInfo && checkAndRenameModelName(refTypeInfo.typeName); } -const getType = (property) => { - const func = specificObjectTypes[property.type] || (() => getPrimitiveType(property.type)) - return getRefType(property) || func(property) +const getType = property => { + const anotherTypeGetter = specificObjectTypes[property.type] || getPrimitiveType + return getRefTypeName(property) || anotherTypeGetter(property) } -const getObjectTypeContent = (properties) => { + +const getObjectTypeContent = properties => { return _.map(properties, (property, name) => { + // TODO: probably nullable should'n be use as required/no-required conditions const isRequired = typeof property.nullable === "undefined" ? property.required : !property.nullable return { description: property.description, - field: `${isValidName(name) ? name : `"${name}"`}${isRequired ? '' : '?'}: ${parseSchema(property, null, inlineExtraFormatters).content}`, + field: `${isValidName(name) ? name : `"${name}"`}${isRequired ? '' : '?'}: ${getInlineParseContent(property)}`, } }) } - -const complexTypeGetter = ({description, ...schema}) => parseSchema(schema, null, inlineExtraFormatters).content +const complexTypeGetter = ({ description, ...schema }) => getInlineParseContent(schema) const complexSchemaParsers = { - 'oneOf': (schema) => { + 'oneOf': schema => { // T1 | T2 const combined = _.map(schema.oneOf, complexTypeGetter); return combined.join(' | '); }, - 'allOf': (schema) => { + 'allOf': schema => { // T1 & T2 return _.map(schema.allOf, complexTypeGetter).join(' & ') }, - 'anyOf': (schema) => { + 'anyOf': schema => { // T1 | T2 | (T1 & T2) const combined = _.map(schema.anyOf, complexTypeGetter); return `${combined.join(' | ')}` + (combined.length > 1 ? ` | (${combined.join(' & ')})` : ''); }, // TODO - 'not': (schema) => { + 'not': schema => { // TODO } } -const getComplexType = (schema) => { +const getComplexType = schema => { if (schema.oneOf) return 'oneOf'; if (schema.allOf) return 'allOf'; if (schema.anyOf) return 'anyOf'; + + // TODO :( if (schema.not) return 'not'; throw new Error("Uknown complex type") @@ -79,7 +96,7 @@ const getComplexType = (schema) => { const schemaParsers = { 'enum': (schema, typeName) => { - const type = getPrimitiveType(schema.type); + const type = getPrimitiveType(schema); const isIntegerEnum = type === "number"; return { type: isIntegerEnum ? "intEnum" : 'enum', @@ -132,16 +149,24 @@ const schemaParsers = { } } -// { typeIdentifier, name, content }[] -const parseSchema = (schema, typeName, formattersMap) => { - const schemaType = findSchemaType(schema); - const parsedSchema = schemaParsers[schemaType](schema, typeName); +/** @returns {{ type, typeIdentifier, name, description, content }} */ +const parseSchema = (rawTypeData, typeName, formattersMap) => { + const schemaType = findSchemaType(rawTypeData); + const parsedSchema = schemaParsers[schemaType](rawTypeData, typeName); return (formattersMap && formattersMap[schemaType] && formattersMap[schemaType](parsedSchema)) || parsedSchema } +const parseSchemas = components => + _.map(_.get(components, "schemas"), (schema, typeName) => parseSchema(schema, typeName)) + +const getInlineParseContent = rawTypeData => + parseSchema(rawTypeData, null, inlineExtraFormatters).content + module.exports = { parseSchema, + parseSchemas, + getInlineParseContent, getType, + getRefTypeName, getRefType, - getPrimitiveType, } \ No newline at end of file diff --git a/src/swagger.js b/src/swagger.js index 8e27c21d..69c9f496 100644 --- a/src/swagger.js +++ b/src/swagger.js @@ -1,8 +1,8 @@ const _ = require('lodash'); -const fs = require("fs"); const yaml = require('js-yaml'); const axios = require("axios"); const converter = require('swagger2openapi'); +const { pathIsExist, getFileContent } = require("./files"); const parseSwaggerFile = (file) => { if (typeof file !== "string") return file; @@ -15,10 +15,9 @@ const parseSwaggerFile = (file) => { } const getSwaggerFile = (pathToSwagger, urlToSwagger) => new Promise((resolve) => { - if (pathToSwagger && fs.existsSync(pathToSwagger)){ + if (pathIsExist(pathToSwagger)){ console.log(`✨ try to get swagger by path "${pathToSwagger}"`) - const file = fs.readFileSync(pathToSwagger, { encoding: 'UTF-8' }) - resolve(file) + resolve(getFileContent(pathToSwagger)) } else { console.log(`✨ try to get swagger by url "${urlToSwagger}"`) axios.get(urlToSwagger).then(res => resolve(res.data)) @@ -26,7 +25,7 @@ const getSwaggerFile = (pathToSwagger, urlToSwagger) => new Promise((resolve) => }) const getSwaggerObject = (pathToSwagger, urlToSwagger) => - new Promise((resolve) => + new Promise(resolve => getSwaggerFile(pathToSwagger, urlToSwagger).then(file => { const swaggerSchema = parseSwaggerFile(file); if (!(swaggerSchema.openapi)) { diff --git a/tests/generated/v2.0/adafruit.ts b/tests/generated/v2.0/adafruit.ts index b3e93b91..c0f63cb4 100644 --- a/tests/generated/v2.0/adafruit.ts +++ b/tests/generated/v2.0/adafruit.ts @@ -509,7 +509,7 @@ export class Api { * @summary Update properties of an existing Block * @request PATCH:/{username}/dashboards/{dashboard_id}/blocks/{id} */ - updateBlock: (username: string, dashboard_id: string, id: string, block: any, params?: RequestParams) => + updateBlock: (username: string, dashboard_id: string, id: string, block: { block_feeds?: Array<{ feed_id?: string, group_id?: string }>, column?: number, dashboard_id?: number, description?: string, key?: string, name?: string, properties?: object, row?: number, size_x?: number, size_y?: number, visual_type?: string }, params?: RequestParams) => this.request(`/${username}/dashboards/${dashboard_id}/blocks/${id}`, "PATCH", params, block), @@ -519,7 +519,7 @@ export class Api { * @summary Replace an existing Block * @request PUT:/{username}/dashboards/{dashboard_id}/blocks/{id} */ - replaceBlock: (username: string, dashboard_id: string, id: string, block: any, params?: RequestParams) => + replaceBlock: (username: string, dashboard_id: string, id: string, block: { block_feeds?: Array<{ feed_id?: string, group_id?: string }>, column?: number, dashboard_id?: number, description?: string, key?: string, name?: string, properties?: object, row?: number, size_x?: number, size_y?: number, visual_type?: string }, params?: RequestParams) => this.request(`/${username}/dashboards/${dashboard_id}/blocks/${id}`, "PUT", params, block), @@ -549,7 +549,7 @@ export class Api { * @summary Update properties of an existing Dashboard * @request PATCH:/{username}/dashboards/{id} */ - updateDashboard: (username: string, id: string, dashboard: any, params?: RequestParams) => + updateDashboard: (username: string, id: string, dashboard: { description?: string, key?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/dashboards/${id}`, "PATCH", params, dashboard), @@ -559,7 +559,7 @@ export class Api { * @summary Replace an existing Dashboard * @request PUT:/{username}/dashboards/{id} */ - replaceDashboard: (username: string, id: string, dashboard: any, params?: RequestParams) => + replaceDashboard: (username: string, id: string, dashboard: { description?: string, key?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/dashboards/${id}`, "PUT", params, dashboard), @@ -611,7 +611,7 @@ export class Api { * @summary Update properties of an existing Feed * @request PATCH:/{username}/feeds/{feed_key} */ - updateFeed: (username: string, feed_key: string, feed: any, params?: RequestParams) => + updateFeed: (username: string, feed_key: string, feed: { description?: string, key?: string, license?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/feeds/${feed_key}`, "PATCH", params, feed), @@ -621,7 +621,7 @@ export class Api { * @summary Replace an existing Feed * @request PUT:/{username}/feeds/{feed_key} */ - replaceFeed: (username: string, feed_key: string, feed: any, params?: RequestParams) => + replaceFeed: (username: string, feed_key: string, feed: { description?: string, key?: string, license?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/feeds/${feed_key}`, "PUT", params, feed), @@ -642,7 +642,7 @@ export class Api { * @request POST:/{username}/feeds/{feed_key}/data * @description Create new data records on the given feed.. . **NOTE:** when feed history is on, data `value` size is limited to 1KB, when feed history is turned off data value size is limited to 100KB. */ - createData: (username: string, feed_key: string, datum: any, params?: RequestParams) => + createData: (username: string, feed_key: string, datum: { created_at?: string, ele?: string, epoch?: number, lat?: string, lon?: string, value?: string }, params?: RequestParams) => this.request(`/${username}/feeds/${feed_key}/data`, "POST", params, datum), @@ -719,7 +719,7 @@ export class Api { * @description Get the most recent data point in the feed in an MQTT compatible CSV format: `value,lat,lon,ele` */ retainData: (username: string, feed_key: string, params?: RequestParams) => - this.request(`/${username}/feeds/${feed_key}/data/retain`, "GET", params, null), + this.request(`/${username}/feeds/${feed_key}/data/retain`, "GET", params, null), /** @@ -748,7 +748,7 @@ export class Api { * @summary Update properties of existing Data * @request PATCH:/{username}/feeds/{feed_key}/data/{id} */ - updateData: (username: string, feed_key: string, id: string, datum: any, params?: RequestParams) => + updateData: (username: string, feed_key: string, id: string, datum: { created_at?: string, ele?: string, epoch?: number, lat?: string, lon?: string, value?: string }, params?: RequestParams) => this.request(`/${username}/feeds/${feed_key}/data/${id}`, "PATCH", params, datum), @@ -758,7 +758,7 @@ export class Api { * @summary Replace existing Data * @request PUT:/{username}/feeds/{feed_key}/data/{id} */ - replaceData: (username: string, feed_key: string, id: string, datum: any, params?: RequestParams) => + replaceData: (username: string, feed_key: string, id: string, datum: { created_at?: string, ele?: string, epoch?: number, lat?: string, lon?: string, value?: string }, params?: RequestParams) => this.request(`/${username}/feeds/${feed_key}/data/${id}`, "PUT", params, datum), @@ -820,7 +820,7 @@ export class Api { * @summary Update properties of an existing Group * @request PATCH:/{username}/groups/{group_key} */ - updateGroup: (username: string, group_key: string, group: any, params?: RequestParams) => + updateGroup: (username: string, group_key: string, group: { description?: string, key?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/groups/${group_key}`, "PATCH", params, group), @@ -830,7 +830,7 @@ export class Api { * @summary Replace an existing Group * @request PUT:/{username}/groups/{group_key} */ - replaceGroup: (username: string, group_key: string, group: any, params?: RequestParams) => + replaceGroup: (username: string, group_key: string, group: { description?: string, key?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/groups/${group_key}`, "PUT", params, group), @@ -871,7 +871,7 @@ export class Api { * @summary Create a new Feed in a Group * @request POST:/{username}/groups/{group_key}/feeds */ - createGroupFeed: (username: string, group_key: string, feed: any, params?: RequestParams) => + createGroupFeed: (username: string, group_key: string, feed: { description?: string, key?: string, license?: string, name?: string }, params?: RequestParams) => this.request(`/${username}/groups/${group_key}/feeds`, "POST", params, feed), @@ -891,7 +891,7 @@ export class Api { * @summary Create new Data in a feed belonging to a particular group * @request POST:/{username}/groups/{group_key}/feeds/{feed_key}/data */ - createGroupFeedData: (username: string, group_key: string, feed_key: string, datum: any, params?: RequestParams) => + createGroupFeedData: (username: string, group_key: string, feed_key: string, datum: { created_at?: string, ele?: string, epoch?: number, lat?: string, lon?: string, value?: string }, params?: RequestParams) => this.request(`/${username}/groups/${group_key}/feeds/${feed_key}/data`, "POST", params, datum), @@ -901,7 +901,7 @@ export class Api { * @summary Create multiple new Data records in a feed belonging to a particular group * @request POST:/{username}/groups/{group_key}/feeds/{feed_key}/data/batch */ - batchCreateGroupFeedData: (username: string, group_key: string, feed_key: string, data: any, params?: RequestParams) => + batchCreateGroupFeedData: (username: string, group_key: string, feed_key: string, data: Array<{ created_at?: string, ele?: string, epoch?: number, lat?: string, lon?: string, value?: string }>, params?: RequestParams) => this.request(`/${username}/groups/${group_key}/feeds/${feed_key}/data/batch`, "POST", params, data), @@ -972,7 +972,7 @@ export class Api { * @summary Update properties of an existing Token * @request PATCH:/{username}/tokens/{id} */ - updateToken: (username: string, id: string, token: any, params?: RequestParams) => + updateToken: (username: string, id: string, token: { token?: string }, params?: RequestParams) => this.request(`/${username}/tokens/${id}`, "PATCH", params, token), @@ -982,7 +982,7 @@ export class Api { * @summary Replace an existing Token * @request PUT:/{username}/tokens/{id} */ - replaceToken: (username: string, id: string, token: any, params?: RequestParams) => + replaceToken: (username: string, id: string, token: { token?: string }, params?: RequestParams) => this.request(`/${username}/tokens/${id}`, "PUT", params, token), @@ -1033,7 +1033,7 @@ export class Api { * @summary Update properties of an existing Trigger * @request PATCH:/{username}/triggers/{id} */ - updateTrigger: (username: string, id: string, trigger: any, params?: RequestParams) => + updateTrigger: (username: string, id: string, trigger: { name?: string }, params?: RequestParams) => this.request(`/${username}/triggers/${id}`, "PATCH", params, trigger), @@ -1043,7 +1043,7 @@ export class Api { * @summary Replace an existing Trigger * @request PUT:/{username}/triggers/{id} */ - replaceTrigger: (username: string, id: string, trigger: any, params?: RequestParams) => + replaceTrigger: (username: string, id: string, trigger: { name?: string }, params?: RequestParams) => this.request(`/${username}/triggers/${id}`, "PUT", params, trigger), @@ -1094,7 +1094,7 @@ export class Api { * @summary Update properties of an existing Permission * @request PATCH:/{username}/{type}/{type_id}/acl/{id} */ - updatePermission: (username: string, type: string, type_id: string, id: string, permission: any, params?: RequestParams) => + updatePermission: (username: string, type: string, type_id: string, id: string, permission: { mode?: "r" | "w" | "rw", scope?: "secret" | "public" | "user" | "organization", scope_value?: string }, params?: RequestParams) => this.request(`/${username}/${type}/${type_id}/acl/${id}`, "PATCH", params, permission), @@ -1104,7 +1104,7 @@ export class Api { * @summary Replace an existing Permission * @request PUT:/{username}/{type}/{type_id}/acl/{id} */ - replacePermission: (username: string, type: string, type_id: string, id: string, permission: any, params?: RequestParams) => + replacePermission: (username: string, type: string, type_id: string, id: string, permission: { mode?: "r" | "w" | "rw", scope?: "secret" | "public" | "user" | "organization", scope_value?: string }, params?: RequestParams) => this.request(`/${username}/${type}/${type_id}/acl/${id}`, "PUT", params, permission), } diff --git a/tests/generated/v2.0/another-example.ts b/tests/generated/v2.0/another-example.ts index 4d85cbbe..dba71946 100644 --- a/tests/generated/v2.0/another-example.ts +++ b/tests/generated/v2.0/another-example.ts @@ -262,7 +262,7 @@ export class Api { * @request POST:/pet/{petId} * @secure */ - updatePetWithForm: (petId: number, data: any, params?: RequestParams) => + updatePetWithForm: (petId: number, data: { name?: string, status?: string }, params?: RequestParams) => this.request(`/pet/${petId}`, "POST", params, data, true), @@ -284,7 +284,7 @@ export class Api { * @request POST:/pet/{petId}/uploadImage * @secure */ - uploadFile: (petId: number, data: any, params?: RequestParams) => + uploadFile: (petId: number, data: { additionalMetadata?: string, file?: string }, params?: RequestParams) => this.request(`/pet/${petId}/uploadImage`, "POST", params, data, true), } store = { @@ -353,7 +353,7 @@ export class Api { * @summary Creates list of users with given input array * @request POST:/user/createWithArray */ - createUsersWithArrayInput: (body: any, params?: RequestParams) => + createUsersWithArrayInput: (body: User[], params?: RequestParams) => this.request(`/user/createWithArray`, "POST", params, body), @@ -363,7 +363,7 @@ export class Api { * @summary Creates list of users with given input array * @request POST:/user/createWithList */ - createUsersWithListInput: (body: any, params?: RequestParams) => + createUsersWithListInput: (body: User[], params?: RequestParams) => this.request(`/user/createWithList`, "POST", params, body), diff --git a/tests/generated/v2.0/authentiq.ts b/tests/generated/v2.0/authentiq.ts index ffa3e059..64f03bca 100644 --- a/tests/generated/v2.0/authentiq.ts +++ b/tests/generated/v2.0/authentiq.ts @@ -253,7 +253,7 @@ export class Api { * @request POST:/login * @description push sign-in request. See: https://github.com/skion/authentiq/wiki/JWT-Examples. */ - pushLoginRequest: (query: { callback: string }, body: any, params?: RequestParams) => + pushLoginRequest: (query: { callback: string }, body: PushToken, params?: RequestParams) => this.request<{ status?: string }>(`/login${this.addQueryParams(query)}`, "POST", params, body), } scope = { @@ -265,7 +265,7 @@ export class Api { * @request POST:/scope * @description scope verification request. See: https://github.com/skion/authentiq/wiki/JWT-Examples. */ - signRequest: (query: { test?: number }, body: any, params?: RequestParams) => + signRequest: (query: { test?: number }, body: Claims, params?: RequestParams) => this.request<{ job?: string, status?: string }>(`/scope${this.addQueryParams(query)}`, "POST", params, body), @@ -316,7 +316,7 @@ export class Api { * @description authority updates a JWT with its signature. See: https://github.com/skion/authentiq/wiki/JWT-Examples. */ signUpdate: (job: string, params?: RequestParams) => - this.request(`/scope/${job}`, "PUT", params, null), + this.request<{ jwt?: string, status?: string }>(`/scope/${job}`, "PUT", params, null), } } diff --git a/tests/generated/v2.0/github-swagger.ts b/tests/generated/v2.0/github-swagger.ts index cddffb73..be758cf4 100644 --- a/tests/generated/v2.0/github-swagger.ts +++ b/tests/generated/v2.0/github-swagger.ts @@ -3026,7 +3026,7 @@ export class Api { * @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.. */ emailsList: (params?: RequestParams) => - this.request(`/user/emails`, "GET", params, null), + this.request(`/user/emails`, "GET", params, null), /** diff --git a/tests/generated/v3.0/components-responses.ts b/tests/generated/v3.0/components-responses.ts new file mode 100644 index 00000000..8f3eb79d --- /dev/null +++ b/tests/generated/v3.0/components-responses.ts @@ -0,0 +1,103 @@ +/* tslint:disable */ +/* eslint-disable */ + +/* +* --------------------------------------------------------------- +* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## +* ## ## +* ## AUTHOR: acacode ## +* ## SOURCE: https://github.com/acacode/swagger-typescript-api ## +* --------------------------------------------------------------- +*/ + + +export type RequestParams = Omit & { + secure?: boolean; +} + +type ApiConfig = { + baseUrl?: string, + baseApiParams?: RequestParams, + securityWorker?: (securityData: SecurityDataType) => RequestParams, +} + +/** Description */ +export class Api { + + public baseUrl = ""; + public title = "Title"; + public version = "latest"; + + private securityData: SecurityDataType = (null as any); + private securityWorker: ApiConfig["securityWorker"] = (() => {}) as any + + private baseApiParams: RequestParams = { + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + }, + redirect: 'follow', + referrerPolicy: 'no-referrer', + } + + constructor({ baseUrl,baseApiParams,securityWorker, }: ApiConfig = {}) { + this.baseUrl = baseUrl || this.baseUrl; + this.baseApiParams = baseApiParams || this.baseApiParams; + this.securityWorker = securityWorker || this.securityWorker; + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data + } + + + private mergeRequestOptions(params: RequestParams, securityParams?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params, + ...(securityParams || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params.headers || {}), + ...((securityParams && securityParams.headers) || {}) + } + } + } + + private safeParseResponse = (response: Response): Promise => + response.json() + .then(data => data) + .catch(e => response.text); + + public request = ( + path: string, + method: string, + { secure, ...params }: RequestParams = {}, + body?: any, + secureByDefault?: boolean, + ): Promise => + fetch(`${this.baseUrl}${path}`, { + // @ts-ignore + ...this.mergeRequestOptions(params, (secureByDefault || secure) && this.securityWorker(this.securityData)), + method, + body: body ? JSON.stringify(body) : null, + }).then(async response => { + const data = await this.safeParseResponse(response); + if (!response.ok) throw data + return data + }) + + + + api = { + + + /** + * @name getData + * @request GET:/api + */ + getData: (params?: RequestParams) => + this.request<{ data?: string }>(`/api`, "GET", params, null), + } + +} diff --git a/tests/generated/v3.0/responses.ts b/tests/generated/v3.0/responses.ts new file mode 100644 index 00000000..8f3eb79d --- /dev/null +++ b/tests/generated/v3.0/responses.ts @@ -0,0 +1,103 @@ +/* tslint:disable */ +/* eslint-disable */ + +/* +* --------------------------------------------------------------- +* ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## +* ## ## +* ## AUTHOR: acacode ## +* ## SOURCE: https://github.com/acacode/swagger-typescript-api ## +* --------------------------------------------------------------- +*/ + + +export type RequestParams = Omit & { + secure?: boolean; +} + +type ApiConfig = { + baseUrl?: string, + baseApiParams?: RequestParams, + securityWorker?: (securityData: SecurityDataType) => RequestParams, +} + +/** Description */ +export class Api { + + public baseUrl = ""; + public title = "Title"; + public version = "latest"; + + private securityData: SecurityDataType = (null as any); + private securityWorker: ApiConfig["securityWorker"] = (() => {}) as any + + private baseApiParams: RequestParams = { + credentials: 'same-origin', + headers: { + 'Content-Type': 'application/json' + }, + redirect: 'follow', + referrerPolicy: 'no-referrer', + } + + constructor({ baseUrl,baseApiParams,securityWorker, }: ApiConfig = {}) { + this.baseUrl = baseUrl || this.baseUrl; + this.baseApiParams = baseApiParams || this.baseApiParams; + this.securityWorker = securityWorker || this.securityWorker; + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data + } + + + private mergeRequestOptions(params: RequestParams, securityParams?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params, + ...(securityParams || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params.headers || {}), + ...((securityParams && securityParams.headers) || {}) + } + } + } + + private safeParseResponse = (response: Response): Promise => + response.json() + .then(data => data) + .catch(e => response.text); + + public request = ( + path: string, + method: string, + { secure, ...params }: RequestParams = {}, + body?: any, + secureByDefault?: boolean, + ): Promise => + fetch(`${this.baseUrl}${path}`, { + // @ts-ignore + ...this.mergeRequestOptions(params, (secureByDefault || secure) && this.securityWorker(this.securityData)), + method, + body: body ? JSON.stringify(body) : null, + }).then(async response => { + const data = await this.safeParseResponse(response); + if (!response.ok) throw data + return data + }) + + + + api = { + + + /** + * @name getData + * @request GET:/api + */ + getData: (params?: RequestParams) => + this.request<{ data?: string }>(`/api`, "GET", params, null), + } + +} diff --git a/tests/generated/v3.0/uspto.ts b/tests/generated/v3.0/uspto.ts index 713deeca..00c41411 100644 --- a/tests/generated/v3.0/uspto.ts +++ b/tests/generated/v3.0/uspto.ts @@ -125,7 +125,7 @@ export class Api { * @request POST:/{dataset}/{version}/records * @description This API is based on Solr/Lucense Search. The data is indexed using SOLR. This GET API returns the list of all the searchable field names that are in the Solr Index. Please see the 'fields' attribute which returns an array of field names. Each field or a combination of fields can be searched using the Solr/Lucene Syntax. Please refer https://lucene.apache.org/core/3_6_2/queryparsersyntax.html#Overview for the query syntax. List of field names that are searchable can be determined using above GET api. */ - performSearch: (version: string, dataset: string, data: any, params?: RequestParams) => + performSearch: (version: string, dataset: string, data: { criteria: string, start?: number, rows?: number }, params?: RequestParams) => this.request(`/${dataset}/${version}/records`, "POST", params, data), } diff --git a/tests/schemas/v3.0/components-responses.yaml b/tests/schemas/v3.0/components-responses.yaml new file mode 100644 index 00000000..e9708a0f --- /dev/null +++ b/tests/schemas/v3.0/components-responses.yaml @@ -0,0 +1,27 @@ +openapi: '3.0.0' + +info: + description: 'Description' + version: 'latest' + title: 'Title' + +paths: + '/api': + get: + operationId: getData + responses: + 200: + $ref: '#/components/responses/default' + +components: + responses: + default: + description: OK + content: + 'application/json': + schema: + type: object + properties: + data: { type: string } + examples: | + Lorem ipsum de foo bar \ No newline at end of file diff --git a/tests/schemas/v3.0/responses.yaml b/tests/schemas/v3.0/responses.yaml new file mode 100644 index 00000000..711f9be9 --- /dev/null +++ b/tests/schemas/v3.0/responses.yaml @@ -0,0 +1,20 @@ +openapi: '3.0.0' + +info: + description: 'Description' + version: 'latest' + title: 'Title' + +paths: + '/api': + get: + operationId: getData + responses: + 200: + description: OK + content: + 'application/json': + schema: + type: object + properties: + data: { type: string } \ No newline at end of file diff --git a/tests/spec/noClient/schema.ts b/tests/spec/noClient/schema.ts index 96ded7cb..1d749591 100644 --- a/tests/spec/noClient/schema.ts +++ b/tests/spec/noClient/schema.ts @@ -983,2782 +983,3 @@ export interface UserUpdate { } export type users = user[] - -export namespace emojis { - - /** - * @name emojisList - * @request GET:/emojis - * @description Lists all the emojis available to use on GitHub. - */ - export namespace EmojisList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = emojis; - } -} -export namespace events { - - /** - * @name eventsList - * @request GET:/events - * @description List public events. - */ - export namespace EventsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = events; - } -} -export namespace feeds { - - /** - * @name feedsList - * @request GET:/feeds - * @description List Feeds.. GitHub provides several timeline resources in Atom format. The Feeds API. lists all the feeds available to the authenticating user.. - */ - export namespace FeedsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = feeds; - } -} -export namespace gists { - - /** - * @name gistsList - * @request GET:/gists - * @description List the authenticated user's gists or if called anonymously, this will. return all public gists.. - */ - export namespace GistsList { - export type RequestQuery = { since?: string }; - export type RequestBody = never; - export type ResponseBody = gists; - } - - /** - * @name gistsCreate - * @request POST:/gists - * @description Create a gist. - */ - export namespace GistsCreate { - export type RequestQuery = {}; - export type RequestBody = postGist; - export type ResponseBody = gist; - } - - /** - * @name publicList - * @request GET:/gists/public - * @description List all public gists. - */ - export namespace PublicList { - export type RequestQuery = { since?: string }; - export type RequestBody = never; - export type ResponseBody = gists; - } - - /** - * @name starredList - * @request GET:/gists/starred - * @description List the authenticated user's starred gists. - */ - export namespace StarredList { - export type RequestQuery = { since?: string }; - export type RequestBody = never; - export type ResponseBody = gists; - } - - /** - * @name gistsDelete - * @request DELETE:/gists/{id} - * @description Delete a gist. - */ - export namespace GistsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name gistsDetail - * @request GET:/gists/{id} - * @description Get a single gist. - */ - export namespace GistsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gist; - } - - /** - * @name gistsPartialUpdate - * @request PATCH:/gists/{id} - * @description Edit a gist. - */ - export namespace GistsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = patchGist; - export type ResponseBody = gist; - } - - /** - * @name commentsDetail - * @request GET:/gists/{id}/comments - * @description List comments on a gist. - */ - export namespace CommentsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = comments; - } - - /** - * @name commentsCreate - * @request POST:/gists/{id}/comments - * @description Create a commen - */ - export namespace CommentsCreate { - export type RequestQuery = {}; - export type RequestBody = commentBody; - export type ResponseBody = comment; - } - - /** - * @name commentsDelete - * @request DELETE:/gists/{id}/comments/{commentId} - * @description Delete a comment. - */ - export namespace CommentsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name commentsDetail - * @request GET:/gists/{id}/comments/{commentId} - * @description Get a single comment. - * @originalName commentsDetail - * @duplicate - */ - export namespace CommentsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = comment; - } - - /** - * @name commentsPartialUpdate - * @request PATCH:/gists/{id}/comments/{commentId} - * @description Edit a comment. - */ - export namespace CommentsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = comment; - export type ResponseBody = comment; - } - - /** - * @name forksCreate - * @request POST:/gists/{id}/forks - * @description Fork a gist. - */ - export namespace ForksCreate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name starDelete - * @request DELETE:/gists/{id}/star - * @description Unstar a gist. - */ - export namespace StarDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name starDetail - * @request GET:/gists/{id}/star - * @description Check if a gist is starred. - */ - export namespace StarDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name starUpdate - * @request PUT:/gists/{id}/star - * @description Star a gist. - */ - export namespace StarUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } -} -export namespace gitignore { - - /** - * @name templatesList - * @request GET:/gitignore/templates - * @description Listing available templates.. List all templates available to pass as an option when creating a repository.. - */ - export namespace TemplatesList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name templatesDetail - * @request GET:/gitignore/templates/{language} - * @description Get a single template. - */ - export namespace TemplatesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = GitignoreLang; - } -} -export namespace issues { - - /** - * @name issuesList - * @request GET:/issues - * @description List issues.. List all issues across all the authenticated user's visible repositories.. - */ - export namespace IssuesList { - export type RequestQuery = { filter: "assigned" | "created" | "mentioned" | "subscribed" | "all", state: "open" | "closed", labels: string, sort: "created" | "updated" | "comments", direction: "asc" | "desc", since?: string }; - export type RequestBody = never; - export type ResponseBody = issues; - } -} -export namespace legacy { - - /** - * @name issuesSearchDetail - * @request GET:/legacy/issues/search/{owner}/{repository}/{state}/{keyword} - * @description Find issues by state and keyword. - */ - export namespace IssuesSearchDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = SearchIssuesByKeyword; - } - - /** - * @name reposSearchDetail - * @request GET:/legacy/repos/search/{keyword} - * @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. - */ - export namespace ReposSearchDetail { - export type RequestQuery = { order?: "desc" | "asc", language?: string, start_page?: string, sort?: "updated" | "stars" | "forks" }; - export type RequestBody = never; - export type ResponseBody = SearchRepositoriesByKeyword; - } - - /** - * @name userEmailDetail - * @request GET:/legacy/user/email/{email} - * @description This API call is added for compatibility reasons only. - */ - export namespace UserEmailDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = SearchUserByEmail; - } - - /** - * @name userSearchDetail - * @request GET:/legacy/user/search/{keyword} - * @description Find users by keyword. - */ - export namespace UserSearchDetail { - export type RequestQuery = { order?: "desc" | "asc", start_page?: string, sort?: "updated" | "stars" | "forks" }; - export type RequestBody = never; - export type ResponseBody = SearchUsersByKeyword; - } -} -export namespace markdown { - - /** - * @name markdownCreate - * @request POST:/markdown - * @description Render an arbitrary Markdown document - */ - export namespace MarkdownCreate { - export type RequestQuery = {}; - export type RequestBody = markdown; - export type ResponseBody = any; - } - - /** - * @name postMarkdown - * @request POST:/markdown/raw - * @description Render a Markdown document in raw mode - */ - export namespace PostMarkdown { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } -} -export namespace meta { - - /** - * @name metaList - * @request GET:/meta - * @description This gives some information about GitHub.com, the service. - */ - export namespace MetaList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = meta; - } -} -export namespace networks { - - /** - * @name eventsDetail - * @request GET:/networks/{owner}/{repo}/events - * @description List public events for a network of repositories. - */ - export namespace EventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = events; - } -} -export namespace notifications { - - /** - * @name notificationsList - * @request GET:/notifications - * @description List your notifications.. List all notifications for the current user, grouped by repository.. - */ - export namespace NotificationsList { - export type RequestQuery = { all?: boolean, participating?: boolean, since?: string }; - export type RequestBody = never; - export type ResponseBody = notifications; - } - - /** - * @name notificationsUpdate - * @request PUT:/notifications - * @description Mark as read.. Marking a notification as "read" removes it from the default view on GitHub.com.. - */ - export namespace NotificationsUpdate { - export type RequestQuery = {}; - export type RequestBody = notificationMarkRead; - export type ResponseBody = any; - } - - /** - * @name threadsDetail - * @request GET:/notifications/threads/{id} - * @description View a single thread. - */ - export namespace ThreadsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = notifications; - } - - /** - * @name threadsPartialUpdate - * @request PATCH:/notifications/threads/{id} - * @description Mark a thread as read - */ - export namespace ThreadsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name threadsSubscriptionDelete - * @request DELETE:/notifications/threads/{id}/subscription - * @description Delete a Thread Subscription. - */ - export namespace ThreadsSubscriptionDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name threadsSubscriptionDetail - * @request GET:/notifications/threads/{id}/subscription - * @description Get a Thread Subscription. - */ - export namespace ThreadsSubscriptionDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = subscription; - } - - /** - * @name threadsSubscriptionUpdate - * @request PUT:/notifications/threads/{id}/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).. - */ - export namespace ThreadsSubscriptionUpdate { - export type RequestQuery = {}; - export type RequestBody = putSubscription; - export type ResponseBody = subscription; - } -} -export namespace orgs { - - /** - * @name orgsDetail - * @request GET:/orgs/{org} - * @description Get an Organization. - */ - export namespace OrgsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = organization; - } - - /** - * @name orgsPartialUpdate - * @request PATCH:/orgs/{org} - * @description Edit an Organization. - */ - export namespace OrgsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = patchOrg; - export type ResponseBody = organization; - } - - /** - * @name eventsDetail - * @request GET:/orgs/{org}/events - * @description List public events for an organization. - */ - export namespace EventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = events; - } - - /** - * @name issuesDetail - * @request GET:/orgs/{org}/issues - * @description List issues.. List all issues for a given organization for the authenticated user.. - */ - export namespace IssuesDetail { - export type RequestQuery = { filter: "assigned" | "created" | "mentioned" | "subscribed" | "all", state: "open" | "closed", labels: string, sort: "created" | "updated" | "comments", direction: "asc" | "desc", since?: string }; - export type RequestBody = never; - export type ResponseBody = issues; - } - - /** - * @name membersDetail - * @request GET:/orgs/{org}/members - * @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.. - */ - export namespace MembersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name membersDelete - * @request DELETE:/orgs/{org}/members/{username} - * @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.. - */ - export namespace MembersDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name membersDetail - * @request GET:/orgs/{org}/members/{username} - * @description Check if a user is, publicly or privately, a member of the organization. - * @originalName membersDetail - * @duplicate - */ - export namespace MembersDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name publicMembersDetail - * @request GET:/orgs/{org}/public_members - * @description Public members list.. Members of an organization can choose to have their membership publicized. or not.. - */ - export namespace PublicMembersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name publicMembersDelete - * @request DELETE:/orgs/{org}/public_members/{username} - * @description Conceal a user's membership. - */ - export namespace PublicMembersDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name publicMembersDetail - * @request GET:/orgs/{org}/public_members/{username} - * @description Check public membership. - * @originalName publicMembersDetail - * @duplicate - */ - export namespace PublicMembersDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name publicMembersUpdate - * @request PUT:/orgs/{org}/public_members/{username} - * @description Publicize a user's membership. - */ - export namespace PublicMembersUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name reposDetail - * @request GET:/orgs/{org}/repos - * @description List repositories for the specified org. - */ - export namespace ReposDetail { - export type RequestQuery = { type?: "all" | "public" | "private" | "forks" | "sources" | "member" }; - export type RequestBody = never; - export type ResponseBody = repos; - } - - /** - * @name reposCreate - * @request POST:/orgs/{org}/repos - * @description Create a new repository for the authenticated user. OAuth users must supply. repo scope.. - */ - export namespace ReposCreate { - export type RequestQuery = {}; - export type RequestBody = postRepo; - export type ResponseBody = repos; - } - - /** - * @name teamsDetail - * @request GET:/orgs/{org}/teams - * @description List teams. - */ - export namespace TeamsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = teams; - } - - /** - * @name teamsCreate - * @request POST:/orgs/{org}/teams - * @description Create team.. In order to create a team, the authenticated user must be an owner of organization.. - */ - export namespace TeamsCreate { - export type RequestQuery = {}; - export type RequestBody = orgTeamsPost; - export type ResponseBody = team; - } -} -export namespace rateLimit { - - /** - * @name rateLimitList - * @request GET:/rate_limit - * @description Get your current rate limit status. Note: Accessing this endpoint does not count against your rate limit.. - */ - export namespace RateLimitList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = rate_limit; - } -} -export namespace repos { - - /** - * @name reposDelete - * @request DELETE:/repos/{owner}/{repo} - * @description Delete a Repository.. Deleting a repository requires admin access. If OAuth is used, the delete_repo. scope is required.. - */ - export namespace ReposDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name reposDetail - * @request GET:/repos/{owner}/{repo} - * @description Get repository. - */ - export namespace ReposDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = repo; - } - - /** - * @name reposPartialUpdate - * @request PATCH:/repos/{owner}/{repo} - * @description Edit repository. - */ - export namespace ReposPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = repoEdit; - export type ResponseBody = repo; - } - - /** - * @name assigneesDetail - * @request GET:/repos/{owner}/{repo}/assignees - * @description List assignees.. This call lists all the available assignees (owner + collaborators) to which. issues may be assigned.. - */ - export namespace AssigneesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = assignees; - } - - /** - * @name assigneesDetail - * @request GET:/repos/{owner}/{repo}/assignees/{assignee} - * @description Check assignee.. You may also check to see if a particular user is an assignee for a repository.. - * @originalName assigneesDetail - * @duplicate - */ - export namespace AssigneesDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name branchesDetail - * @request GET:/repos/{owner}/{repo}/branches - * @description Get list of branches - */ - export namespace BranchesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = branches; - } - - /** - * @name branchesDetail - * @request GET:/repos/{owner}/{repo}/branches/{branch} - * @description Get Branch - * @originalName branchesDetail - * @duplicate - */ - export namespace BranchesDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = branch; - } - - /** - * @name collaboratorsDetail - * @request GET:/repos/{owner}/{repo}/collaborators - * @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.. - */ - export namespace CollaboratorsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name collaboratorsDelete - * @request DELETE:/repos/{owner}/{repo}/collaborators/{user} - * @description Remove collaborator. - */ - export namespace CollaboratorsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name collaboratorsDetail - * @request GET:/repos/{owner}/{repo}/collaborators/{user} - * @description Check if user is a collaborator - * @originalName collaboratorsDetail - * @duplicate - */ - export namespace CollaboratorsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name collaboratorsUpdate - * @request PUT:/repos/{owner}/{repo}/collaborators/{user} - * @description Add collaborator. - */ - export namespace CollaboratorsUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name commentsDetail - * @request GET:/repos/{owner}/{repo}/comments - * @description List commit comments for a repository.. Comments are ordered by ascending ID.. - */ - export namespace CommentsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = repoComments; - } - - /** - * @name commentsDelete - * @request DELETE:/repos/{owner}/{repo}/comments/{commentId} - * @description Delete a commit comment - */ - export namespace CommentsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name commentsDetail - * @request GET:/repos/{owner}/{repo}/comments/{commentId} - * @description Get a single commit comment. - * @originalName commentsDetail - * @duplicate - */ - export namespace CommentsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = commitComment; - } - - /** - * @name commentsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/comments/{commentId} - * @description Update a commit comment. - */ - export namespace CommentsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = commentBody; - export type ResponseBody = commitComment; - } - - /** - * @name commitsDetail - * @request GET:/repos/{owner}/{repo}/commits - * @description List commits on a repository. - */ - export namespace CommitsDetail { - export type RequestQuery = { since?: string, sha?: string, path?: string, author?: string, until?: string }; - export type RequestBody = never; - export type ResponseBody = commits; - } - - /** - * @name commitsStatusDetail - * @request GET:/repos/{owner}/{repo}/commits/{ref}/status - * @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. - */ - export namespace CommitsStatusDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = refStatus; - } - - /** - * @name commitsDetail - * @request GET:/repos/{owner}/{repo}/commits/{shaCode} - * @description Get a single commit. - * @originalName commitsDetail - * @duplicate - */ - export namespace CommitsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = commit; - } - - /** - * @name commitsCommentsDetail - * @request GET:/repos/{owner}/{repo}/commits/{shaCode}/comments - * @description List comments for a single commitList comments for a single commit. - */ - export namespace CommitsCommentsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = repoComments; - } - - /** - * @name commitsCommentsCreate - * @request POST:/repos/{owner}/{repo}/commits/{shaCode}/comments - * @description Create a commit comment. - */ - export namespace CommitsCommentsCreate { - export type RequestQuery = {}; - export type RequestBody = commitCommentBody; - export type ResponseBody = commitComment; - } - - /** - * @name compareDetail - * @request GET:/repos/{owner}/{repo}/compare/{baseId}...{headId} - * @description Compare two commits - */ - export namespace CompareDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = CompareCommits; - } - - /** - * @name contentsDelete - * @request DELETE:/repos/{owner}/{repo}/contents/{path} - * @description Delete a file.. This method deletes a file in a repository.. - */ - export namespace ContentsDelete { - export type RequestQuery = {}; - export type RequestBody = deleteFileBody; - export type ResponseBody = deleteFile; - } - - /** - * @name contentsDetail - * @request GET:/repos/{owner}/{repo}/contents/{path} - * @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/". - */ - export namespace ContentsDetail { - export type RequestQuery = { path?: string, ref?: string }; - export type RequestBody = never; - export type ResponseBody = ContentsPath; - } - - /** - * @name contentsUpdate - * @request PUT:/repos/{owner}/{repo}/contents/{path} - * @description Create a file. - */ - export namespace ContentsUpdate { - export type RequestQuery = {}; - export type RequestBody = createFileBody; - export type ResponseBody = createFile; - } - - /** - * @name contributorsDetail - * @request GET:/repos/{owner}/{repo}/contributors - * @description Get list of contributors. - */ - export namespace ContributorsDetail { - export type RequestQuery = { anon: string }; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name deploymentsDetail - * @request GET:/repos/{owner}/{repo}/deployments - * @description Users with pull access can view deployments for a repository - */ - export namespace DeploymentsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = RepoDeployments; - } - - /** - * @name deploymentsCreate - * @request POST:/repos/{owner}/{repo}/deployments - * @description Users with push access can create a deployment for a given ref - */ - export namespace DeploymentsCreate { - export type RequestQuery = {}; - export type RequestBody = deployment; - export type ResponseBody = DeploymentResp; - } - - /** - * @name deploymentsStatusesDetail - * @request GET:/repos/{owner}/{repo}/deployments/{id}/statuses - * @description Users with pull access can view deployment statuses for a deployment - */ - export namespace DeploymentsStatusesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = DeploymentStatuses; - } - - /** - * @name deploymentsStatusesCreate - * @request POST:/repos/{owner}/{repo}/deployments/{id}/statuses - * @description Create a Deployment Status. Users with push access can create deployment statuses for a given deployment:. - */ - export namespace DeploymentsStatusesCreate { - export type RequestQuery = {}; - export type RequestBody = DeploymentStatusesCreate; - export type ResponseBody = any; - } - - /** - * @name downloadsDetail - * @request GET:/repos/{owner}/{repo}/downloads - * @description Deprecated. List downloads for a repository. - */ - export namespace DownloadsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = downloads; - } - - /** - * @name downloadsDelete - * @request DELETE:/repos/{owner}/{repo}/downloads/{downloadId} - * @description Deprecated. Delete a download. - */ - export namespace DownloadsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name downloadsDetail - * @request GET:/repos/{owner}/{repo}/downloads/{downloadId} - * @description Deprecated. Get a single download. - * @originalName downloadsDetail - * @duplicate - */ - export namespace DownloadsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = download; - } - - /** - * @name eventsDetail - * @request GET:/repos/{owner}/{repo}/events - * @description Get list of repository events. - */ - export namespace EventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = events; - } - - /** - * @name forksDetail - * @request GET:/repos/{owner}/{repo}/forks - * @description List forks. - */ - export namespace ForksDetail { - export type RequestQuery = { sort?: "newes" | "oldes" | "watchers" }; - export type RequestBody = never; - export type ResponseBody = forks; - } - - /** - * @name forksCreate - * @request POST:/repos/{owner}/{repo}/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.. - */ - export namespace ForksCreate { - export type RequestQuery = {}; - export type RequestBody = forkBody; - export type ResponseBody = repo; - } - - /** - * @name gitBlobsCreate - * @request POST:/repos/{owner}/{repo}/git/blobs - * @description Create a Blob. - */ - export namespace GitBlobsCreate { - export type RequestQuery = {}; - export type RequestBody = blob; - export type ResponseBody = blobs; - } - - /** - * @name gitBlobsDetail - * @request GET:/repos/{owner}/{repo}/git/blobs/{shaCode} - * @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.. - */ - export namespace GitBlobsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = blob; - } - - /** - * @name gitCommitsCreate - * @request POST:/repos/{owner}/{repo}/git/commits - * @description Create a Commit. - */ - export namespace GitCommitsCreate { - export type RequestQuery = {}; - export type RequestBody = repoCommitBody; - export type ResponseBody = gitCommit; - } - - /** - * @name gitCommitsDetail - * @request GET:/repos/{owner}/{repo}/git/commits/{shaCode} - * @description Get a Commit. - */ - export namespace GitCommitsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = repoCommit; - } - - /** - * @name gitRefsDetail - * @request GET:/repos/{owner}/{repo}/git/refs - * @description Get all References - */ - export namespace GitRefsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = refs; - } - - /** - * @name gitRefsCreate - * @request POST:/repos/{owner}/{repo}/git/refs - * @description Create a Reference - */ - export namespace GitRefsCreate { - export type RequestQuery = {}; - export type RequestBody = refsBody; - export type ResponseBody = headBranch; - } - - /** - * @name gitRefsDelete - * @request DELETE:/repos/{owner}/{repo}/git/refs/{ref} - * @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. - */ - export namespace GitRefsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name gitRefsDetail - * @request GET:/repos/{owner}/{repo}/git/refs/{ref} - * @description Get a Reference - * @originalName gitRefsDetail - * @duplicate - */ - export namespace GitRefsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = headBranch; - } - - /** - * @name gitRefsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/git/refs/{ref} - * @description Update a Reference - */ - export namespace GitRefsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = gitRefPatch; - export type ResponseBody = headBranch; - } - - /** - * @name gitTagsCreate - * @request POST:/repos/{owner}/{repo}/git/tags - * @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.. - */ - export namespace GitTagsCreate { - export type RequestQuery = {}; - export type RequestBody = tagBody; - export type ResponseBody = tag; - } - - /** - * @name gitTagsDetail - * @request GET:/repos/{owner}/{repo}/git/tags/{shaCode} - * @description Get a Tag. - */ - export namespace GitTagsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = tag; - } - - /** - * @name gitTreesCreate - * @request POST:/repos/{owner}/{repo}/git/trees - * @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.. - */ - export namespace GitTreesCreate { - export type RequestQuery = {}; - export type RequestBody = tree; - export type ResponseBody = trees; - } - - /** - * @name gitTreesDetail - * @request GET:/repos/{owner}/{repo}/git/trees/{shaCode} - * @description Get a Tree. - */ - export namespace GitTreesDetail { - export type RequestQuery = { recursive?: number }; - export type RequestBody = never; - export type ResponseBody = tree; - } - - /** - * @name hooksDetail - * @request GET:/repos/{owner}/{repo}/hooks - * @description Get list of hooks. - */ - export namespace HooksDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = hook; - } - - /** - * @name hooksCreate - * @request POST:/repos/{owner}/{repo}/hooks - * @description Create a hook. - */ - export namespace HooksCreate { - export type RequestQuery = {}; - export type RequestBody = hookBody; - export type ResponseBody = hook; - } - - /** - * @name hooksDelete - * @request DELETE:/repos/{owner}/{repo}/hooks/{hookId} - * @description Delete a hook. - */ - export namespace HooksDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name hooksDetail - * @request GET:/repos/{owner}/{repo}/hooks/{hookId} - * @description Get single hook. - * @originalName hooksDetail - * @duplicate - */ - export namespace HooksDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = hook; - } - - /** - * @name hooksPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/hooks/{hookId} - * @description Edit a hook. - */ - export namespace HooksPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = hookBody; - export type ResponseBody = hook; - } - - /** - * @name hooksTestsCreate - * @request POST:/repos/{owner}/{repo}/hooks/{hookId}/tests - * @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. - */ - export namespace HooksTestsCreate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name issuesDetail - * @request GET:/repos/{owner}/{repo}/issues - * @description List issues for a repository. - */ - export namespace IssuesDetail { - export type RequestQuery = { filter: "assigned" | "created" | "mentioned" | "subscribed" | "all", state: "open" | "closed", labels: string, sort: "created" | "updated" | "comments", direction: "asc" | "desc", since?: string }; - export type RequestBody = never; - export type ResponseBody = issues; - } - - /** - * @name issuesCreate - * @request POST:/repos/{owner}/{repo}/issues - * @description Create an issue.. Any user with pull access to a repository can create an issue.. - */ - export namespace IssuesCreate { - export type RequestQuery = {}; - export type RequestBody = issue; - export type ResponseBody = issue; - } - - /** - * @name issuesCommentsDetail - * @request GET:/repos/{owner}/{repo}/issues/comments - * @description List comments in a repository. - */ - export namespace IssuesCommentsDetail { - export type RequestQuery = { direction?: string, sort?: "created" | "updated", since?: string }; - export type RequestBody = never; - export type ResponseBody = issuesComments; - } - - /** - * @name issuesCommentsDelete - * @request DELETE:/repos/{owner}/{repo}/issues/comments/{commentId} - * @description Delete a comment. - */ - export namespace IssuesCommentsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name issuesCommentsDetail - * @request GET:/repos/{owner}/{repo}/issues/comments/{commentId} - * @description Get a single comment. - * @originalName issuesCommentsDetail - * @duplicate - */ - export namespace IssuesCommentsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issuesComment; - } - - /** - * @name issuesCommentsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/issues/comments/{commentId} - * @description Edit a comment. - */ - export namespace IssuesCommentsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = commentBody; - export type ResponseBody = issuesComment; - } - - /** - * @name issuesEventsDetail - * @request GET:/repos/{owner}/{repo}/issues/events - * @description List issue events for a repository. - */ - export namespace IssuesEventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issueEvents; - } - - /** - * @name issuesEventsDetail - * @request GET:/repos/{owner}/{repo}/issues/events/{eventId} - * @description Get a single event. - * @originalName issuesEventsDetail - * @duplicate - */ - export namespace IssuesEventsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issueEvent; - } - - /** - * @name issuesDetail - * @request GET:/repos/{owner}/{repo}/issues/{number} - * @description Get a single issue - * @originalName issuesDetail - * @duplicate - */ - export namespace IssuesDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issue; - } - - /** - * @name issuesPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/issues/{number} - * @description Edit an issue.. Issue owners and users with push access can edit an issue.. - */ - export namespace IssuesPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = issue; - export type ResponseBody = issue; - } - - /** - * @name issuesCommentsDetail - * @request GET:/repos/{owner}/{repo}/issues/{number}/comments - * @description List comments on an issue. - * @originalName issuesCommentsDetail - * @duplicate - */ - export namespace IssuesCommentsDetail3 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issuesComments; - } - - /** - * @name issuesCommentsCreate - * @request POST:/repos/{owner}/{repo}/issues/{number}/comments - * @description Create a comment. - */ - export namespace IssuesCommentsCreate { - export type RequestQuery = {}; - export type RequestBody = commentBody; - export type ResponseBody = issuesComment; - } - - /** - * @name issuesEventsDetail - * @request GET:/repos/{owner}/{repo}/issues/{number}/events - * @description List events for an issue. - * @originalName issuesEventsDetail - * @duplicate - */ - export namespace IssuesEventsDetail3 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = issueEvents; - } - - /** - * @name issuesLabelsDelete - * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels - * @description Remove all labels from an issue. - */ - export namespace IssuesLabelsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name issuesLabelsDetail - * @request GET:/repos/{owner}/{repo}/issues/{number}/labels - * @description List labels on an issue. - */ - export namespace IssuesLabelsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = labels; - } - - /** - * @name issuesLabelsCreate - * @request POST:/repos/{owner}/{repo}/issues/{number}/labels - * @description Add labels to an issue. - */ - export namespace IssuesLabelsCreate { - export type RequestQuery = {}; - export type RequestBody = emailsPost; - export type ResponseBody = label; - } - - /** - * @name issuesLabelsUpdate - * @request PUT:/repos/{owner}/{repo}/issues/{number}/labels - * @description Replace all labels for an issue.. Sending an empty array ([]) will remove all Labels from the Issue.. - */ - export namespace IssuesLabelsUpdate { - export type RequestQuery = {}; - export type RequestBody = emailsPost; - export type ResponseBody = label; - } - - /** - * @name issuesLabelsDelete - * @request DELETE:/repos/{owner}/{repo}/issues/{number}/labels/{name} - * @description Remove a label from an issue. - * @originalName issuesLabelsDelete - * @duplicate - */ - export namespace IssuesLabelsDelete2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name keysDetail - * @request GET:/repos/{owner}/{repo}/keys - * @description Get list of keys. - */ - export namespace KeysDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = keys; - } - - /** - * @name keysCreate - * @request POST:/repos/{owner}/{repo}/keys - * @description Create a key. - */ - export namespace KeysCreate { - export type RequestQuery = {}; - export type RequestBody = UserKeysPost; - export type ResponseBody = UserKeysKeyId; - } - - /** - * @name keysDelete - * @request DELETE:/repos/{owner}/{repo}/keys/{keyId} - * @description Delete a key. - */ - export namespace KeysDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name keysDetail - * @request GET:/repos/{owner}/{repo}/keys/{keyId} - * @description Get a key - * @originalName keysDetail - * @duplicate - */ - export namespace KeysDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = UserKeysKeyId; - } - - /** - * @name labelsDetail - * @request GET:/repos/{owner}/{repo}/labels - * @description List all labels for this repository. - */ - export namespace LabelsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = labels; - } - - /** - * @name labelsCreate - * @request POST:/repos/{owner}/{repo}/labels - * @description Create a label. - */ - export namespace LabelsCreate { - export type RequestQuery = {}; - export type RequestBody = emailsPost; - export type ResponseBody = label; - } - - /** - * @name labelsDelete - * @request DELETE:/repos/{owner}/{repo}/labels/{name} - * @description Delete a label. - */ - export namespace LabelsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name labelsDetail - * @request GET:/repos/{owner}/{repo}/labels/{name} - * @description Get a single label. - * @originalName labelsDetail - * @duplicate - */ - export namespace LabelsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = label; - } - - /** - * @name labelsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/labels/{name} - * @description Update a label. - */ - export namespace LabelsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = emailsPost; - export type ResponseBody = label; - } - - /** - * @name languagesDetail - * @request GET:/repos/{owner}/{repo}/languages - * @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.. - */ - export namespace LanguagesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = languages; - } - - /** - * @name mergesCreate - * @request POST:/repos/{owner}/{repo}/merges - * @description Perform a merge. - */ - export namespace MergesCreate { - export type RequestQuery = {}; - export type RequestBody = mergesBody; - export type ResponseBody = mergesSuccessful; - } - - /** - * @name milestonesDetail - * @request GET:/repos/{owner}/{repo}/milestones - * @description List milestones for a repository. - */ - export namespace MilestonesDetail { - export type RequestQuery = { state?: "open" | "closed", direction?: string, sort?: "due_date" | "completeness" }; - export type RequestBody = never; - export type ResponseBody = milestone; - } - - /** - * @name milestonesCreate - * @request POST:/repos/{owner}/{repo}/milestones - * @description Create a milestone. - */ - export namespace MilestonesCreate { - export type RequestQuery = {}; - export type RequestBody = milestoneUpdate; - export type ResponseBody = milestone; - } - - /** - * @name milestonesDelete - * @request DELETE:/repos/{owner}/{repo}/milestones/{number} - * @description Delete a milestone. - */ - export namespace MilestonesDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name milestonesDetail - * @request GET:/repos/{owner}/{repo}/milestones/{number} - * @description Get a single milestone. - * @originalName milestonesDetail - * @duplicate - */ - export namespace MilestonesDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = milestone; - } - - /** - * @name milestonesPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/milestones/{number} - * @description Update a milestone. - */ - export namespace MilestonesPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = milestoneUpdate; - export type ResponseBody = milestone; - } - - /** - * @name milestonesLabelsDetail - * @request GET:/repos/{owner}/{repo}/milestones/{number}/labels - * @description Get labels for every issue in a milestone. - */ - export namespace MilestonesLabelsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = labels; - } - - /** - * @name notificationsDetail - * @request GET:/repos/{owner}/{repo}/notifications - * @description List your notifications in a repository. List all notifications for the current user.. - */ - export namespace NotificationsDetail { - export type RequestQuery = { all?: boolean, participating?: boolean, since?: string }; - export type RequestBody = never; - export type ResponseBody = notifications; - } - - /** - * @name notificationsUpdate - * @request PUT:/repos/{owner}/{repo}/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.. - */ - export namespace NotificationsUpdate { - export type RequestQuery = {}; - export type RequestBody = notificationMarkRead; - export type ResponseBody = any; - } - - /** - * @name pullsDetail - * @request GET:/repos/{owner}/{repo}/pulls - * @description List pull requests. - */ - export namespace PullsDetail { - export type RequestQuery = { state?: "open" | "closed", head?: string, base?: string }; - export type RequestBody = never; - export type ResponseBody = pulls; - } - - /** - * @name pullsCreate - * @request POST:/repos/{owner}/{repo}/pulls - * @description Create a pull request. - */ - export namespace PullsCreate { - export type RequestQuery = {}; - export type RequestBody = pullsPost; - export type ResponseBody = pulls; - } - - /** - * @name pullsCommentsDetail - * @request GET:/repos/{owner}/{repo}/pulls/comments - * @description List comments in a repository.. By default, Review Comments are ordered by ascending ID.. - */ - export namespace PullsCommentsDetail { - export type RequestQuery = { direction?: string, sort?: "created" | "updated", since?: string }; - export type RequestBody = never; - export type ResponseBody = issuesComments; - } - - /** - * @name pullsCommentsDelete - * @request DELETE:/repos/{owner}/{repo}/pulls/comments/{commentId} - * @description Delete a comment. - */ - export namespace PullsCommentsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name pullsCommentsDetail - * @request GET:/repos/{owner}/{repo}/pulls/comments/{commentId} - * @description Get a single comment. - * @originalName pullsCommentsDetail - * @duplicate - */ - export namespace PullsCommentsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = pullsComment; - } - - /** - * @name pullsCommentsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/pulls/comments/{commentId} - * @description Edit a comment. - */ - export namespace PullsCommentsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = commentBody; - export type ResponseBody = pullsComment; - } - - /** - * @name pullsDetail - * @request GET:/repos/{owner}/{repo}/pulls/{number} - * @description Get a single pull request. - * @originalName pullsDetail - * @duplicate - */ - export namespace PullsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = pullRequest; - } - - /** - * @name pullsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/pulls/{number} - * @description Update a pull request. - */ - export namespace PullsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = pullUpdate; - export type ResponseBody = repo; - } - - /** - * @name pullsCommentsDetail - * @request GET:/repos/{owner}/{repo}/pulls/{number}/comments - * @description List comments on a pull request. - * @originalName pullsCommentsDetail - * @duplicate - */ - export namespace PullsCommentsDetail3 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = pullsComment; - } - - /** - * @name pullsCommentsCreate - * @request POST:/repos/{owner}/{repo}/pulls/{number}/comments - * @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.. - */ - export namespace PullsCommentsCreate { - export type RequestQuery = {}; - export type RequestBody = pullsCommentPost; - export type ResponseBody = pullsComment; - } - - /** - * @name pullsCommitsDetail - * @request GET:/repos/{owner}/{repo}/pulls/{number}/commits - * @description List commits on a pull request. - */ - export namespace PullsCommitsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = commits; - } - - /** - * @name pullsFilesDetail - * @request GET:/repos/{owner}/{repo}/pulls/{number}/files - * @description List pull requests files. - */ - export namespace PullsFilesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = pulls; - } - - /** - * @name pullsMergeDetail - * @request GET:/repos/{owner}/{repo}/pulls/{number}/merge - * @description Get if a pull request has been merged. - */ - export namespace PullsMergeDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name pullsMergeUpdate - * @request PUT:/repos/{owner}/{repo}/pulls/{number}/merge - * @description Merge a pull request (Merge Button's) - */ - export namespace PullsMergeUpdate { - export type RequestQuery = {}; - export type RequestBody = mergePullBody; - export type ResponseBody = merge; - } - - /** - * @name readmeDetail - * @request GET:/repos/{owner}/{repo}/readme - * @description Get the README.. This method returns the preferred README for a repository.. - */ - export namespace ReadmeDetail { - export type RequestQuery = { ref?: string }; - export type RequestBody = never; - export type ResponseBody = ContentsPath; - } - - /** - * @name releasesDetail - * @request GET:/repos/{owner}/{repo}/releases - * @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 - */ - export namespace ReleasesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = releases; - } - - /** - * @name releasesCreate - * @request POST:/repos/{owner}/{repo}/releases - * @description Create a release. Users with push access to the repository can create a release.. - */ - export namespace ReleasesCreate { - export type RequestQuery = {}; - export type RequestBody = ReleaseCreate; - export type ResponseBody = release; - } - - /** - * @name releasesAssetsDelete - * @request DELETE:/repos/{owner}/{repo}/releases/assets/{id} - * @description Delete a release asset - */ - export namespace ReleasesAssetsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name releasesAssetsDetail - * @request GET:/repos/{owner}/{repo}/releases/assets/{id} - * @description Get a single release asset - */ - export namespace ReleasesAssetsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = asset; - } - - /** - * @name releasesAssetsPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/releases/assets/{id} - * @description Edit a release asset. Users with push access to the repository can edit a release asset.. - */ - export namespace ReleasesAssetsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = assetPatch; - export type ResponseBody = asset; - } - - /** - * @name releasesDelete - * @request DELETE:/repos/{owner}/{repo}/releases/{id} - * @description Users with push access to the repository can delete a release. - */ - export namespace ReleasesDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name releasesDetail - * @request GET:/repos/{owner}/{repo}/releases/{id} - * @description Get a single release - * @originalName releasesDetail - * @duplicate - */ - export namespace ReleasesDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = release; - } - - /** - * @name releasesPartialUpdate - * @request PATCH:/repos/{owner}/{repo}/releases/{id} - * @description Users with push access to the repository can edit a release - */ - export namespace ReleasesPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = ReleaseCreate; - export type ResponseBody = release; - } - - /** - * @name releasesAssetsDetail - * @request GET:/repos/{owner}/{repo}/releases/{id}/assets - * @description List assets for a release - * @originalName releasesAssetsDetail - * @duplicate - */ - export namespace ReleasesAssetsDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = assets; - } - - /** - * @name stargazersDetail - * @request GET:/repos/{owner}/{repo}/stargazers - * @description List Stargazers. - */ - export namespace StargazersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name statsCodeFrequencyDetail - * @request GET:/repos/{owner}/{repo}/stats/code_frequency - * @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.. - */ - export namespace StatsCodeFrequencyDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = codeFrequencyStats; - } - - /** - * @name statsCommitActivityDetail - * @request GET:/repos/{owner}/{repo}/stats/commit_activity - * @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.. - */ - export namespace StatsCommitActivityDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = commitActivityStats; - } - - /** - * @name statsContributorsDetail - * @request GET:/repos/{owner}/{repo}/stats/contributors - * @description Get contributors list with additions, deletions, and commit counts. - */ - export namespace StatsContributorsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = contributorsStats; - } - - /** - * @name statsParticipationDetail - * @request GET:/repos/{owner}/{repo}/stats/participation - * @description Get the weekly commit count for the repo owner and everyone else. - */ - export namespace StatsParticipationDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = participationStats; - } - - /** - * @name statsPunchCardDetail - * @request GET:/repos/{owner}/{repo}/stats/punch_card - * @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.. - */ - export namespace StatsPunchCardDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = codeFrequencyStats; - } - - /** - * @name statusesDetail - * @request GET:/repos/{owner}/{repo}/statuses/{ref} - * @description List Statuses for a specific Ref. - */ - export namespace StatusesDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = ref; - } - - /** - * @name statusesCreate - * @request POST:/repos/{owner}/{repo}/statuses/{ref} - * @description Create a Status. - */ - export namespace StatusesCreate { - export type RequestQuery = {}; - export type RequestBody = headBranch; - export type ResponseBody = ref; - } - - /** - * @name subscribersDetail - * @request GET:/repos/{owner}/{repo}/subscribers - * @description List watchers. - */ - export namespace SubscribersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name subscriptionDelete - * @request DELETE:/repos/{owner}/{repo}/subscription - * @description Delete a Repository Subscription. - */ - export namespace SubscriptionDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name subscriptionDetail - * @request GET:/repos/{owner}/{repo}/subscription - * @description Get a Repository Subscription. - */ - export namespace SubscriptionDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = subscription; - } - - /** - * @name subscriptionUpdate - * @request PUT:/repos/{owner}/{repo}/subscription - * @description Set a Repository Subscription - */ - export namespace SubscriptionUpdate { - export type RequestQuery = {}; - export type RequestBody = subscriptionBody; - export type ResponseBody = subscription; - } - - /** - * @name tagsDetail - * @request GET:/repos/{owner}/{repo}/tags - * @description Get list of tags. - */ - export namespace TagsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = tags; - } - - /** - * @name teamsDetail - * @request GET:/repos/{owner}/{repo}/teams - * @description Get list of teams - */ - export namespace TeamsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = teams; - } - - /** - * @name watchersDetail - * @request GET:/repos/{owner}/{repo}/watchers - * @description List Stargazers. New implementation. - */ - export namespace WatchersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name reposDetail - * @request GET:/repos/{owner}/{repo}/{archive_format}/{path} - * @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.. - * @originalName reposDetail - * @duplicate - */ - export namespace ReposDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } -} -export namespace repositories { - - /** - * @name repositoriesList - * @request GET:/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.. - */ - export namespace RepositoriesList { - export type RequestQuery = { since?: string }; - export type RequestBody = never; - export type ResponseBody = repos; - } -} -export namespace search { - - /** - * @name codeList - * @request GET:/search/code - * @description Search code. - */ - export namespace CodeList { - export type RequestQuery = { order?: "desc" | "asc", q: string, sort?: "indexed" }; - export type RequestBody = never; - export type ResponseBody = SearchCode; - } - - /** - * @name issuesList - * @request GET:/search/issues - * @description Find issues by state and keyword. (This method returns up to 100 results per page.) - */ - export namespace IssuesList { - export type RequestQuery = { order?: "desc" | "asc", q: string, sort?: "updated" | "created" | "comments" }; - export type RequestBody = never; - export type ResponseBody = SearchIssues; - } - - /** - * @name repositoriesList - * @request GET:/search/repositories - * @description Search repositories. - */ - export namespace RepositoriesList { - export type RequestQuery = { order?: "desc" | "asc", q: string, sort?: "stars" | "forks" | "updated" }; - export type RequestBody = never; - export type ResponseBody = SearchRepositories; - } - - /** - * @name usersList - * @request GET:/search/users - * @description Search users. - */ - export namespace UsersList { - export type RequestQuery = { order?: "desc" | "asc", q: string, sort?: "followers" | "repositories" | "joined" }; - export type RequestBody = never; - export type ResponseBody = SearchUsers; - } -} -export namespace teams { - - /** - * @name teamsDelete - * @request DELETE:/teams/{teamId} - * @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.. - */ - export namespace TeamsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name teamsDetail - * @request GET:/teams/{teamId} - * @description Get team. - */ - export namespace TeamsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = team; - } - - /** - * @name teamsPartialUpdate - * @request PATCH:/teams/{teamId} - * @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.. - */ - export namespace TeamsPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = editTeam; - export type ResponseBody = team; - } - - /** - * @name membersDetail - * @request GET:/teams/{teamId}/members - * @description List team members.. In order to list members in a team, the authenticated user must be a member. of the team.. - */ - export namespace MembersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name membersDelete - * @request DELETE:/teams/{teamId}/members/{username} - * @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.. - */ - export namespace MembersDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name membersDetail - * @request GET:/teams/{teamId}/members/{username} - * @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.. - * @originalName membersDetail - * @duplicate - */ - export namespace MembersDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name membersUpdate - * @request PUT:/teams/{teamId}/members/{username} - * @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.. - */ - export namespace MembersUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name membershipsDelete - * @request DELETE:/teams/{teamId}/memberships/{username} - * @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.. - */ - export namespace MembershipsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name membershipsDetail - * @request GET:/teams/{teamId}/memberships/{username} - * @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.. - */ - export namespace MembershipsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = teamMembership; - } - - /** - * @name membershipsUpdate - * @request PUT:/teams/{teamId}/memberships/{username} - * @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.. - */ - export namespace MembershipsUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = teamMembership; - } - - /** - * @name reposDetail - * @request GET:/teams/{teamId}/repos - * @description List team repos - */ - export namespace ReposDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = teamRepos; - } - - /** - * @name reposDelete - * @request DELETE:/teams/{teamId}/repos/{owner}/{repo} - * @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. - */ - export namespace ReposDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name reposDetail - * @request GET:/teams/{teamId}/repos/{owner}/{repo} - * @description Check if a team manages a repository - * @originalName reposDetail - * @duplicate - */ - export namespace ReposDetail2 { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name reposUpdate - * @request PUT:/teams/{teamId}/repos/{owner}/{repo} - * @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. - */ - export namespace ReposUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } -} -export namespace user { - - /** - * @name userList - * @request GET:/user - * @description Get the authenticated user. - */ - export namespace UserList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = user; - } - - /** - * @name userPartialUpdate - * @request PATCH:/user - * @description Update the authenticated user. - */ - export namespace UserPartialUpdate { - export type RequestQuery = {}; - export type RequestBody = UserUpdate; - export type ResponseBody = user; - } - - /** - * @name emailsDelete - * @request DELETE:/user/emails - * @description Delete email address(es).. You can include a single email address or an array of addresses.. - */ - export namespace EmailsDelete { - export type RequestQuery = {}; - export type RequestBody = UserEmails; - export type ResponseBody = any; - } - - /** - * @name emailsList - * @request GET:/user/emails - * @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.. - */ - export namespace EmailsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name emailsCreate - * @request POST:/user/emails - * @description Add email address(es).. You can post a single email address or an array of addresses.. - */ - export namespace EmailsCreate { - export type RequestQuery = {}; - export type RequestBody = emailsPost; - export type ResponseBody = any; - } - - /** - * @name followersList - * @request GET:/user/followers - * @description List the authenticated user's followers - */ - export namespace FollowersList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name followingList - * @request GET:/user/following - * @description List who the authenticated user is following. - */ - export namespace FollowingList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name followingDelete - * @request DELETE:/user/following/{username} - * @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.. - */ - export namespace FollowingDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name followingDetail - * @request GET:/user/following/{username} - * @description Check if you are following a user. - */ - export namespace FollowingDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name followingUpdate - * @request PUT:/user/following/{username} - * @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.. - */ - export namespace FollowingUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name issuesList - * @request GET:/user/issues - * @description List issues.. List all issues across owned and member repositories for the authenticated. user.. - */ - export namespace IssuesList { - export type RequestQuery = { filter: "assigned" | "created" | "mentioned" | "subscribed" | "all", state: "open" | "closed", labels: string, sort: "created" | "updated" | "comments", direction: "asc" | "desc", since?: string }; - export type RequestBody = never; - export type ResponseBody = issues; - } - - /** - * @name keysList - * @request GET:/user/keys - * @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.. - */ - export namespace KeysList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name keysCreate - * @request POST:/user/keys - * @description Create a public key. - */ - export namespace KeysCreate { - export type RequestQuery = {}; - export type RequestBody = UserKeysPost; - export type ResponseBody = UserKeysKeyId; - } - - /** - * @name keysDelete - * @request DELETE:/user/keys/{keyId} - * @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. - */ - export namespace KeysDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name keysDetail - * @request GET:/user/keys/{keyId} - * @description Get a single public key. - */ - export namespace KeysDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = UserKeysKeyId; - } - - /** - * @name orgsList - * @request GET:/user/orgs - * @description List public and private organizations for the authenticated user. - */ - export namespace OrgsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name reposList - * @request GET:/user/repos - * @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.. - */ - export namespace ReposList { - export type RequestQuery = { type?: "all" | "public" | "private" | "forks" | "sources" | "member" }; - export type RequestBody = never; - export type ResponseBody = repos; - } - - /** - * @name reposCreate - * @request POST:/user/repos - * @description Create a new repository for the authenticated user. OAuth users must supply. repo scope.. - */ - export namespace ReposCreate { - export type RequestQuery = {}; - export type RequestBody = postRepo; - export type ResponseBody = repos; - } - - /** - * @name starredList - * @request GET:/user/starred - * @description List repositories being starred by the authenticated user. - */ - export namespace StarredList { - export type RequestQuery = { direction?: string, sort?: "created" | "updated" }; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name starredDelete - * @request DELETE:/user/starred/{owner}/{repo} - * @description Unstar a repository - */ - export namespace StarredDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name starredDetail - * @request GET:/user/starred/{owner}/{repo} - * @description Check if you are starring a repository. - */ - export namespace StarredDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name starredUpdate - * @request PUT:/user/starred/{owner}/{repo} - * @description Star a repository. - */ - export namespace StarredUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name subscriptionsList - * @request GET:/user/subscriptions - * @description List repositories being watched by the authenticated user. - */ - export namespace SubscriptionsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = repos; - } - - /** - * @name subscriptionsDelete - * @request DELETE:/user/subscriptions/{owner}/{repo} - * @description Stop watching a repository - */ - export namespace SubscriptionsDelete { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name subscriptionsDetail - * @request GET:/user/subscriptions/{owner}/{repo} - * @description Check if you are watching a repository. - */ - export namespace SubscriptionsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name subscriptionsUpdate - * @request PUT:/user/subscriptions/{owner}/{repo} - * @description Watch a repository. - */ - export namespace SubscriptionsUpdate { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name teamsList - * @request GET:/user/teams - * @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. - */ - export namespace TeamsList { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = TeamsList; - } -} -export namespace users { - - /** - * @name usersList - * @request GET:/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.. - */ - export namespace UsersList { - export type RequestQuery = { since?: number }; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name usersDetail - * @request GET:/users/{username} - * @description Get a single user. - */ - export namespace UsersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = user; - } - - /** - * @name eventsDetail - * @request GET:/users/{username}/events - * @description If you are authenticated as the given user, you will see your private events. Otherwise, you'll only see public events. - */ - export namespace EventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name eventsOrgsDetail - * @request GET:/users/{username}/events/orgs/{org} - * @description This is the user's organization dashboard. You must be authenticated as the user to view this. - */ - export namespace EventsOrgsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name followersDetail - * @request GET:/users/{username}/followers - * @description List a user's followers - */ - export namespace FollowersDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = users; - } - - /** - * @name followingDetail - * @request GET:/users/{username}/following/{targetUser} - * @description Check if one user follows another. - */ - export namespace FollowingDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name gistsDetail - * @request GET:/users/{username}/gists - * @description List a users gists. - */ - export namespace GistsDetail { - export type RequestQuery = { since?: string }; - export type RequestBody = never; - export type ResponseBody = gists; - } - - /** - * @name keysDetail - * @request GET:/users/{username}/keys - * @description List public keys for a user.. Lists the verified public keys for a user. This is accessible by anyone.. - */ - export namespace KeysDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name orgsDetail - * @request GET:/users/{username}/orgs - * @description List all public organizations for a user. - */ - export namespace OrgsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = gitignore; - } - - /** - * @name receivedEventsDetail - * @request GET:/users/{username}/received_events - * @description These are events that you'll only see public events. - */ - export namespace ReceivedEventsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name receivedEventsPublicDetail - * @request GET:/users/{username}/received_events/public - * @description List public events that a user has received - */ - export namespace ReceivedEventsPublicDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name reposDetail - * @request GET:/users/{username}/repos - * @description List public repositories for the specified user. - */ - export namespace ReposDetail { - export type RequestQuery = { type?: "all" | "public" | "private" | "forks" | "sources" | "member" }; - export type RequestBody = never; - export type ResponseBody = repos; - } - - /** - * @name starredDetail - * @request GET:/users/{username}/starred - * @description List repositories being starred by a user. - */ - export namespace StarredDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } - - /** - * @name subscriptionsDetail - * @request GET:/users/{username}/subscriptions - * @description List repositories being watched by a user. - */ - export namespace SubscriptionsDetail { - export type RequestQuery = {}; - export type RequestBody = never; - export type ResponseBody = any; - } -} diff --git a/tests/spec/routeTypes/schema.ts b/tests/spec/routeTypes/schema.ts index 3191100b..402313a2 100644 --- a/tests/spec/routeTypes/schema.ts +++ b/tests/spec/routeTypes/schema.ts @@ -3350,7 +3350,7 @@ export namespace user { export namespace EmailsList { export type RequestQuery = {}; export type RequestBody = never; - export type ResponseBody = any; + export type ResponseBody = UserEmails; } /** @@ -5805,7 +5805,7 @@ export class Api { * @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.. */ emailsList: (params?: RequestParams) => - this.request(`/user/emails`, "GET", params, null), + this.request(`/user/emails`, "GET", params, null), /**