From d458a177c5c1fb4028af579ca5267e1ea14ed2ec Mon Sep 17 00:00:00 2001 From: js2me Date: Sat, 12 Nov 2022 10:57:24 +0600 Subject: [PATCH 1/9] internal: trying to add async operations in swagger-typescript-api --- CHANGELOG.md | 4 +- README.md | 4 +- src/code-gen-process.js | 122 +- src/configuration.js | 4 +- src/schema-parser/schema-formatters.js | 40 +- src/schema-parser/schema-parser.js | 207 +- src/schema-parser/schema-routes.js | 172 +- src/templates.js | 10 +- templates/default/api.ejs | 4 +- templates/default/procedure-call.ejs | 4 +- templates/default/route-types.ejs | 10 +- templates/modular/procedure-call.ejs | 2 +- tests/generated/v2.0/adafruit.ts | 439 +- tests/generated/v2.0/another-example.ts | 93 +- tests/generated/v2.0/another-schema.ts | 6 +- tests/generated/v2.0/api-with-examples.ts | 8 +- tests/generated/v2.0/authentiq.ts | 24 +- tests/generated/v2.0/example1.ts | 5 +- tests/generated/v2.0/file-formdata-example.ts | 15 +- tests/generated/v2.0/giphy.ts | 28 +- tests/generated/v2.0/github-swagger.ts | 373 +- tests/generated/v2.0/path-args.ts | 4 +- tests/generated/v2.0/petstore-expanded.ts | 8 +- tests/generated/v2.0/petstore-simple.ts | 8 +- tests/generated/v2.0/petstore-swagger-io.ts | 60 +- .../v2.0/petstore-with-external-docs.ts | 8 +- tests/generated/v2.0/petstore.ts | 4 +- tests/generated/v2.0/query-path-param.ts | 4 +- tests/generated/v2.0/uber.ts | 10 +- tests/generated/v3.0/allof-example.ts | 4 +- tests/generated/v3.0/anyof-example.ts | 4 +- tests/generated/v3.0/callback-example.ts | 2 +- tests/generated/v3.0/explode-param-3.0.1.ts | 16 +- tests/generated/v3.0/full-swagger-scheme.ts | 4695 ++--------------- tests/generated/v3.0/link-example.ts | 4 +- tests/generated/v3.0/oneof-example.ts | 4 +- tests/generated/v3.0/personal-api-example.ts | 22 +- tests/generated/v3.0/petstore-expanded.ts | 8 +- tests/generated/v3.0/petstore.ts | 4 +- tests/generated/v3.0/tsoa-odd-types-3.0.2.ts | 32 +- tests/generated/v3.0/up-banking.ts | 40 +- tests/generated/v3.0/uspto.ts | 25 +- tests/generated/v3.0/wrong-schema-names.ts | 4 +- tests/spec/deprecated/schema.ts | 4 +- tests/spec/extract-enums/schema.ts | 16 +- tests/spec/multiple-schemas/paths/repro.yaml | 8 + tests/spec/multiple-schemas/schema.yaml | 8 + tests/spec/templates/spec_templates/api.eta | 4 +- .../templates/spec_templates/http-client.eta | 2 +- .../spec_templates/procedure-call.eta | 4 +- .../templates/spec_templates/route-type.eta | 2 +- .../templates/spec_templates/route-types.eta | 4 +- 52 files changed, 1181 insertions(+), 5415 deletions(-) create mode 100644 tests/spec/multiple-schemas/paths/repro.yaml create mode 100644 tests/spec/multiple-schemas/schema.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index f9b18c3a..05f36fcd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -236,8 +236,8 @@ const primitiveTypes = { "relative-json-pointer": () => Ts.Keyword.String, regex: () => Ts.Keyword.String, }, - array: ({ items, ...schemaPart }, parser) => { - const content = parser.getInlineParseContent(items); + array: async ({ items, ...schemaPart }, parser) => { + const content = await parser.getInlineParseContent(items); return parser.safeAddNullToType(schemaPart, Ts.ArrayType(content)); }, } diff --git a/README.md b/README.md index 9fe53778..71bf96f4 100644 --- a/README.md +++ b/README.md @@ -435,8 +435,8 @@ generateApi({ "relative-json-pointer": () => "string", regex: () => "string", }, - array: (schema, parser) => { - const content = parser.getInlineParseContent(schema.items); + array: async (schema, parser) => { + const content = await parser.getInlineParseContent(schema.items); return parser.safeAddNullToType(schema, `(${content})[]`); }, }) diff --git a/src/code-gen-process.js b/src/code-gen-process.js index 2d615ac6..9b8896c4 100644 --- a/src/code-gen-process.js +++ b/src/code-gen-process.js @@ -84,6 +84,7 @@ class CodeGenProcess { } async start() { + await this.schemaRoutes.init(); this.config.update({ templatePaths: this.templates.getTemplatePaths(this.config) }); this.config.update({ templatesToRender: this.templates.getTemplates(this.config) }); @@ -106,11 +107,13 @@ class CodeGenProcess { this.config.componentTypeNameResolver.reserve(componentSchemaNames); - const parsedSchemas = _.map(_.get(swagger.usageSchema.components, "schemas"), (schema, typeName) => - this.schemaParser.parseSchema(schema, typeName), + const parsedSchemas = await Promise.all( + _.map(_.get(swagger.usageSchema.components, "schemas"), (schema, typeName) => + this.schemaParser.parseSchema(schema, typeName), + ), ); - this.schemaRoutes.attachSchema({ + await this.schemaRoutes.attachSchema({ usageSchema: swagger.usageSchema, parsedSchemas, }); @@ -149,10 +152,14 @@ class CodeGenProcess { return schemas; }; + const modelTypes = (await Promise.all(_.map(sortSchemas(usageComponentSchemas), this.prepareModelType))).filter( + Boolean, + ); + const rawConfiguration = { apiConfig: this.createApiConfig(swagger.usageSchema), config: this.config, - modelTypes: _.map(sortSchemas(usageComponentSchemas), this.prepareModelType).filter(Boolean), + modelTypes: modelTypes, rawModelTypes: usageComponentSchemas, hasSecurityRoutes: this.schemaRoutes.hasSecurityRoutes, hasQueryRoutes: this.schemaRoutes.hasQueryRoutes, @@ -175,7 +182,7 @@ class CodeGenProcess { this.fileSystem.createDir(this.config.output); } - const files = this.generateOutputFiles({ + const files = await this.generateOutputFiles({ configuration: configuration, }); @@ -215,7 +222,7 @@ class CodeGenProcess { files: generatedFiles, configuration, getTemplate: this.templates.getTemplate, - renderTemplate: this.templates.renderTemplate, + renderTemplate: await this.templates.renderTemplate, createFile: this.fileSystem.createFile, formatTSContent: this.codeFormatter.formatCode, }; @@ -250,9 +257,9 @@ class CodeGenProcess { }; }; - prepareModelType = (typeInfo) => { + prepareModelType = async (typeInfo) => { if (!typeInfo.typeData) { - typeInfo.typeData = this.schemaParser.parseSchema(typeInfo.rawTypeData, typeInfo.typeName); + typeInfo.typeData = await this.schemaParser.parseSchema(typeInfo.rawTypeData, typeInfo.typeName); } const rawTypeData = typeInfo.typeData; const typeData = this.schemaParser.schemaFormatters.base[rawTypeData.type] @@ -275,36 +282,41 @@ class CodeGenProcess { }; }; - generateOutputFiles = ({ configuration }) => { + generateOutputFiles = async ({ configuration }) => { const { modular, templatesToRender } = this.config; const output = modular - ? this.createMultipleFileInfos(templatesToRender, configuration) - : this.createSingleFileInfo(templatesToRender, configuration); + ? await this.createMultipleFileInfos(templatesToRender, configuration) + : await this.createSingleFileInfo(templatesToRender, configuration); if (!_.isEmpty(configuration.extraTemplates)) { output.push( - ..._.map(configuration.extraTemplates, (extraTemplate) => { - return this.createOutputFileInfo( - configuration, - extraTemplate.name, - this.templates.renderTemplate(this.fileSystem.getFileContent(extraTemplate.path), configuration), - ); - }), + ...(await Promise.all( + _.map(configuration.extraTemplates, async (extraTemplate) => { + return this.createOutputFileInfo( + configuration, + extraTemplate.name, + await await this.templates.renderTemplate( + this.fileSystem.getFileContent(extraTemplate.path), + configuration, + ), + ); + }), + )), ); } return output.filter((fileInfo) => !!fileInfo && !!fileInfo.content); }; - createMultipleFileInfos = (templatesToRender, configuration) => { + createMultipleFileInfos = async (templatesToRender, configuration) => { const { routes } = configuration; const { fileNames, generateRouteTypes, generateClient } = configuration.config; const modularApiFileInfos = []; if (routes.$outOfModule) { if (generateRouteTypes) { - const outOfModuleRouteContent = this.templates.renderTemplate(templatesToRender.routeTypes, { + const outOfModuleRouteContent = await this.templates.renderTemplate(templatesToRender.routeTypes, { ...configuration, route: configuration.routes.$outOfModule, }); @@ -314,7 +326,7 @@ class CodeGenProcess { ); } if (generateClient) { - const outOfModuleApiContent = this.templates.renderTemplate(templatesToRender.api, { + const outOfModuleApiContent = await this.templates.renderTemplate(templatesToRender.api, { ...configuration, route: configuration.routes.$outOfModule, }); @@ -326,56 +338,48 @@ class CodeGenProcess { } if (routes.combined) { - modularApiFileInfos.push( - ..._.reduce( - routes.combined, - (apiFileInfos, route) => { - if (generateRouteTypes) { - const routeModuleContent = this.templates.renderTemplate(templatesToRender.routeTypes, { - ...configuration, - route, - }); - - apiFileInfos.push( - this.createOutputFileInfo(configuration, pascalCase(`${route.moduleName}_Route`), routeModuleContent), - ); - } - - if (generateClient) { - const apiModuleContent = this.templates.renderTemplate(templatesToRender.api, { - ...configuration, - route, - }); - - apiFileInfos.push( - this.createOutputFileInfo(configuration, pascalCase(route.moduleName), apiModuleContent), - ); - } - - return apiFileInfos; - }, - [], - ), - ); + for await (const route of routes.combined) { + if (generateRouteTypes) { + const routeModuleContent = await this.templates.renderTemplate(templatesToRender.routeTypes, { + ...configuration, + route, + }); + + modularApiFileInfos.push( + this.createOutputFileInfo(configuration, pascalCase(`${route.moduleName}_Route`), routeModuleContent), + ); + } + + if (generateClient) { + const apiModuleContent = await this.templates.renderTemplate(templatesToRender.api, { + ...configuration, + route, + }); + + modularApiFileInfos.push( + this.createOutputFileInfo(configuration, pascalCase(route.moduleName), apiModuleContent), + ); + } + } } return [ this.createOutputFileInfo( configuration, fileNames.dataContracts, - this.templates.renderTemplate(templatesToRender.dataContracts, configuration), + await this.templates.renderTemplate(templatesToRender.dataContracts, configuration), ), generateClient && this.createOutputFileInfo( configuration, fileNames.httpClient, - this.templates.renderTemplate(templatesToRender.httpClient, configuration), + await this.templates.renderTemplate(templatesToRender.httpClient, configuration), ), ...modularApiFileInfos, ]; }; - createSingleFileInfo = (templatesToRender, configuration) => { + createSingleFileInfo = async (templatesToRender, configuration) => { const { generateRouteTypes, generateClient } = configuration.config; return [ @@ -383,10 +387,10 @@ class CodeGenProcess { configuration, configuration.fileName, _.compact([ - this.templates.renderTemplate(templatesToRender.dataContracts, configuration), - generateRouteTypes && this.templates.renderTemplate(templatesToRender.routeTypes, configuration), - generateClient && this.templates.renderTemplate(templatesToRender.httpClient, configuration), - generateClient && this.templates.renderTemplate(templatesToRender.api, configuration), + await this.templates.renderTemplate(templatesToRender.dataContracts, configuration), + generateRouteTypes && (await this.templates.renderTemplate(templatesToRender.routeTypes, configuration)), + generateClient && (await this.templates.renderTemplate(templatesToRender.httpClient, configuration)), + generateClient && (await this.templates.renderTemplate(templatesToRender.api, configuration)), ]).join("\n"), ), ]; diff --git a/src/configuration.js b/src/configuration.js index 091b7da3..bf292dea 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -280,8 +280,8 @@ class CodeGenConfig { "relative-json-pointer": () => this.Ts.Keyword.String, regex: () => this.Ts.Keyword.String, }, - array: ({ items, ...schemaPart }, parser) => { - const content = parser.getInlineParseContent(items); + array: async ({ items, ...schemaPart }, parser) => { + const content = await parser.getInlineParseContent(items); return parser.schemaUtils.safeAddNullToType(schemaPart, this.Ts.ArrayType(content)); }, }; diff --git a/src/schema-parser/schema-formatters.js b/src/schema-parser/schema-formatters.js index 82c790c6..eb4b5930 100644 --- a/src/schema-parser/schema-formatters.js +++ b/src/schema-parser/schema-formatters.js @@ -42,12 +42,12 @@ class SchemaFormatters { content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content), }; }, - [SCHEMA_TYPES.OBJECT]: (parsedSchema) => { + [SCHEMA_TYPES.OBJECT]: async (parsedSchema) => { if (parsedSchema.nullable) return this.inline[SCHEMA_TYPES.OBJECT](parsedSchema); return { ...parsedSchema, $content: parsedSchema.content, - content: this.formatObjectContent(parsedSchema.content), + content: await this.formatObjectContent(parsedSchema.content), }; }, [SCHEMA_TYPES.PRIMITIVE]: (parsedSchema) => { @@ -71,7 +71,7 @@ class SchemaFormatters { ), }; }, - [SCHEMA_TYPES.OBJECT]: (parsedSchema) => { + [SCHEMA_TYPES.OBJECT]: async (parsedSchema) => { if (_.isString(parsedSchema.content)) { return { ...parsedSchema, @@ -86,7 +86,7 @@ class SchemaFormatters { content: this.schemaParser.schemaUtils.safeAddNullToType( parsedSchema, parsedSchema.content.length - ? this.config.Ts.ObjectWrapper(this.formatObjectContent(parsedSchema.content)) + ? this.config.Ts.ObjectWrapper(await this.formatObjectContent(parsedSchema.content)) : this.config.Ts.RecordType(Ts.Keyword.String, this.config.Ts.Keyword.Any), ), }; @@ -126,24 +126,28 @@ class SchemaFormatters { return _.replace(prettified, /\n$/g, ""); }; - formatObjectContent = (content) => { - return _.map(content, (part) => { - const extraSpace = " "; - const result = `${extraSpace}${part.field},\n`; + formatObjectContent = async (content) => { + return ( + await Promise.all( + _.map(content, async (part) => { + const extraSpace = " "; + const result = `${extraSpace}${part.field},\n`; - const renderedJsDoc = this.templates.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { - data: part, - }); + const renderedJsDoc = await this.templates.renderTemplate(this.config.templatesToRender.dataContractJsDoc, { + data: part, + }); - const routeNameFromTemplate = renderedJsDoc - .split("\n") - .map((c) => `${extraSpace}${c}`) - .join("\n"); + const routeNameFromTemplate = renderedJsDoc + .split("\n") + .map((c) => `${extraSpace}${c}`) + .join("\n"); - if (routeNameFromTemplate) return `${routeNameFromTemplate}${result}`; + if (routeNameFromTemplate) return `${routeNameFromTemplate}${result}`; - return `${result}`; - }).join(""); + return `${result}`; + }), + ) + ).join(""); }; } diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index 0fd7a4dc..0fbc3963 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -42,10 +42,12 @@ class SchemaParser { complexSchemaParsers = { // T1 | T2 - [SCHEMA_TYPES.COMPLEX_ONE_OF]: (schema) => { + [SCHEMA_TYPES.COMPLEX_ONE_OF]: async (schema) => { const ignoreTypes = [this.config.Ts.Keyword.Any]; - const combined = _.map(schema.oneOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + const combined = await Promise.all( + _.map(schema.oneOf, (childSchema) => + this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -54,10 +56,12 @@ class SchemaParser { return this.schemaUtils.safeAddNullToType(schema, type); }, // T1 & T2 - [SCHEMA_TYPES.COMPLEX_ALL_OF]: (schema) => { + [SCHEMA_TYPES.COMPLEX_ALL_OF]: async (schema) => { const ignoreTypes = [...this.config.jsPrimitiveTypes, this.config.Ts.Keyword.Any]; - const combined = _.map(schema.allOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + const combined = await Promise.all( + _.map(schema.allOf, (childSchema) => + this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -66,10 +70,12 @@ class SchemaParser { return this.schemaUtils.safeAddNullToType(schema, type); }, // T1 | T2 | (T1 & T2) - [SCHEMA_TYPES.COMPLEX_ANY_OF]: (schema) => { + [SCHEMA_TYPES.COMPLEX_ANY_OF]: async (schema) => { const ignoreTypes = [...this.config.jsPrimitiveTypes, this.config.Ts.Keyword.Any]; - const combined = _.map(schema.anyOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + const combined = await Promise.all( + _.map(schema.anyOf, (childSchema) => + this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -90,7 +96,7 @@ class SchemaParser { }; baseSchemaParsers = { - [SCHEMA_TYPES.ENUM]: (schema, typeName) => { + [SCHEMA_TYPES.ENUM]: async (schema, typeName) => { if (this.config.extractEnums && !typeName) { const generatedTypeName = this.config.componentTypeNameResolver.resolve([this.buildTypeNameFromPath()]); const schemaComponent = this.schemaComponentsMap.createComponent("schemas", generatedTypeName, { ...schema }); @@ -99,18 +105,18 @@ class SchemaParser { const refType = this.schemaUtils.getSchemaRefType(schema); const $ref = (refType && refType.$ref) || null; - const keyType = this.getSchemaType(schema); + const keyType = await this.getSchemaType(schema); const enumNames = this.schemaUtils.getEnumNames(schema); let content = null; - const formatValue = (value) => { + const formatValue = async (value) => { if (value === null) { return this.config.Ts.NullValue(value); } - if (keyType === this.getSchemaType({ type: "number" })) { + if (keyType === (await this.getSchemaType({ type: "number" }))) { return this.config.Ts.NumberValue(value); } - if (keyType === this.getSchemaType({ type: "boolean" })) { + if (keyType === (await this.getSchemaType({ type: "boolean" }))) { return this.config.Ts.BooleanValue(value); } @@ -118,41 +124,45 @@ class SchemaParser { }; if (_.isArray(enumNames) && _.size(enumNames)) { - content = _.map(enumNames, (enumName, index) => { - const enumValue = _.get(schema.enum, index); - const formattedKey = - (enumName && - this.typeName.format(enumName, { + content = await Promise.all( + _.map(enumNames, async (enumName, index) => { + const enumValue = _.get(schema.enum, index); + const formattedKey = + (enumName && + this.typeName.format(enumName, { + type: "enum-key", + })) || + this.typeName.format(`${enumValue}`, { type: "enum-key", - })) || - this.typeName.format(`${enumValue}`, { - type: "enum-key", - }); + }); + + if (this.config.enumNamesAsValues || _.isUndefined(enumValue)) { + return { + key: formattedKey, + type: this.config.Ts.Keyword.String, + value: this.config.Ts.StringValue(enumName), + }; + } - if (this.config.enumNamesAsValues || _.isUndefined(enumValue)) { return { key: formattedKey, - type: this.config.Ts.Keyword.String, - value: this.config.Ts.StringValue(enumName), + type: keyType, + value: await formatValue(enumValue), }; - } - - return { - key: formattedKey, - type: keyType, - value: formatValue(enumValue), - }; - }); + }), + ); } else { - content = _.map(schema.enum, (key) => { - return { - key: this.typeName.format(`${key}`, { - type: "enum-key", - }), - type: keyType, - value: formatValue(key), - }; - }); + content = await Promise.all( + _.map(schema.enum, async (key) => { + return { + key: this.typeName.format(`${key}`, { + type: "enum-key", + }), + type: keyType, + value: await formatValue(key), + }; + }), + ); } return { @@ -169,8 +179,8 @@ class SchemaParser { content, }; }, - [SCHEMA_TYPES.OBJECT]: (schema, typeName) => { - const contentProperties = this.getObjectSchemaContent(schema); + [SCHEMA_TYPES.OBJECT]: async (schema, typeName) => { + const contentProperties = await this.getObjectSchemaContent(schema); return { ...(_.isObject(schema) ? schema : {}), @@ -184,10 +194,10 @@ class SchemaParser { content: contentProperties, }; }, - [SCHEMA_TYPES.COMPLEX]: (schema, typeName) => { + [SCHEMA_TYPES.COMPLEX]: async (schema, typeName) => { const complexType = this.getComplexType(schema); const simpleSchema = _.omit(_.clone(schema), _.keys(this.complexSchemaParsers)); - const complexSchemaContent = this.complexSchemaParsers[complexType](schema); + const complexSchemaContent = await this.complexSchemaParsers[complexType](schema); return { ...(_.isObject(schema) ? schema : {}), @@ -204,24 +214,24 @@ class SchemaParser { _.compact([ this.config.Ts.ExpressionGroup(complexSchemaContent), this.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && - this.config.Ts.ExpressionGroup(this.getInlineParseContent(simpleSchema)), + this.config.Ts.ExpressionGroup(await this.getInlineParseContent(simpleSchema)), ]), ) || this.config.Ts.Keyword.Any, }; }, - [SCHEMA_TYPES.PRIMITIVE]: (schema, typeName) => { + [SCHEMA_TYPES.PRIMITIVE]: async (schema, typeName) => { let contentType = null; const { additionalProperties, type, description, $$requiredKeys } = schema || {}; if (type === this.config.Ts.Keyword.Object && additionalProperties) { const fieldType = _.isObject(additionalProperties) - ? this.getInlineParseContent(additionalProperties) + ? await this.getInlineParseContent(additionalProperties) : this.config.Ts.Keyword.Any; contentType = this.config.Ts.RecordType(this.config.Ts.Keyword.String, fieldType); } if (_.isArray(type) && type.length) { - contentType = this.complexSchemaParsers.oneOf({ + contentType = await this.complexSchemaParsers.oneOf({ ...(_.isObject(schema) ? schema : {}), oneOf: type.map((type) => ({ type })), }); @@ -236,7 +246,7 @@ class SchemaParser { name: typeName, description: this.schemaFormatters.formatDescription(description), // TODO: probably it should be refactored. `type === 'null'` is not flexible - content: type === this.config.Ts.Keyword.Null ? type : contentType || this.getSchemaType(schema), + content: type === this.config.Ts.Keyword.Null ? type : contentType || (await this.getSchemaType(schema)), }; }, }; @@ -249,7 +259,7 @@ class SchemaParser { return SCHEMA_TYPES.PRIMITIVE; }; - getSchemaType = (schema) => { + getSchemaType = async (schema) => { if (!schema) return this.config.Ts.Keyword.Any; const refTypeInfo = this.schemaUtils.getSchemaRefType(schema); @@ -267,13 +277,16 @@ class SchemaParser { let resultType; + /** + * @type {string | (() => Promise)} + */ const typeAlias = _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || this.config.primitiveTypes[primitiveType]; if (_.isFunction(typeAlias)) { - resultType = typeAlias(schema, this); + resultType = await typeAlias(schema, this); } else { resultType = typeAlias || primitiveType; } @@ -283,42 +296,44 @@ class SchemaParser { return this.schemaUtils.checkAndAddRequiredKeys(schema, this.schemaUtils.safeAddNullToType(schema, resultType)); }; - getObjectSchemaContent = (schema) => { + getObjectSchemaContent = async (schema) => { const { properties, additionalProperties } = schema || {}; - const propertiesContent = _.map(properties, (property, name) => { - this.$processingSchemaPath.push(name); - const required = this.schemaUtils.isPropertyRequired(name, property, schema); - const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); - const nullable = !!(rawTypeData.nullable || property.nullable); - const fieldName = this.typeName.isValidName(name) ? name : this.config.Ts.StringValue(name); - const fieldValue = this.getInlineParseContent(property); - const readOnly = property.readOnly; - - this.$processingSchemaPath.pop(); - - return { - ...property, - $$raw: property, - title: property.title, - description: - property.description || - _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || - rawTypeData.description || - _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || - "", - isRequired: required, - isNullable: nullable, - name: fieldName, - value: fieldValue, - field: this.config.Ts.TypeField({ - readonly: readOnly && this.config.addReadonly, - optional: !required, - key: fieldName, + const propertiesContent = await Promise.all( + _.map(properties, async (property, name) => { + this.$processingSchemaPath.push(name); + const required = this.schemaUtils.isPropertyRequired(name, property, schema); + const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); + const nullable = !!(rawTypeData.nullable || property.nullable); + const fieldName = this.typeName.isValidName(name) ? name : this.config.Ts.StringValue(name); + const fieldValue = await this.getInlineParseContent(property); + const readOnly = property.readOnly; + + this.$processingSchemaPath.pop(); + + return { + ...property, + $$raw: property, + title: property.title, + description: + property.description || + _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || + rawTypeData.description || + _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || + "", + isRequired: required, + isNullable: nullable, + name: fieldName, value: fieldValue, - }), - }; - }); + field: this.config.Ts.TypeField({ + readonly: readOnly && this.config.addReadonly, + optional: !required, + key: fieldName, + value: fieldValue, + }), + }; + }), + ); if (additionalProperties) { propertiesContent.push({ @@ -347,10 +362,10 @@ class SchemaParser { * @param schema {any} * @param typeName {null | string} * @param formatter {"inline" | "base"} - * @return {Record} + * @return {Promise>} */ - parseSchema = (schema, typeName = null) => { - if (!schema) return this.baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, typeName); + parseSchema = async (schema, typeName = null) => { + if (!schema) return await this.baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, typeName); let schemaType = null; let parsedSchema = null; @@ -361,7 +376,7 @@ class SchemaParser { if (!schema.$parsed) { if (!typeName && this.schemaUtils.isRefSchema(schema)) { - typeName = this.getSchemaType(schema); + typeName = await this.getSchemaType(schema); } if (schema.items && !schema.type) { @@ -372,7 +387,7 @@ class SchemaParser { this.$processingSchemaPath.push(typeName); _.merge(schema, this.config.hooks.onPreParseSchema(schema, typeName, schemaType)); - parsedSchema = this.baseSchemaParsers[schemaType](schema, typeName); + parsedSchema = await this.baseSchemaParsers[schemaType](schema, typeName); schema.$parsed = this.config.hooks.onParseSchema(schema, parsedSchema) || parsedSchema; } @@ -381,14 +396,14 @@ class SchemaParser { return schema.$parsed; }; - getInlineParseContent = (rawTypeData, typeName) => { - const parsedSchema = this.parseSchema(rawTypeData, typeName); + getInlineParseContent = async (rawTypeData, typeName) => { + const parsedSchema = await this.parseSchema(rawTypeData, typeName); const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "inline"); return formattedSchema.content; }; - getParseContent = (rawTypeData, typeName) => { - const parsedSchema = this.parseSchema(rawTypeData, typeName); + getParseContent = async (rawTypeData, typeName) => { + const parsedSchema = await this.parseSchema(rawTypeData, typeName); const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "base"); return formattedSchema.content; }; diff --git a/src/schema-parser/schema-routes.js b/src/schema-parser/schema-routes.js index 10fb8375..9009d2f4 100644 --- a/src/schema-parser/schema-routes.js +++ b/src/schema-parser/schema-routes.js @@ -59,10 +59,12 @@ class SchemaRoutes { this.schemaComponentMap = schemaComponentMap; this.logger = logger; this.templates = templates; + } + async init() { this.FORM_DATA_TYPES = _.uniq([ - this.schemaParser.getSchemaType({ type: "string", format: "file" }), - this.schemaParser.getSchemaType({ type: "string", format: "binary" }), + await this.schemaParser.getSchemaType({ type: "string", format: "file" }), + await this.schemaParser.getSchemaType({ type: "string", format: "binary" }), ]); } @@ -303,13 +305,13 @@ class SchemaRoutes { return null; }; - getTypeFromRequestInfo = ({ requestInfo, parsedSchemas, operationId, defaultType, typeName }) => { + getTypeFromRequestInfo = async ({ requestInfo, parsedSchemas, operationId, defaultType, typeName }) => { // TODO: make more flexible pick schema without content type const schema = this.getSchemaFromRequestType(requestInfo); const refTypeInfo = this.schemaParser.schemaUtils.getSchemaRefType(requestInfo); if (schema) { - const content = this.schemaParser.getInlineParseContent(schema, typeName); + const content = await this.schemaParser.getInlineParseContent(schema, typeName); const foundedSchemaByName = _.find( parsedSchemas, (parsedSchema) => this.typeName.format(parsedSchema.name) === content, @@ -336,54 +338,56 @@ class SchemaRoutes { return this.typeName.format(refTypeInfo.typeName); case "responses": case "requestBodies": - return this.schemaParser.getInlineParseContent( + return await this.schemaParser.getInlineParseContent( this.getSchemaFromRequestType(refTypeInfo.rawTypeData), refTypeInfo.typeName || null, ); default: - return this.schemaParser.getInlineParseContent(refTypeInfo.rawTypeData, refTypeInfo.typeName || null); + return await this.schemaParser.getInlineParseContent(refTypeInfo.rawTypeData, refTypeInfo.typeName || null); } } return defaultType || this.config.Ts.Keyword.Any; }; - getRequestInfoTypes = ({ requestInfos, parsedSchemas, operationId, defaultType }) => - _.reduce( - requestInfos, - (acc, requestInfo, status) => { - const contentTypes = this.getContentTypes([requestInfo]); - - return [ - ...acc, - { - ...(requestInfo || {}), - contentTypes: contentTypes, - contentKind: this.getContentKind(contentTypes), - type: this.schemaParser.schemaUtils.safeAddNullToType( - requestInfo, - this.getTypeFromRequestInfo({ - requestInfo, - parsedSchemas, - operationId, - defaultType, - }), - ), - description: this.schemaParser.schemaFormatters.formatDescription(requestInfo.description || "", true), - status: _.isNaN(+status) ? status : +status, - isSuccess: this.isSuccessStatus(status), - }, - ]; - }, - [], - ); + getRequestInfoTypes = async ({ requestInfos, parsedSchemas, operationId, defaultType }) => { + const requestInfoTypes = []; + + const statuses = _.entries(requestInfos); + + for await (const [status, requestInfo] of statuses) { + const contentTypes = this.getContentTypes([requestInfo]); + + const requestInfoType = { + ...(requestInfo || {}), + contentTypes: contentTypes, + contentKind: this.getContentKind(contentTypes), + type: this.schemaParser.schemaUtils.safeAddNullToType( + requestInfo, + await this.getTypeFromRequestInfo({ + requestInfo, + parsedSchemas, + operationId, + defaultType, + }), + ), + description: this.schemaParser.schemaFormatters.formatDescription(requestInfo.description || "", true), + status: _.isNaN(+status) ? status : +status, + isSuccess: this.isSuccessStatus(status), + }; + + requestInfoTypes.push(requestInfoType); + } - getResponseBodyInfo = (routeInfo, routeParams, parsedSchemas) => { + return requestInfoTypes; + }; + + getResponseBodyInfo = async (routeInfo, routeParams, parsedSchemas) => { const { produces, operationId, responses } = routeInfo; const contentTypes = this.getContentTypes(responses, [...(produces || []), routeInfo["x-accepts"]]); - const responseInfos = this.getRequestInfoTypes({ + const responseInfos = await this.getRequestInfoTypes({ requestInfos: responses, parsedSchemas, operationId, @@ -395,14 +399,16 @@ class SchemaRoutes { (response) => !response.isSuccess && response.type !== this.config.Ts.Keyword.Any, ); - const handleResponseHeaders = (src) => { + const handleResponseHeaders = async (src) => { if (!src) { return "headers: {},"; } const headerTypes = Object.fromEntries( - Object.entries(src).map(([k, v]) => { - return [k, this.schemaParser.getSchemaType(v)]; - }), + await Promise.all( + Object.entries(src).map(async ([k, v]) => { + return [k, await this.schemaParser.getSchemaType(v)]; + }), + ), ); const r = `headers: { ${Object.entries(headerTypes) .map(([k, v]) => `"${k}": ${v}`) @@ -424,11 +430,13 @@ class SchemaRoutes { full: { types: this.config.Ts.UnionType( - responseInfos.map( - (response) => `{ + await Promise.all( + responseInfos.map( + async (response) => `{ data: ${response.type}, status: ${response.status}, statusCode: ${response.status}, statusText: "${ - response.description - }", ${handleResponseHeaders(response.headers)} config: {} }`, + response.description + }", ${await handleResponseHeaders(response.headers)} config: {} }`, + ), ), ) || this.config.Ts.Keyword.Any, }, @@ -459,7 +467,7 @@ class SchemaRoutes { ); }; - getRequestBodyInfo = (routeInfo, routeParams, parsedSchemas, routeName) => { + getRequestBodyInfo = async (routeInfo, routeParams, parsedSchemas, routeName) => { const { requestBody, consumes, requestBodyName, operationId } = routeInfo; let schema = null; let type = null; @@ -480,15 +488,15 @@ class SchemaRoutes { if (routeParams.formData.length) { contentKind = CONTENT_KIND.FORM_DATA; schema = this.convertRouteParamsIntoObject(routeParams.formData); - type = this.schemaParser.getInlineParseContent(schema, typeName); + type = await this.schemaParser.getInlineParseContent(schema, typeName); } else if (contentKind === CONTENT_KIND.FORM_DATA) { schema = this.getSchemaFromRequestType(requestBody); - type = this.schemaParser.getInlineParseContent(schema, typeName); + type = await this.schemaParser.getInlineParseContent(schema, typeName); } else if (requestBody) { schema = this.getSchemaFromRequestType(requestBody); type = this.schemaParser.schemaUtils.safeAddNullToType( requestBody, - this.getTypeFromRequestInfo({ + await this.getTypeFromRequestInfo({ requestInfo: requestBody, parsedSchemas, operationId, @@ -506,7 +514,7 @@ class SchemaRoutes { if (schema && !schema.$ref && this.config.extractRequestBody) { schema = this.schemaComponentMap.createComponent("schemas", typeName, { ...schema }); - type = this.schemaParser.getInlineParseContent(schema); + type = await this.schemaParser.getInlineParseContent(schema); } return { @@ -579,7 +587,7 @@ class SchemaRoutes { return schema; }; - extractResponseBodyIfItNeeded = (routeInfo, responseBodyInfo, routeName) => { + extractResponseBodyIfItNeeded = async (routeInfo, responseBodyInfo, routeName) => { if (responseBodyInfo.responses.length && responseBodyInfo.success && responseBodyInfo.success.schema) { const typeName = this.config.componentTypeNameResolver.resolve([ pascalCase(`${routeName.usage} Data`), @@ -594,7 +602,7 @@ class SchemaRoutes { if (successResponse.schema && !successResponse.schema.$ref) { const schema = this.getSchemaFromRequestType(successResponse.schema); successResponse.schema = this.schemaComponentMap.createComponent("schemas", typeName, { ...schema }); - successResponse.type = this.schemaParser.getInlineParseContent(successResponse.schema); + successResponse.type = await this.schemaParser.getInlineParseContent(successResponse.schema); if (idx > -1) { _.assign(responseBodyInfo.responses[idx], { @@ -606,7 +614,7 @@ class SchemaRoutes { } }; - extractResponseErrorIfItNeeded = (routeInfo, responseBodyInfo, routeName) => { + extractResponseErrorIfItNeeded = async (routeInfo, responseBodyInfo, routeName) => { if (responseBodyInfo.responses.length && responseBodyInfo.error.schemas && responseBodyInfo.error.schemas.length) { const typeName = this.config.componentTypeNameResolver.resolve([ pascalCase(`${routeName.usage} Error`), @@ -621,7 +629,7 @@ class SchemaRoutes { if (!errorSchemas.length) return; - const schema = this.schemaParser.parseSchema({ + const schema = await this.schemaParser.parseSchema({ oneOf: errorSchemas, title: errorSchemas .map((schema) => schema.title) @@ -638,12 +646,12 @@ class SchemaRoutes { } }; - getRouteName = (rawRouteInfo) => { + getRouteName = async (rawRouteInfo) => { const { moduleName } = rawRouteInfo; const { routeNameDuplicatesMap, templatesToRender } = this.config; const routeNameTemplate = templatesToRender.routeName; - const routeNameFromTemplate = this.templates.renderTemplate(routeNameTemplate, { + const routeNameFromTemplate = await this.templates.renderTemplate(routeNameTemplate, { routeInfo: rawRouteInfo, }); @@ -675,7 +683,7 @@ class SchemaRoutes { return this.config.hooks.onCreateRouteName(routeNameInfo, rawRouteInfo) || routeNameInfo; }; - parseRouteInfo = (rawRouteName, routeInfo, method, usageSchema, parsedSchemas) => { + parseRouteInfo = async (rawRouteName, routeInfo, method, usageSchema, parsedSchemas) => { const { security: globalSecurity } = usageSchema; const { moduleNameIndex, moduleNameFirstTag, extractRequestParams } = this.config; const { @@ -711,15 +719,17 @@ class SchemaRoutes { const routeParams = this.getRouteParams(routeInfo, pathParamsFromRouteName, queryParamsFromRouteName); - const pathArgs = routeParams.path.map((pathArgSchema) => ({ - name: pathArgSchema.name, - optional: !pathArgSchema.required, - type: this.schemaParser.getInlineParseContent(pathArgSchema.schema), - description: pathArgSchema.description, - })); + const pathArgs = await Promise.all( + routeParams.path.map(async (pathArgSchema) => ({ + name: pathArgSchema.name, + optional: !pathArgSchema.required, + type: await this.schemaParser.getInlineParseContent(pathArgSchema.schema), + description: pathArgSchema.description, + })), + ); const pathArgsNames = pathArgs.map((arg) => arg.name); - const responseBodyInfo = this.getResponseBodyInfo(routeInfo, routeParams, parsedSchemas); + const responseBodyInfo = await this.getResponseBodyInfo(routeInfo, routeParams, parsedSchemas); const rawRouteInfo = { ...otherInfo, @@ -742,7 +752,7 @@ class SchemaRoutes { const pathObjectSchema = this.convertRouteParamsIntoObject(routeParams.path); const headersObjectSchema = this.convertRouteParamsIntoObject(routeParams.header); - const routeName = this.getRouteName(rawRouteInfo); + const routeName = await this.getRouteName(rawRouteInfo); const requestBodyInfo = this.getRequestBodyInfo(routeInfo, routeParams, parsedSchemas, routeName); @@ -755,15 +765,19 @@ class SchemaRoutes { }); if (this.config.extractResponseBody) { - this.extractResponseBodyIfItNeeded(routeInfo, responseBodyInfo, routeName); + await this.extractResponseBodyIfItNeeded(routeInfo, responseBodyInfo, routeName); } if (this.config.extractResponseError) { - this.extractResponseErrorIfItNeeded(routeInfo, responseBodyInfo, routeName); + await this.extractResponseErrorIfItNeeded(routeInfo, responseBodyInfo, routeName); } - const queryType = routeParams.query.length ? this.schemaParser.getInlineParseContent(queryObjectSchema) : null; - const pathType = routeParams.path.length ? this.schemaParser.getInlineParseContent(pathObjectSchema) : null; - const headersType = routeParams.header.length ? this.schemaParser.getInlineParseContent(headersObjectSchema) : null; + const queryType = routeParams.query.length + ? await this.schemaParser.getInlineParseContent(queryObjectSchema) + : null; + const pathType = routeParams.path.length ? await this.schemaParser.getInlineParseContent(pathObjectSchema) : null; + const headersType = routeParams.header.length + ? await this.schemaParser.getInlineParseContent(headersObjectSchema) + : null; const nameResolver = new SpecificArgNameResolver(pathArgsNames); @@ -771,7 +785,7 @@ class SchemaRoutes { query: queryType ? { name: nameResolver.resolve(RESERVED_QUERY_ARG_NAMES), - optional: this.schemaParser.parseSchema(queryObjectSchema).allFieldsAreOptional, + optional: await this.schemaParser.parseSchema(queryObjectSchema).allFieldsAreOptional, type: queryType, } : void 0, @@ -785,14 +799,14 @@ class SchemaRoutes { pathParams: pathType ? { name: nameResolver.resolve(RESERVED_PATH_ARG_NAMES), - optional: this.schemaParser.parseSchema(pathObjectSchema).allFieldsAreOptional, + optional: await this.schemaParser.parseSchema(pathObjectSchema).allFieldsAreOptional, type: pathType, } : void 0, headers: headersType ? { name: nameResolver.resolve(RESERVED_HEADER_ARG_NAMES), - optional: this.schemaParser.parseSchema(headersObjectSchema).allFieldsAreOptional, + optional: await this.schemaParser.parseSchema(headersObjectSchema).allFieldsAreOptional, type: headersType, } : void 0, @@ -837,16 +851,16 @@ class SchemaRoutes { }; }; - attachSchema = ({ usageSchema, parsedSchemas }) => { + attachSchema = async ({ usageSchema, parsedSchemas }) => { this.config.routeNameDuplicatesMap.clear(); const pathsEntries = _.entries(usageSchema.paths); - _.forEach(pathsEntries, ([rawRouteName, routeInfoByMethodsMap]) => { + for await (const [rawRouteName, routeInfoByMethodsMap] of pathsEntries) { const routeInfosMap = this.createRequestsMap(routeInfoByMethodsMap); - _.forEach(routeInfosMap, (routeInfo, method) => { - const parsedRouteInfo = this.parseRouteInfo(rawRouteName, routeInfo, method, usageSchema, parsedSchemas); + for await (const [method, routeInfo] of _.entries(routeInfosMap)) { + const parsedRouteInfo = await this.parseRouteInfo(rawRouteName, routeInfo, method, usageSchema, parsedSchemas); const processedRouteInfo = this.config.hooks.onCreateRoute(parsedRouteInfo); const route = processedRouteInfo || parsedRouteInfo; @@ -861,8 +875,8 @@ class SchemaRoutes { } this.routes.push(route); - }); - }); + } + } }; getGroupedRoutes = () => { diff --git a/src/templates.js b/src/templates.js index bbe352b5..69bca81a 100644 --- a/src/templates.js +++ b/src/templates.js @@ -152,20 +152,20 @@ class Templates { return ""; }; - renderTemplate = (template, configuration, options) => { + renderTemplate = async (template, configuration, options) => { if (!template) return ""; - return Eta.render( + return Eta.renderAsync( template, { ...this.getRenderTemplateData(), ...configuration, }, { - async: false, + async: true, ...(options || {}), - includeFile: (path, payload, options) => { - return this.renderTemplate(this.getTemplateContent(path), payload, options); + includeFile: async (path, payload, options) => { + return await this.renderTemplate(this.getTemplateContent(path), payload, options); }, }, ); diff --git a/templates/default/api.ejs b/templates/default/api.ejs index 5aee183b..0bf95d6e 100644 --- a/templates/default/api.ejs +++ b/templates/default/api.ejs @@ -49,7 +49,7 @@ export class <%~ config.apiClassName %><% if ( <% routes.outOfModule && routes.outOfModule.forEach((route) => { %> - <%~ includeFile('./procedure-call.ejs', { ...it, route }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> <% }) %> @@ -57,7 +57,7 @@ export class <%~ config.apiClassName %><% if ( <%~ moduleName %> = { <% routes.forEach((route) => { %> - <%~ includeFile('./procedure-call.ejs', { ...it, route }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> <% }) %> } diff --git a/templates/default/procedure-call.ejs b/templates/default/procedure-call.ejs index 465d6327..7efd5b7b 100644 --- a/templates/default/procedure-call.ejs +++ b/templates/default/procedure-call.ejs @@ -5,7 +5,7 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe const { parameters, path, method, payload, query, formData, security, requestParams } = route.request; const { type, errorType, contentTypes } = route.response; const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants; -const routeDocs = includeFile("@base/route-docs", { config, route, utils }); +const routeDocs = await includeFile("@base/route-docs", { config, route, utils }); const queryName = (query && query.name) || "query"; const pathParams = _.values(parameters); const pathParamsNames = _.map(pathParams, "name"); @@ -26,7 +26,7 @@ const rawWrapperArgs = config.extractRequestParams ? requestParams && { name: pathParams.length ? `{ ${_.join(pathParamsNames, ", ")}, ...${queryName} }` : queryName, optional: false, - type: getInlineParseContent(requestParams), + type: await getInlineParseContent(requestParams), }, ...(!requestParams ? pathParams : []), payload, diff --git a/templates/default/route-types.ejs b/templates/default/route-types.ejs index 5c9ff567..f61a47bd 100644 --- a/templates/default/route-types.ejs +++ b/templates/default/route-types.ejs @@ -12,16 +12,16 @@ import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataCont /* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */ %> -<% routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %> - <% routes.forEach((route) => { %> - <%~ includeFile('@base/route-type.ejs', { ...it, route }) %> - <% }) %> +<%if (routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %> + <% for await (const route of routes) { %> + <%~ (await includeFile('@base/route-type.ejs', { ...it, route })) %> + <% } %> <% }) %> <% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> export namespace <%~ pascalCase(moduleName) %> { <% routes.forEach((route) => { %> - <%~ includeFile('@base/route-type.ejs', { ...it, route }) %> + <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> <% }) %> } diff --git a/templates/modular/procedure-call.ejs b/templates/modular/procedure-call.ejs index 6f15500f..aa0369e2 100644 --- a/templates/modular/procedure-call.ejs +++ b/templates/modular/procedure-call.ejs @@ -26,7 +26,7 @@ const rawWrapperArgs = config.extractRequestParams ? requestParams && { name: pathParams.length ? `{ ${_.join(pathParamsNames, ", ")}, ...${queryName} }` : queryName, optional: false, - type: getInlineParseContent(requestParams), + type: await getInlineParseContent(requestParams), }, ...(!requestParams ? pathParams : []), payload, diff --git a/tests/generated/v2.0/adafruit.ts b/tests/generated/v2.0/adafruit.ts index 2cc5ce4d..0433627c 100644 --- a/tests/generated/v2.0/adafruit.ts +++ b/tests/generated/v2.0/adafruit.ts @@ -533,19 +533,11 @@ export class Api extends HttpClient + createWebhookFeedData: (token: string, params: RequestParams = {}) => this.request({ path: `/webhooks/feed/${token}`, method: "POST", - body: payload, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -564,7 +556,6 @@ export class Api extends HttpClient extends HttpClient extends HttpClient this.request({ path: `/${username}/activities`, @@ -635,7 +626,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/activities/${type}`, @@ -687,13 +678,11 @@ export class Api extends HttpClient + createDashboard: (username: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards`, method: "POST", - body: dashboard, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -725,13 +714,11 @@ export class Api extends HttpClient + createBlock: (username: string, dashboardId: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${dashboardId}/blocks`, method: "POST", - body: block, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -781,34 +768,11 @@ export class Api extends HttpClient + updateBlock: (username: string, dashboardId: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${dashboardId}/blocks/${id}`, method: "PATCH", - body: block, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -822,34 +786,11 @@ export class Api extends HttpClient + replaceBlock: (username: string, dashboardId: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${dashboardId}/blocks/${id}`, method: "PUT", - body: block, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -899,22 +840,11 @@ export class Api extends HttpClient + updateDashboard: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${id}`, method: "PATCH", - body: dashboard, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -928,22 +858,11 @@ export class Api extends HttpClient + replaceDashboard: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${id}`, method: "PUT", - body: dashboard, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -977,19 +896,16 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds`, method: "POST", query: query, - body: feed, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1038,23 +954,11 @@ export class Api extends HttpClient + updateFeed: (username: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}`, method: "PATCH", - body: feed, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1068,23 +972,11 @@ export class Api extends HttpClient + replaceFeed: (username: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}`, method: "PUT", - body: feed, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1101,7 +993,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data`, @@ -1137,26 +1029,11 @@ export class Api extends HttpClient + createData: (username: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}/data`, method: "POST", - body: datum, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1170,13 +1047,11 @@ export class Api extends HttpClient + batchCreateData: (username: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}/data/batch`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1193,7 +1068,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -1252,18 +1127,17 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/first`, method: "GET", query: query, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1280,18 +1154,17 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/last`, method: "GET", query: query, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1308,18 +1181,17 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/next`, method: "GET", query: query, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1336,18 +1208,17 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/previous`, method: "GET", query: query, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1366,7 +1237,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, @@ -1425,27 +1295,11 @@ export class Api extends HttpClient + updateData: (username: string, feedKey: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, method: "PATCH", - body: datum, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1459,27 +1313,11 @@ export class Api extends HttpClient + replaceData: (username: string, feedKey: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, method: "PUT", - body: datum, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1529,13 +1367,11 @@ export class Api extends HttpClient + createGroup: (username: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups`, method: "POST", - body: group, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1585,22 +1421,11 @@ export class Api extends HttpClient + updateGroup: (username: string, groupKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}`, method: "PATCH", - body: group, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1614,22 +1439,11 @@ export class Api extends HttpClient + replaceGroup: (username: string, groupKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}`, method: "PUT", - body: group, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1646,10 +1460,10 @@ export class Api extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/add`, @@ -1669,32 +1483,11 @@ export class Api extends HttpClient + createGroupData: (username: string, groupKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}/data`, method: "POST", - body: group_feed_data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1726,23 +1519,11 @@ export class Api extends HttpClient + createGroupFeed: (username: string, groupKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}/feeds`, method: "POST", - body: feed, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1760,7 +1541,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data`, @@ -1794,27 +1575,11 @@ export class Api extends HttpClient + createGroupFeedData: (username: string, groupKey: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data`, method: "POST", - body: datum, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1828,27 +1593,11 @@ export class Api extends HttpClient + batchCreateGroupFeedData: (username: string, groupKey: string, feedKey: string, params: RequestParams = {}) => this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data/batch`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1865,10 +1614,10 @@ export class Api extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/remove`, @@ -1932,13 +1681,11 @@ export class Api extends HttpClient + createToken: (username: string, params: RequestParams = {}) => this.request({ path: `/${username}/tokens`, method: "POST", - body: token, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1988,20 +1735,11 @@ export class Api extends HttpClient + updateToken: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/tokens/${id}`, method: "PATCH", - body: token, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2015,20 +1753,11 @@ export class Api extends HttpClient + replaceToken: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/tokens/${id}`, method: "PUT", - body: token, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2060,13 +1789,11 @@ export class Api extends HttpClient + createTrigger: (username: string, params: RequestParams = {}) => this.request({ path: `/${username}/triggers`, method: "POST", - body: trigger, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2116,20 +1843,11 @@ export class Api extends HttpClient + updateTrigger: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/triggers/${id}`, method: "PATCH", - body: trigger, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2143,20 +1861,11 @@ export class Api extends HttpClient + replaceTrigger: (username: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/triggers/${id}`, method: "PUT", - body: trigger, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2188,19 +1897,11 @@ export class Api extends HttpClient + createPermission: (username: string, type: string, typeId: string, params: RequestParams = {}) => this.request({ path: `/${username}/${type}/${typeId}/acl`, method: "POST", - body: permission, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2250,26 +1951,11 @@ export class Api extends HttpClient + updatePermission: (username: string, type: string, typeId: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/${type}/${typeId}/acl/${id}`, method: "PATCH", - body: permission, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -2283,26 +1969,11 @@ export class Api extends HttpClient + replacePermission: (username: string, type: string, typeId: string, id: string, params: RequestParams = {}) => this.request({ path: `/${username}/${type}/${typeId}/acl/${id}`, method: "PUT", - body: permission, secure: true, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/another-example.ts b/tests/generated/v2.0/another-example.ts index e68edcd1..85a49467 100644 --- a/tests/generated/v2.0/another-example.ts +++ b/tests/generated/v2.0/another-example.ts @@ -374,13 +374,11 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pet`, method: "POST", - body: body, secure: true, - type: ContentType.Json, ...params, }), @@ -393,13 +391,11 @@ export class Api extends HttpClient + updatePet: (params: RequestParams = {}) => this.request({ path: `/pet`, method: "PUT", - body: body, secure: true, - type: ContentType.Json, ...params, }), @@ -413,11 +409,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByStatus`, @@ -436,19 +432,10 @@ export class Api extends HttpClient + singleFormUrlEncodedRequest: (params: RequestParams = {}) => this.request({ path: `/pet/single-form-url-encoded`, method: "POST", - body: data, - type: ContentType.UrlEncoded, ...params, }), @@ -460,19 +447,10 @@ export class Api extends HttpClient + formUrlEncodedRequest: (params: RequestParams = {}) => this.request({ path: `/pet/form-url-encoded`, method: "POST", - body: data, - type: ContentType.UrlEncoded, ...params, }), @@ -486,19 +464,10 @@ export class Api extends HttpClient + formUrlEncodedRequest2: (params: RequestParams = {}) => this.request({ path: `/pet/end-form-url-encoded`, method: "POST", - body: data, - type: ContentType.UrlEncoded, ...params, }), @@ -513,11 +482,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByTags`, @@ -555,22 +524,11 @@ export class Api extends HttpClient + updatePetWithForm: (petId: number, params: RequestParams = {}) => this.request({ path: `/pet/${petId}`, method: "POST", - body: data, secure: true, - type: ContentType.FormData, ...params, }), @@ -600,22 +558,11 @@ export class Api extends HttpClient + uploadFile: (petId: number, params: RequestParams = {}) => this.request({ path: `/pet/${petId}/uploadImage`, method: "POST", - body: data, secure: true, - type: ContentType.FormData, format: "json", ...params, }), @@ -647,12 +594,10 @@ export class Api extends HttpClient + placeOrder: (params: RequestParams = {}) => this.request({ path: `/store/order`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -697,12 +642,10 @@ export class Api extends HttpClient + createUser: (params: RequestParams = {}) => this.request({ path: `/user`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -714,12 +657,10 @@ export class Api extends HttpClient + createUsersWithArrayInput: (params: RequestParams = {}) => this.request({ path: `/user/createWithArray`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -731,12 +672,10 @@ export class Api extends HttpClient + createUsersWithListInput: (params: RequestParams = {}) => this.request({ path: `/user/createWithList`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -749,13 +688,13 @@ export class Api extends HttpClient this.request({ path: `/user/login`, @@ -804,12 +743,10 @@ export class Api extends HttpClient + updateUser: (username: string, params: RequestParams = {}) => this.request({ path: `/user/${username}`, method: "PUT", - body: body, - type: ContentType.Json, ...params, }), diff --git a/tests/generated/v2.0/another-schema.ts b/tests/generated/v2.0/another-schema.ts index d336b24e..50b4de18 100644 --- a/tests/generated/v2.0/another-schema.ts +++ b/tests/generated/v2.0/another-schema.ts @@ -268,11 +268,11 @@ export class Api extends HttpClient this.request({ path: `/api/Foo/GetBar`, @@ -289,12 +289,10 @@ export class Api extends HttpClient + fooSetBar: (params: RequestParams = {}) => this.request({ path: `/api/Foo/SetBar`, method: "POST", - body: value, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/api-with-examples.ts b/tests/generated/v2.0/api-with-examples.ts index c57736d7..0bc172d8 100644 --- a/tests/generated/v2.0/api-with-examples.ts +++ b/tests/generated/v2.0/api-with-examples.ts @@ -263,12 +263,10 @@ export class Api extends HttpClient + withCharset: (params: RequestParams = {}) => this.request({ path: `/with-charset/`, method: "POST", - body: someParm, - type: ContentType.Json, ...params, }), }; @@ -280,12 +278,10 @@ export class Api extends HttpClient + consumesPlainText: (params: RequestParams = {}) => this.request({ path: `/consumes-plain-text/`, method: "POST", - body: someParm, - type: ContentType.Text, ...params, }), }; diff --git a/tests/generated/v2.0/authentiq.ts b/tests/generated/v2.0/authentiq.ts index 7fe19e9e..88993fca 100644 --- a/tests/generated/v2.0/authentiq.ts +++ b/tests/generated/v2.0/authentiq.ts @@ -315,6 +315,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -346,7 +346,7 @@ export class Api extends HttpClient + keyRegister: (params: RequestParams = {}) => this.request< { /** revoke key */ @@ -358,7 +358,6 @@ export class Api extends HttpClient({ path: `/key`, method: "POST", - body: body, format: "json", ...params, }), @@ -372,11 +371,11 @@ export class Api extends HttpClient this.request< { @@ -437,7 +436,7 @@ export class Api extends HttpClient + keyUpdate: (pk: string, params: RequestParams = {}) => this.request< { /** confirmed */ @@ -447,7 +446,6 @@ export class Api extends HttpClient({ path: `/key/${pk}`, method: "POST", - body: body, format: "json", ...params, }), @@ -459,7 +457,7 @@ export class Api extends HttpClient + keyBind: (pk: string, params: RequestParams = {}) => this.request< { /** confirmed */ @@ -469,7 +467,6 @@ export class Api extends HttpClient({ path: `/key/${pk}`, method: "PUT", - body: body, format: "json", ...params, }), @@ -483,12 +480,11 @@ export class Api extends HttpClient this.request< { @@ -500,7 +496,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -533,7 +527,6 @@ export class Api extends HttpClient extends HttpClient({ path: `/scope/${job}`, method: "POST", - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/example1.ts b/tests/generated/v2.0/example1.ts index 5fbe9b93..86464a5d 100644 --- a/tests/generated/v2.0/example1.ts +++ b/tests/generated/v2.0/example1.ts @@ -276,19 +276,16 @@ export class Api extends HttpClient this.request({ path: `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Sql/managedInstances/${managedInstanceName}/tdeCertificates`, method: "POST", query: query, - body: parameters, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/file-formdata-example.ts b/tests/generated/v2.0/file-formdata-example.ts index 023d994a..183e47d1 100644 --- a/tests/generated/v2.0/file-formdata-example.ts +++ b/tests/generated/v2.0/file-formdata-example.ts @@ -233,23 +233,10 @@ export class Api extends HttpClient + uploadFile: (params: RequestParams = {}) => this.request({ path: `/upload-file`, method: "POST", - body: data, - type: ContentType.FormData, ...params, }), }; diff --git a/tests/generated/v2.0/giphy.ts b/tests/generated/v2.0/giphy.ts index 358dd58a..570b6326 100644 --- a/tests/generated/v2.0/giphy.ts +++ b/tests/generated/v2.0/giphy.ts @@ -498,11 +498,11 @@ export class Api extends HttpClient this.request< { @@ -532,13 +532,13 @@ export class Api extends HttpClient this.request< { @@ -566,6 +566,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -616,11 +616,11 @@ export class Api extends HttpClient this.request< { @@ -648,7 +648,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -720,13 +720,13 @@ export class Api extends HttpClient this.request< { @@ -754,6 +754,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -804,11 +804,11 @@ export class Api extends HttpClient this.request< { @@ -836,7 +836,8 @@ export class Api extends HttpClient extends HttpClient this.request< { diff --git a/tests/generated/v2.0/github-swagger.ts b/tests/generated/v2.0/github-swagger.ts index a81c8234..a201d019 100644 --- a/tests/generated/v2.0/github-swagger.ts +++ b/tests/generated/v2.0/github-swagger.ts @@ -2136,8 +2136,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/someop`, method: "POST", query: query, - body: data, format: "json", ...params, }), @@ -2171,21 +2169,19 @@ export class Api extends HttpClient this.request({ path: `/someop/${fooId}/bars/bar-bar`, method: "POST", query: query, - body: data, format: "json", ...params, }), @@ -2243,14 +2239,14 @@ export class Api extends HttpClient this.request({ path: `/gists`, @@ -2266,12 +2262,10 @@ export class Api extends HttpClient + gistsCreate: (params: RequestParams = {}) => this.request({ path: `/gists`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -2283,14 +2277,14 @@ export class Api extends HttpClient this.request({ path: `/gists/public`, @@ -2307,14 +2301,14 @@ export class Api extends HttpClient this.request({ path: `/gists/starred`, @@ -2357,12 +2351,10 @@ export class Api extends HttpClient + gistsPartialUpdate: (id: number, params: RequestParams = {}) => this.request({ path: `/gists/${id}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -2387,11 +2379,10 @@ export class Api extends HttpClient + commentsCreate: (id: number, params: RequestParams = {}) => this.request({ path: `/gists/${id}/comments`, method: "POST", - body: body, format: "json", ...params, }), @@ -2431,12 +2422,10 @@ export class Api extends HttpClient + commentsPartialUpdate: (id: number, commentId: number, params: RequestParams = {}) => this.request({ path: `/gists/${id}/comments/${commentId}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -2530,6 +2519,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/issues`, @@ -2592,7 +2581,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/legacy/repos/search/${keyword}`, @@ -2639,7 +2628,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/legacy/user/search/${keyword}`, @@ -2667,12 +2656,10 @@ export class Api extends HttpClient + markdownCreate: (params: RequestParams = {}) => this.request({ path: `/markdown`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -2686,7 +2673,6 @@ export class Api extends HttpClient({ path: `/markdown/raw`, method: "POST", - type: ContentType.Text, ...params, }), }; @@ -2728,7 +2714,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/notifications`, @@ -2758,11 +2744,10 @@ export class Api extends HttpClient + notificationsUpdate: (params: RequestParams = {}) => this.request({ path: `/notifications`, method: "PUT", - body: body, ...params, }), @@ -2826,12 +2811,10 @@ export class Api extends HttpClient + threadsSubscriptionUpdate: (id: number, params: RequestParams = {}) => this.request({ path: `/notifications/threads/${id}/subscription`, method: "PUT", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -2857,12 +2840,10 @@ export class Api extends HttpClient + orgsPartialUpdate: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -2889,6 +2870,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/issues`, @@ -3025,11 +3006,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/repos`, @@ -3045,11 +3026,10 @@ export class Api extends HttpClient + reposCreate: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/repos`, method: "POST", - body: body, format: "json", ...params, }), @@ -3074,12 +3054,10 @@ export class Api extends HttpClient + teamsCreate: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3133,12 +3111,10 @@ export class Api extends HttpClient + reposPartialUpdate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3306,17 +3282,10 @@ export class Api extends HttpClient + commentsPartialUpdate: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/comments/${commentId}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -3330,7 +3299,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits`, @@ -3405,18 +3374,10 @@ export class Api extends HttpClient + commitsCommentsCreate: (owner: string, repo: string, shaCode: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3441,12 +3402,10 @@ export class Api extends HttpClient + contentsDelete: (owner: string, repo: string, path: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "DELETE", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3461,13 +3420,13 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, @@ -3483,12 +3442,10 @@ export class Api extends HttpClient + contentsUpdate: (owner: string, repo: string, path: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "PUT", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3502,11 +3459,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contributors`, @@ -3536,12 +3493,10 @@ export class Api extends HttpClient + deploymentsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/deployments`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3566,18 +3521,10 @@ export class Api extends HttpClient + deploymentsStatusesCreate: (owner: string, repo: string, id: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -3650,11 +3597,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/forks`, @@ -3670,12 +3617,10 @@ export class Api extends HttpClient + forksCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/forks`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3686,12 +3631,10 @@ export class Api extends HttpClient + gitBlobsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/blobs`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3716,12 +3659,10 @@ export class Api extends HttpClient + gitCommitsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/commits`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3760,12 +3701,10 @@ export class Api extends HttpClient + gitRefsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3805,12 +3744,10 @@ export class Api extends HttpClient + gitRefsPartialUpdate: (owner: string, repo: string, ref: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs/${ref}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3821,12 +3758,10 @@ export class Api extends HttpClient + gitTagsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/tags`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3851,12 +3786,10 @@ export class Api extends HttpClient + gitTreesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/trees`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -3871,11 +3804,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, @@ -3905,11 +3838,10 @@ export class Api extends HttpClient + hooksCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks`, method: "POST", - body: body, format: "json", ...params, }), @@ -3949,11 +3881,10 @@ export class Api extends HttpClient + hooksPartialUpdate: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -3980,6 +3911,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues`, @@ -4017,11 +3948,10 @@ export class Api extends HttpClient + issuesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues`, method: "POST", - body: body, format: "json", ...params, }), @@ -4035,7 +3965,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/comments`, @@ -4090,17 +4020,10 @@ export class Api extends HttpClient + issuesCommentsPartialUpdate: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -4157,11 +4080,10 @@ export class Api extends HttpClient + issuesPartialUpdate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -4188,17 +4110,10 @@ export class Api extends HttpClient + issuesCommentsCreate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/comments`, method: "POST", - body: body, format: "json", ...params, }), @@ -4252,11 +4167,10 @@ export class Api extends HttpClient + issuesLabelsCreate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/labels`, method: "POST", - body: body, format: "json", ...params, }), @@ -4267,11 +4181,10 @@ export class Api extends HttpClient + issuesLabelsUpdate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/labels`, method: "PUT", - body: body, format: "json", ...params, }), @@ -4311,11 +4224,10 @@ export class Api extends HttpClient + keysCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/keys`, method: "POST", - body: body, format: "json", ...params, }), @@ -4369,11 +4281,10 @@ export class Api extends HttpClient + labelsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels`, method: "POST", - body: body, format: "json", ...params, }), @@ -4413,11 +4324,10 @@ export class Api extends HttpClient + labelsPartialUpdate: (owner: string, repo: string, name: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels/${name}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -4442,12 +4352,10 @@ export class Api extends HttpClient + mergesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/merges`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4461,7 +4369,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones`, @@ -4488,11 +4396,10 @@ export class Api extends HttpClient + milestonesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/milestones`, method: "POST", - body: body, format: "json", ...params, }), @@ -4532,17 +4439,10 @@ export class Api extends HttpClient + milestonesPartialUpdate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/milestones/${number}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -4570,7 +4470,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/notifications`, @@ -4600,11 +4500,10 @@ export class Api extends HttpClient + notificationsUpdate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/notifications`, method: "PUT", - body: body, ...params, }), @@ -4617,7 +4516,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls`, @@ -4647,12 +4546,10 @@ export class Api extends HttpClient + pullsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4666,7 +4563,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/comments`, @@ -4721,17 +4618,10 @@ export class Api extends HttpClient + pullsCommentsPartialUpdate: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -4758,12 +4648,10 @@ export class Api extends HttpClient + pullsPartialUpdate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4790,18 +4678,10 @@ export class Api extends HttpClient + pullsCommentsCreate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}/comments`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4853,12 +4733,10 @@ export class Api extends HttpClient + pullsMergeUpdate: (owner: string, repo: string, number: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}/merge`, method: "PUT", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4872,11 +4750,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/readme`, @@ -4906,11 +4784,10 @@ export class Api extends HttpClient + releasesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases`, method: "POST", - body: body, format: "json", ...params, }), @@ -4948,18 +4825,10 @@ export class Api extends HttpClient + releasesAssetsPartialUpdate: (owner: string, repo: string, id: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases/assets/${id}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -4999,11 +4868,10 @@ export class Api extends HttpClient + releasesPartialUpdate: (owner: string, repo: string, id: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases/${id}`, method: "PATCH", - body: body, format: "json", ...params, }), @@ -5128,12 +4996,10 @@ export class Api extends HttpClient + statusesCreate: (owner: string, repo: string, ref: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/statuses/${ref}`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -5185,12 +5051,10 @@ export class Api extends HttpClient + subscriptionUpdate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/subscription`, method: "PUT", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -5266,14 +5130,14 @@ export class Api extends HttpClient this.request({ path: `/repositories`, @@ -5291,6 +5155,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/code`, @@ -5337,6 +5201,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/issues`, @@ -5365,6 +5229,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/repositories`, @@ -5407,6 +5271,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/users`, @@ -5475,12 +5339,10 @@ export class Api extends HttpClient + teamsPartialUpdate: (teamId: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -5660,12 +5522,10 @@ export class Api extends HttpClient + userPartialUpdate: (params: RequestParams = {}) => this.request({ path: `/user`, method: "PATCH", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -5676,12 +5536,10 @@ export class Api extends HttpClient + emailsDelete: (params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "DELETE", - body: body, - type: ContentType.Json, ...params, }), @@ -5704,11 +5562,10 @@ export class Api extends HttpClient + emailsCreate: (params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "POST", - body: body, ...params, }), @@ -5786,6 +5643,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/issues`, @@ -5837,11 +5694,10 @@ export class Api extends HttpClient + keysCreate: (params: RequestParams = {}) => this.request({ path: `/user/keys`, method: "POST", - body: body, format: "json", ...params, }), @@ -5894,11 +5750,11 @@ export class Api extends HttpClient this.request({ path: `/user/repos`, @@ -5914,11 +5770,10 @@ export class Api extends HttpClient + reposCreate: (params: RequestParams = {}) => this.request({ path: `/user/repos`, method: "POST", - body: body, format: "json", ...params, }), @@ -5930,13 +5785,13 @@ export class Api extends HttpClient this.request({ path: `/user/starred`, @@ -6063,11 +5918,11 @@ export class Api extends HttpClient this.request({ path: `/users`, @@ -6152,14 +6007,14 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/gists`, @@ -6231,11 +6086,11 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/repos`, diff --git a/tests/generated/v2.0/path-args.ts b/tests/generated/v2.0/path-args.ts index 0d1a861b..09dcb131 100644 --- a/tests/generated/v2.0/path-args.ts +++ b/tests/generated/v2.0/path-args.ts @@ -239,14 +239,14 @@ export class Api extends HttpClient this.request({ path: `/pets/${param1}/${param2}/${param3}`, diff --git a/tests/generated/v2.0/petstore-expanded.ts b/tests/generated/v2.0/petstore-expanded.ts index 2158c9d3..0185c637 100644 --- a/tests/generated/v2.0/petstore-expanded.ts +++ b/tests/generated/v2.0/petstore-expanded.ts @@ -288,7 +288,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -313,12 +313,10 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", - body: pet, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore-simple.ts b/tests/generated/v2.0/petstore-simple.ts index 7950a2df..d016bea7 100644 --- a/tests/generated/v2.0/petstore-simple.ts +++ b/tests/generated/v2.0/petstore-simple.ts @@ -262,7 +262,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -287,12 +287,10 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", - body: pet, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore-swagger-io.ts b/tests/generated/v2.0/petstore-swagger-io.ts index cadbd75e..e46b670c 100644 --- a/tests/generated/v2.0/petstore-swagger-io.ts +++ b/tests/generated/v2.0/petstore-swagger-io.ts @@ -320,22 +320,11 @@ export class Api extends HttpClient + updatePetWithForm: (petId: number, params: RequestParams = {}) => this.request({ path: `/pet/${petId}`, method: "POST", - body: data, secure: true, - type: ContentType.FormData, ...params, }), @@ -365,22 +354,11 @@ export class Api extends HttpClient + uploadFile: (petId: number, params: RequestParams = {}) => this.request({ path: `/pet/${petId}/uploadImage`, method: "POST", - body: data, secure: true, - type: ContentType.FormData, format: "json", ...params, }), @@ -394,13 +372,11 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pet`, method: "POST", - body: body, secure: true, - type: ContentType.Json, ...params, }), @@ -413,13 +389,11 @@ export class Api extends HttpClient + updatePet: (params: RequestParams = {}) => this.request({ path: `/pet`, method: "PUT", - body: body, secure: true, - type: ContentType.Json, ...params, }), @@ -433,11 +407,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByStatus`, @@ -459,11 +433,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByTags`, @@ -532,12 +506,10 @@ export class Api extends HttpClient + placeOrder: (params: RequestParams = {}) => this.request({ path: `/store/order`, method: "POST", - body: body, - type: ContentType.Json, format: "json", ...params, }), @@ -567,12 +539,10 @@ export class Api extends HttpClient + updateUser: (username: string, params: RequestParams = {}) => this.request({ path: `/user/${username}`, method: "PUT", - body: body, - type: ContentType.Json, ...params, }), @@ -600,13 +570,13 @@ export class Api extends HttpClient this.request({ path: `/user/login`, @@ -639,12 +609,10 @@ export class Api extends HttpClient + createUser: (params: RequestParams = {}) => this.request({ path: `/user`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -656,12 +624,10 @@ export class Api extends HttpClient + createUsersWithArrayInput: (params: RequestParams = {}) => this.request({ path: `/user/createWithArray`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), @@ -673,12 +639,10 @@ export class Api extends HttpClient + createUsersWithListInput: (params: RequestParams = {}) => this.request({ path: `/user/createWithList`, method: "POST", - body: body, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/petstore-with-external-docs.ts b/tests/generated/v2.0/petstore-with-external-docs.ts index 3e901f9c..db7d25e4 100644 --- a/tests/generated/v2.0/petstore-with-external-docs.ts +++ b/tests/generated/v2.0/petstore-with-external-docs.ts @@ -255,7 +255,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -280,12 +280,10 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", - body: pet, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore.ts b/tests/generated/v2.0/petstore.ts index 88d19bd3..33597045 100644 --- a/tests/generated/v2.0/petstore.ts +++ b/tests/generated/v2.0/petstore.ts @@ -251,14 +251,14 @@ export class Api extends HttpClient this.request({ path: `/pets`, diff --git a/tests/generated/v2.0/query-path-param.ts b/tests/generated/v2.0/query-path-param.ts index 6495af64..8a3e8062 100644 --- a/tests/generated/v2.0/query-path-param.ts +++ b/tests/generated/v2.0/query-path-param.ts @@ -237,14 +237,14 @@ export class Api extends HttpClient this.request({ path: `/foobarbaz/${query}`, diff --git a/tests/generated/v2.0/uber.ts b/tests/generated/v2.0/uber.ts index b2762c2a..8aceed13 100644 --- a/tests/generated/v2.0/uber.ts +++ b/tests/generated/v2.0/uber.ts @@ -317,6 +317,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/products`, @@ -350,6 +350,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/estimates/price`, @@ -391,6 +391,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/estimates/time`, @@ -447,7 +447,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/history`, diff --git a/tests/generated/v3.0/allof-example.ts b/tests/generated/v3.0/allof-example.ts index ed5ab192..9da5d763 100644 --- a/tests/generated/v3.0/allof-example.ts +++ b/tests/generated/v3.0/allof-example.ts @@ -245,12 +245,10 @@ export class Api extends HttpClient + petsPartialUpdate: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", - body: data, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/anyof-example.ts b/tests/generated/v3.0/anyof-example.ts index d999e9c7..d1864909 100644 --- a/tests/generated/v3.0/anyof-example.ts +++ b/tests/generated/v3.0/anyof-example.ts @@ -241,12 +241,10 @@ export class Api extends HttpClient + petsPartialUpdate: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", - body: data, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/callback-example.ts b/tests/generated/v3.0/callback-example.ts index 89875f35..f4c2e547 100644 --- a/tests/generated/v3.0/callback-example.ts +++ b/tests/generated/v3.0/callback-example.ts @@ -232,6 +232,7 @@ export class Api extends HttpClient extends HttpClient this.request< { diff --git a/tests/generated/v3.0/explode-param-3.0.1.ts b/tests/generated/v3.0/explode-param-3.0.1.ts index 5b48d4b3..038ba83f 100644 --- a/tests/generated/v3.0/explode-param-3.0.1.ts +++ b/tests/generated/v3.0/explode-param-3.0.1.ts @@ -253,20 +253,10 @@ export class Api extends HttpClient + createFile: (user: string, params: RequestParams = {}) => this.request({ path: `/${user}/foos`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -279,10 +269,10 @@ export class Api extends HttpClient this.request({ path: `/something/`, diff --git a/tests/generated/v3.0/full-swagger-scheme.ts b/tests/generated/v3.0/full-swagger-scheme.ts index 5e48e5c9..11aa892a 100644 --- a/tests/generated/v3.0/full-swagger-scheme.ts +++ b/tests/generated/v3.0/full-swagger-scheme.ts @@ -8982,24 +8982,10 @@ export class Api extends HttpClient + appsUpdateWebhookConfigForApp: (params: RequestParams = {}) => this.request({ path: `/app/hook/config`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9013,7 +8999,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/app/installations`, @@ -9084,21 +9070,7 @@ export class Api extends HttpClient + appsCreateInstallationAccessToken: (installationId: number, params: RequestParams = {}) => this.request< InstallationToken, | BasicError @@ -9110,8 +9082,6 @@ export class Api extends HttpClient({ path: `/app/installations/${installationId}/access_tokens`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9183,7 +9153,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/applications/grants`, @@ -9246,19 +9216,10 @@ export class Api extends HttpClient + appsDeleteAuthorization: (clientId: string, params: RequestParams = {}) => this.request({ path: `/applications/${clientId}/grant`, method: "DELETE", - body: data, - type: ContentType.Json, ...params, }), @@ -9286,19 +9247,10 @@ export class Api extends HttpClient + appsCheckToken: (clientId: string, params: RequestParams = {}) => this.request({ path: `/applications/${clientId}/token`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9311,19 +9263,10 @@ export class Api extends HttpClient + appsResetToken: (clientId: string, params: RequestParams = {}) => this.request({ path: `/applications/${clientId}/token`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9336,19 +9279,10 @@ export class Api extends HttpClient + appsDeleteToken: (clientId: string, params: RequestParams = {}) => this.request({ path: `/applications/${clientId}/token`, method: "DELETE", - body: data, - type: ContentType.Json, ...params, }), @@ -9360,41 +9294,10 @@ export class Api extends HttpClient + appsScopeToken: (clientId: string, params: RequestParams = {}) => this.request({ path: `/applications/${clientId}/token/scoped`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9484,7 +9387,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/authorizations`, @@ -9515,40 +9418,10 @@ export class Api extends HttpClient + oauthAuthorizationsCreateAuthorization: (params: RequestParams = {}) => this.request({ path: `/authorizations`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9562,36 +9435,10 @@ export class Api extends HttpClient + oauthAuthorizationsGetOrCreateAuthorizationForApp: (clientId: string, params: RequestParams = {}) => this.request({ path: `/authorizations/clients/${clientId}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9608,32 +9455,11 @@ export class Api extends HttpClient this.request({ path: `/authorizations/clients/${clientId}/${fingerprint}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9664,35 +9490,10 @@ export class Api extends HttpClient + oauthAuthorizationsUpdateAuthorization: (authorizationId: number, params: RequestParams = {}) => this.request({ path: `/authorizations/${authorizationId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9768,24 +9569,7 @@ export class Api extends HttpClient + appsCreateContentAttachment: (contentReferenceId: number, params: RequestParams = {}) => this.request< ContentReferenceAttachment, | BasicError @@ -9797,8 +9581,6 @@ export class Api extends HttpClient({ path: `/content_references/${contentReferenceId}/attachments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -9845,21 +9627,10 @@ export class Api extends HttpClient + enterpriseAdminSetGithubActionsPermissionsEnterprise: (enterprise: string, params: RequestParams = {}) => this.request({ path: `/enterprises/${enterprise}/actions/permissions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -9873,7 +9644,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -9911,17 +9682,11 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/permissions/organizations`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -9987,16 +9752,10 @@ export class Api extends HttpClient + enterpriseAdminSetAllowedActionsEnterprise: (enterprise: string, params: RequestParams = {}) => this.request({ path: `/enterprises/${enterprise}/actions/permissions/selected-actions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -10010,7 +9769,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10046,25 +9805,10 @@ export class Api extends HttpClient + enterpriseAdminCreateSelfHostedRunnerGroupForEnterprise: (enterprise: string, params: RequestParams = {}) => this.request({ path: `/enterprises/${enterprise}/actions/runner-groups`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10100,22 +9844,11 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10150,7 +9883,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10189,17 +9922,11 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}/organizations`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -10254,7 +9981,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10293,17 +10020,11 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}/runners`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -10357,7 +10078,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10482,7 +10203,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/enterprises/${enterprise}/audit-log`, @@ -10579,7 +10300,8 @@ export class Api extends HttpClient extends HttpClient this.request< Event[], @@ -10636,7 +10357,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists`, @@ -10668,34 +10389,10 @@ export class Api extends HttpClient; - /** Flag indicating whether the gist is public */ - public?: boolean | "true" | "false"; - }, - params: RequestParams = {}, - ) => + gistsCreate: (params: RequestParams = {}) => this.request({ path: `/gists`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10709,7 +10406,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/public`, @@ -10742,7 +10439,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/starred`, @@ -10802,35 +10499,10 @@ export class Api extends HttpClient; - }, - params: RequestParams = {}, - ) => + gistsUpdate: (gistId: string, params: RequestParams = {}) => this.request({ path: `/gists/${gistId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10860,7 +10532,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/comments`, @@ -10890,23 +10562,10 @@ export class Api extends HttpClient + gistsCreateComment: (gistId: string, params: RequestParams = {}) => this.request({ path: `/gists/${gistId}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10947,24 +10606,10 @@ export class Api extends HttpClient + gistsUpdateComment: (gistId: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/gists/${gistId}/comments/${commentId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -10994,7 +10639,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/commits`, @@ -11026,7 +10671,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/forks`, @@ -11168,7 +10813,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -11223,7 +10868,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/issues`, @@ -11288,7 +10933,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/licenses`, @@ -11331,26 +10976,10 @@ export class Api extends HttpClient + markdownRender: (params: RequestParams = {}) => this.request({ path: `/markdown`, method: "POST", - body: data, - type: ContentType.Json, ...params, }), @@ -11362,12 +10991,10 @@ export class Api extends HttpClient + markdownRenderRaw: (params: RequestParams = {}) => this.request({ path: `/markdown/raw`, method: "POST", - body: data, - type: ContentType.Text, ...params, }), }; @@ -11397,7 +11024,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/plans`, @@ -11429,7 +11056,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/plans/${planId}/accounts`, @@ -11483,7 +11110,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/stubbed/plans`, @@ -11515,7 +11142,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/stubbed/plans/${planId}/accounts`, @@ -11573,7 +11200,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/networks/${owner}/${repo}/events`, @@ -11605,7 +11232,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/notifications`, @@ -11649,18 +11276,7 @@ export class Api extends HttpClient + activityMarkNotificationsAsRead: (params: RequestParams = {}) => this.request< { message?: string; @@ -11669,8 +11285,6 @@ export class Api extends HttpClient({ path: `/notifications`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -11730,22 +11344,10 @@ export class Api extends HttpClient + activitySetThreadSubscription: (threadId: number, params: RequestParams = {}) => this.request({ path: `/notifications/threads/${threadId}/subscription`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -11775,11 +11377,11 @@ export class Api extends HttpClient this.request({ path: `/octocat`, @@ -11798,7 +11400,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/organizations`, @@ -11842,100 +11444,7 @@ export class Api extends HttpClient + orgsUpdate: (org: string, params: RequestParams = {}) => this.request< OrganizationFull, | BasicError @@ -11947,8 +11456,6 @@ export class Api extends HttpClient({ path: `/orgs/${org}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -11977,21 +11484,10 @@ export class Api extends HttpClient + actionsSetGithubActionsPermissionsOrganization: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/permissions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12005,7 +11501,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12041,19 +11537,10 @@ export class Api extends HttpClient + actionsSetSelectedRepositoriesEnabledGithubActionsOrganization: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/permissions/repositories`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12119,12 +11606,10 @@ export class Api extends HttpClient + actionsSetAllowedActionsOrganization: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/permissions/selected-actions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12138,7 +11623,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12174,28 +11659,10 @@ export class Api extends HttpClient + actionsCreateSelfHostedRunnerGroupForOrg: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/runner-groups`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -12224,22 +11691,10 @@ export class Api extends HttpClient + actionsUpdateSelfHostedRunnerGroupForOrg: (org: string, runnerGroupId: number, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -12296,17 +11751,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}/repositories`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12361,7 +11810,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12397,20 +11846,10 @@ export class Api extends HttpClient + actionsSetSelfHostedRunnersInGroupForOrg: (org: string, runnerGroupId: number, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}/runners`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12464,7 +11903,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12581,7 +12020,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12649,31 +12088,10 @@ export class Api extends HttpClient + actionsCreateOrUpdateOrgSecret: (org: string, secretName: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/secrets/${secretName}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12722,20 +12140,10 @@ export class Api extends HttpClient + actionsSetSelectedReposForOrgSecret: (org: string, secretName: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/secrets/${secretName}/repositories`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -12789,7 +12197,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/audit-log`, @@ -12936,7 +12344,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/events`, @@ -12968,7 +12376,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/failed_invitations`, @@ -13000,7 +12408,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/hooks`, @@ -13030,44 +12438,10 @@ export class Api extends HttpClient + orgsCreateWebhook: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/hooks`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13096,41 +12470,10 @@ export class Api extends HttpClient + orgsUpdateWebhook: (org: string, hookId: number, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/hooks/${hookId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13174,26 +12517,10 @@ export class Api extends HttpClient + orgsUpdateWebhookConfigForOrg: (org: string, hookId: number, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/hooks/${hookId}/config`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13239,7 +12566,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -13291,12 +12618,10 @@ export class Api extends HttpClient + interactionsSetRestrictionsForOrg: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/interaction-limits`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13326,7 +12651,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/invitations`, @@ -13356,31 +12681,10 @@ export class Api extends HttpClient + orgsCreateInvitation: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/invitations`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13411,7 +12715,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/invitations/${invitationId}/teams`, @@ -13443,7 +12747,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/issues`, @@ -13504,7 +12808,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/members`, @@ -13595,25 +12899,10 @@ export class Api extends HttpClient + orgsSetMembershipForUser: (org: string, username: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/memberships/${username}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13643,7 +12932,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/migrations`, @@ -13673,30 +12962,10 @@ export class Api extends HttpClient + migrationsStartForOrg: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/migrations`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13773,7 +13042,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/migrations/${migrationId}/repositories`, @@ -13805,7 +13074,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/outside_collaborators`, @@ -13887,7 +13156,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/projects`, @@ -13922,21 +13191,10 @@ export class Api extends HttpClient + projectsCreateForOrg: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/projects`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -13951,7 +13209,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/public_members`, @@ -14028,7 +13286,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/repos`, @@ -14067,84 +13325,10 @@ export class Api extends HttpClient + reposCreateInOrg: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/repos`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14207,7 +13391,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/team-sync/groups`, @@ -14239,7 +13423,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams`, @@ -14269,46 +13453,10 @@ export class Api extends HttpClient + teamsCreate: (org: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14337,41 +13485,10 @@ export class Api extends HttpClient + teamsUpdateInOrg: (org: string, teamSlug: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams/${teamSlug}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14402,7 +13519,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions`, @@ -14437,27 +13554,10 @@ export class Api extends HttpClient + teamsCreateDiscussionInOrg: (org: string, teamSlug: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14486,23 +13586,10 @@ export class Api extends HttpClient + teamsUpdateDiscussionInOrg: (org: string, teamSlug: string, discussionNumber: number, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14534,7 +13621,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments`, @@ -14573,17 +13660,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14623,17 +13704,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14672,7 +13747,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, @@ -14709,17 +13784,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14758,7 +13827,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/reactions`, @@ -14794,17 +13863,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14841,7 +13904,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/invitations`, @@ -14874,7 +13937,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/members`, @@ -14932,15 +13995,6 @@ export class Api extends HttpClient this.request< @@ -14956,8 +14010,6 @@ export class Api extends HttpClient({ path: `/orgs/${org}/teams/${teamSlug}/memberships/${username}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -14988,7 +14040,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/projects`, @@ -15043,16 +14095,6 @@ export class Api extends HttpClient this.request< @@ -15064,8 +14106,6 @@ export class Api extends HttpClient({ path: `/orgs/${org}/teams/${teamSlug}/projects/${projectId}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -15095,7 +14135,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/repos`, @@ -15152,26 +14192,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/repos/${owner}/${repo}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -15214,27 +14239,10 @@ export class Api extends HttpClient + teamsCreateOrUpdateIdpGroupConnectionsInOrg: (org: string, teamSlug: string, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/team-sync/group-mappings`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15250,7 +14258,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/teams`, @@ -15297,27 +14305,10 @@ export class Api extends HttpClient + projectsUpdateCard: (cardId: number, params: RequestParams = {}) => this.request({ path: `/projects/columns/cards/${cardId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15353,23 +14344,7 @@ export class Api extends HttpClient + projectsMoveCard: (cardId: number, params: RequestParams = {}) => this.request< object, | BasicError @@ -15396,8 +14371,6 @@ export class Api extends HttpClient({ path: `/projects/columns/cards/${cardId}/moves`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15426,22 +14399,10 @@ export class Api extends HttpClient + projectsUpdateColumn: (columnId: number, params: RequestParams = {}) => this.request({ path: `/projects/columns/${columnId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15471,7 +14432,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/projects/columns/${columnId}/cards`, @@ -15506,30 +14467,7 @@ export class Api extends HttpClient + projectsCreateCard: (columnId: number, params: RequestParams = {}) => this.request< ProjectCard, | BasicError @@ -15546,8 +14484,6 @@ export class Api extends HttpClient({ path: `/projects/columns/${columnId}/cards`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15560,23 +14496,10 @@ export class Api extends HttpClient + projectsMoveColumn: (columnId: number, params: RequestParams = {}) => this.request({ path: `/projects/columns/${columnId}/moves`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15605,31 +14528,7 @@ export class Api extends HttpClient + projectsUpdate: (projectId: number, params: RequestParams = {}) => this.request< Project, | BasicError @@ -15643,8 +14542,6 @@ export class Api extends HttpClient({ path: `/projects/${projectId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15682,7 +14579,8 @@ export class Api extends HttpClient extends HttpClient this.request< SimpleUser[], @@ -15728,19 +14625,7 @@ export class Api extends HttpClient + projectsAddCollaborator: (projectId: number, username: string, params: RequestParams = {}) => this.request< void, | BasicError @@ -15752,8 +14637,6 @@ export class Api extends HttpClient({ path: `/projects/${projectId}/collaborators/${username}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -15814,7 +14697,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/projects/${projectId}/columns`, @@ -15844,22 +14727,10 @@ export class Api extends HttpClient + projectsCreateColumn: (projectId: number, params: RequestParams = {}) => this.request({ path: `/projects/${projectId}/columns`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -15930,79 +14801,10 @@ export class Api extends HttpClient + reposUpdate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -16040,7 +14842,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16175,22 +14977,10 @@ export class Api extends HttpClient + actionsSetGithubActionsPermissionsRepository: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/actions/permissions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -16218,17 +15008,10 @@ export class Api extends HttpClient + actionsSetAllowedActionsRepository: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/actions/permissions/selected-actions`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -16243,7 +15026,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16366,7 +15149,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16445,7 +15228,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16500,7 +15283,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16607,7 +15390,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16675,23 +15458,10 @@ export class Api extends HttpClient + actionsCreateOrUpdateRepoSecret: (owner: string, repo: string, secretName: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/actions/secrets/${secretName}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -16721,7 +15491,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16792,19 +15562,11 @@ export class Api extends HttpClient; - }, params: RequestParams = {}, ) => this.request({ path: `/repos/${owner}/${repo}/actions/workflows/${workflowId}/dispatches`, method: "POST", - body: data, - type: ContentType.Json, ...params, }), @@ -16835,7 +15597,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16898,7 +15660,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/assignees`, @@ -16976,7 +15738,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/branches`, @@ -17047,54 +15809,7 @@ export class Api extends HttpClient + reposUpdateBranchProtection: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request< ProtectedBranch, | BasicError @@ -17106,8 +15821,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/branches/${branch}/protection`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17198,32 +15911,10 @@ export class Api extends HttpClient + reposUpdatePullRequestReviewProtection: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_pull_request_reviews`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17314,23 +16005,10 @@ export class Api extends HttpClient + reposUpdateStatusCheckProtection: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17374,21 +16052,10 @@ export class Api extends HttpClient + reposAddStatusCheckContexts: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17401,21 +16068,10 @@ export class Api extends HttpClient + reposSetStatusCheckContexts: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17428,21 +16084,10 @@ export class Api extends HttpClient + reposRemoveStatusCheckContexts: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17507,21 +16152,10 @@ export class Api extends HttpClient + reposAddAppAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17534,21 +16168,10 @@ export class Api extends HttpClient + reposSetAppAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17561,21 +16184,10 @@ export class Api extends HttpClient + reposRemoveAppAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17609,21 +16221,10 @@ export class Api extends HttpClient + reposAddTeamAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17636,21 +16237,10 @@ export class Api extends HttpClient + reposSetTeamAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17663,21 +16253,10 @@ export class Api extends HttpClient + reposRemoveTeamAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17711,21 +16290,10 @@ export class Api extends HttpClient + reposAddUserAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17738,21 +16306,10 @@ export class Api extends HttpClient + reposSetUserAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17765,21 +16322,10 @@ export class Api extends HttpClient + reposRemoveUserAccessRestrictions: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17792,21 +16338,10 @@ export class Api extends HttpClient + reposRenameBranch: (owner: string, repo: string, branch: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/rename`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17819,125 +16354,10 @@ export class Api extends HttpClient + checksCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/check-runs`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -17966,121 +16386,10 @@ export class Api extends HttpClient + checksUpdate: (owner: string, repo: string, checkRunId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/check-runs/${checkRunId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18097,7 +16406,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/check-runs/${checkRunId}/annotations`, @@ -18127,20 +16436,10 @@ export class Api extends HttpClient + checksCreateSuite: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/check-suites`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18153,28 +16452,10 @@ export class Api extends HttpClient + checksSetSuitesPreferences: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/check-suites/preferences`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18207,7 +16488,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -18270,13 +16551,13 @@ export class Api extends HttpClient`. */ ref?: CodeScanningAlertRef; }, - params: RequestParams = {}, ) => this.request< CodeScanningAlertCodeScanningAlertItems[], @@ -18326,23 +16607,10 @@ export class Api extends HttpClient + codeScanningUpdateAlert: (owner: string, repo: string, alertNumber: AlertNumber, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/alerts/${alertNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18358,13 +16626,13 @@ export class Api extends HttpClient`. */ ref?: CodeScanningAnalysisRef; /** Set a single code scanning tool name to filter alerts by tool. */ tool_name?: CodeScanningAnalysisToolName; }, - params: RequestParams = {}, ) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/analyses`, @@ -18382,38 +16650,10 @@ export class Api extends HttpClient`. */ - ref: CodeScanningAnalysisRef; - /** A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using [`gzip`](http://www.gnu.org/software/gzip/manual/gzip.html) and then translate the contents of the file into a Base64 encoding string. */ - sarif: CodeScanningAnalysisSarifFile; - /** - * The base directory used in the analysis, as it appears in the SARIF file. - * This property is used to convert file paths from absolute to relative, so that alerts can be mapped to their correct location in the repository. - * @format uri - * @example "file:///github/workspace/" - */ - checkout_uri?: string; - /** - * The time that the analysis run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. - * @format date - */ - started_at?: string; - /** The name of the tool used to generate the code scanning analysis alert. */ - tool_name: CodeScanningAnalysisToolName; - }, - params: RequestParams = {}, - ) => + codeScanningUploadSarif: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/sarifs`, method: "POST", - body: data, - type: ContentType.Json, ...params, }), @@ -18428,7 +16668,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/collaborators`, @@ -18481,31 +16721,10 @@ export class Api extends HttpClient + reposAddCollaborator: (owner: string, repo: string, username: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/collaborators/${username}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18552,7 +16771,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/comments`, @@ -18598,21 +16817,10 @@ export class Api extends HttpClient + reposUpdateCommitComment: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/comments/${commentId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18644,7 +16852,8 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -18683,16 +16891,7 @@ export class Api extends HttpClient + reactionsCreateForCommitComment: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request< Reaction, | { @@ -18703,8 +16902,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/comments/${commentId}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18741,7 +16938,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits`, @@ -18808,7 +17005,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits/${commitSha}/comments`, @@ -18838,27 +17035,10 @@ export class Api extends HttpClient + reposCreateCommitComment: (owner: string, repo: string, commitSha: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/commits/${commitSha}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -18875,7 +17055,8 @@ export class Api extends HttpClient extends HttpClient this.request< PullRequestSimple[], @@ -18931,7 +17111,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -18980,7 +17160,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -19043,7 +17223,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits/${ref}/statuses`, @@ -19125,11 +17305,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, @@ -19147,45 +17327,10 @@ export class Api extends HttpClient + reposCreateOrUpdateFileContents: (owner: string, repo: string, path: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19198,34 +17343,7 @@ export class Api extends HttpClient + reposDeleteFile: (owner: string, repo: string, path: string, params: RequestParams = {}) => this.request< FileCommit, | BasicError @@ -19238,8 +17356,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19255,7 +17371,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contributors`, @@ -19290,7 +17406,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/deployments`, @@ -19340,52 +17456,7 @@ export class Api extends HttpClient | string; - /** - * Name for the target deployment environment (e.g., `production`, `staging`, `qa`). - * @default "production" - */ - environment?: string; - /** - * Short description of the deployment. - * @default "" - */ - description?: string | null; - /** - * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: `false` - * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. - * @default false - */ - transient_environment?: boolean; - /** - * Specifies if the given environment is one that end-users directly interact with. Default: `true` when `environment` is `production` and `false` otherwise. - * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. - */ - production_environment?: boolean; - /** @example ""1776-07-04T00:00:00.000-07:52"" */ - created_at?: string; - }, - params: RequestParams = {}, - ) => + reposCreateDeployment: (owner: string, repo: string, params: RequestParams = {}) => this.request< Deployment, | { @@ -19397,8 +17468,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/deployments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19446,7 +17515,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/deployments/${deploymentId}/statuses`, @@ -19476,51 +17545,10 @@ export class Api extends HttpClient + reposCreateDeploymentStatus: (owner: string, repo: string, deploymentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/deployments/${deploymentId}/statuses`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19562,22 +17590,10 @@ export class Api extends HttpClient; - }, - params: RequestParams = {}, - ) => + reposCreateDispatchEvent: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/dispatches`, method: "POST", - body: data, - type: ContentType.Json, ...params, }), @@ -19592,7 +17608,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/events`, @@ -19625,7 +17641,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/forks`, @@ -19660,20 +17676,10 @@ export class Api extends HttpClient + reposCreateFork: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/forks`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19686,25 +17692,10 @@ export class Api extends HttpClient + gitCreateBlob: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/blobs`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19733,44 +17724,10 @@ export class Api extends HttpClient + gitCreateCommit: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/commits`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19803,7 +17760,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/matching-refs/${ref}`, @@ -19849,24 +17806,10 @@ export class Api extends HttpClient + gitCreateRef: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19879,26 +17822,10 @@ export class Api extends HttpClient + gitUpdateRef: (owner: string, repo: string, ref: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs/${ref}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19926,35 +17853,10 @@ export class Api extends HttpClient + gitCreateTag: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/tags`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -19983,44 +17885,10 @@ export class Api extends HttpClient + gitCreateTree: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/trees`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20037,11 +17905,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/trees/${treeSha}`, @@ -20062,7 +17930,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/hooks`, @@ -20092,45 +17960,10 @@ export class Api extends HttpClient + reposCreateWebhook: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20159,48 +17992,10 @@ export class Api extends HttpClient + reposUpdateWebhook: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20242,29 +18037,12 @@ export class Api extends HttpClient + * @request PATCH:/repos/{owner}/{repo}/hooks/{hook_id}/config + */ + reposUpdateWebhookConfigForRepo: (owner: string, repo: string, hookId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}/config`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20323,28 +18101,10 @@ export class Api extends HttpClient + migrationsStartImport: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/import`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20357,26 +18117,10 @@ export class Api extends HttpClient + migrationsUpdateImport: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/import`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20407,11 +18151,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/import/authors`, @@ -20429,25 +18173,10 @@ export class Api extends HttpClient + migrationsMapCommitAuthor: (owner: string, repo: string, authorId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/import/authors/${authorId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20476,20 +18205,10 @@ export class Api extends HttpClient + migrationsSetLfsPreference: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/import/lfs`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20534,17 +18253,10 @@ export class Api extends HttpClient + interactionsSetRestrictionsForRepo: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/interaction-limits`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20575,7 +18287,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/invitations`, @@ -20605,21 +18317,10 @@ export class Api extends HttpClient + reposUpdateInvitation: (owner: string, repo: string, invitationId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/invitations/${invitationId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20650,7 +18351,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues`, @@ -20707,33 +18408,7 @@ export class Api extends HttpClient + issuesCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request< Issue, | BasicError @@ -20746,8 +18421,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20763,7 +18436,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/comments`, @@ -20818,21 +18491,10 @@ export class Api extends HttpClient + issuesUpdateComment: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20864,7 +18526,8 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -20903,16 +18565,7 @@ export class Api extends HttpClient + reactionsCreateForIssueComment: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request< Reaction, | { @@ -20923,8 +18576,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -20961,7 +18612,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/events`, @@ -21023,36 +18674,7 @@ export class Api extends HttpClient + issuesUpdate: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request< Issue, | BasicError @@ -21065,8 +18687,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/${issueNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21079,21 +18699,10 @@ export class Api extends HttpClient + issuesAddAssignees: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21106,21 +18715,10 @@ export class Api extends HttpClient + issuesRemoveAssignees: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, method: "DELETE", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21137,7 +18735,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/comments`, @@ -21169,21 +18767,10 @@ export class Api extends HttpClient + issuesCreateComment: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21200,7 +18787,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/events`, @@ -21234,7 +18821,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, @@ -21264,21 +18851,10 @@ export class Api extends HttpClient + issuesAddLabels: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21291,21 +18867,10 @@ export class Api extends HttpClient + issuesSetLabels: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21349,27 +18914,10 @@ export class Api extends HttpClient + issuesLock: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/lock`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -21400,7 +18948,8 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -21439,16 +18987,7 @@ export class Api extends HttpClient + reactionsCreateForIssue: (owner: string, repo: string, issueNumber: number, params: RequestParams = {}) => this.request< Reaction, | { @@ -21459,8 +18998,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21498,7 +19035,8 @@ export class Api extends HttpClient extends HttpClient this.request< IssueEventForIssue[], @@ -21538,7 +19075,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/keys`, @@ -21568,28 +19105,10 @@ export class Api extends HttpClient + reposCreateDeployKey: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/keys`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21636,7 +19155,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/labels`, @@ -21666,24 +19185,10 @@ export class Api extends HttpClient + issuesCreateLabel: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21712,25 +19217,10 @@ export class Api extends HttpClient + issuesUpdateLabel: (owner: string, repo: string, name: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels/${name}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21790,19 +19280,7 @@ export class Api extends HttpClient + reposMerge: (owner: string, repo: string, params: RequestParams = {}) => this.request< Commit, | BasicError @@ -21815,8 +19293,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/merges`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21832,7 +19308,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones`, @@ -21877,29 +19353,10 @@ export class Api extends HttpClient + issuesCreateMilestone: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/milestones`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21928,30 +19385,10 @@ export class Api extends HttpClient + issuesUpdateMilestone: (owner: string, repo: string, milestoneNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/milestones/${milestoneNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -21983,7 +19420,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones/${milestoneNumber}/labels`, @@ -22016,7 +19453,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/notifications`, @@ -22060,20 +19497,10 @@ export class Api extends HttpClient + activityMarkRepoNotificationsAsRead: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/notifications`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -22101,23 +19528,7 @@ export class Api extends HttpClient + reposCreatePagesSite: (owner: string, repo: string, params: RequestParams = {}) => this.request< Page, | BasicError @@ -22129,8 +19540,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pages`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22143,43 +19552,10 @@ export class Api extends HttpClient + reposUpdateInformationAboutPagesSite: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pages`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -22217,7 +19593,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pages/builds`, @@ -22298,7 +19674,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/projects`, @@ -22333,22 +19709,10 @@ export class Api extends HttpClient + projectsCreateForRepo: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/projects`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22364,7 +19728,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls`, @@ -22410,32 +19774,10 @@ export class Api extends HttpClient + pullsCreate: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22451,7 +19793,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/comments`, @@ -22506,21 +19848,10 @@ export class Api extends HttpClient + pullsUpdateReviewComment: (owner: string, repo: string, commentId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22552,7 +19883,8 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -22595,10 +19926,6 @@ export class Api extends HttpClient this.request< @@ -22611,8 +19938,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22662,29 +19987,10 @@ export class Api extends HttpClient + pullsUpdate: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22701,7 +20007,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments`, @@ -22738,39 +20044,12 @@ export class Api extends HttpClient + * @request POST:/repos/{owner}/{repo}/pulls/{pull_number}/comments + */ + pullsCreateReviewComment: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22788,17 +20067,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments/${commentId}/replies`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22815,7 +20088,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/commits`, @@ -22849,7 +20122,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/files`, @@ -22894,22 +20167,7 @@ export class Api extends HttpClient + pullsMerge: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request< PullRequestMergeResult, | BasicError @@ -22921,8 +20179,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/merge`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22939,7 +20195,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, @@ -22969,23 +20225,10 @@ export class Api extends HttpClient + pullsRequestReviewers: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -22998,23 +20241,10 @@ export class Api extends HttpClient + pullsRemoveRequestedReviewers: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, method: "DELETE", - body: data, - type: ContentType.Json, ...params, }), @@ -23030,7 +20260,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews`, @@ -23060,42 +20290,10 @@ export class Api extends HttpClient + pullsCreateReview: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23129,17 +20327,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23179,7 +20371,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/comments`, @@ -23214,19 +20406,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/dismissals`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23244,19 +20428,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/events`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23269,16 +20445,7 @@ export class Api extends HttpClient + pullsUpdateBranch: (owner: string, repo: string, pullNumber: number, params: RequestParams = {}) => this.request< { message?: string; @@ -23293,8 +20460,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/update-branch`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23310,11 +20475,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/readme`, @@ -23335,7 +20500,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases`, @@ -23365,36 +20530,10 @@ export class Api extends HttpClient + reposCreateRelease: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23430,25 +20569,10 @@ export class Api extends HttpClient + reposUpdateReleaseAsset: (owner: string, repo: string, assetId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases/assets/${assetId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23524,31 +20648,10 @@ export class Api extends HttpClient + reposUpdateRelease: (owner: string, repo: string, releaseId: number, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23580,7 +20683,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}/assets`, @@ -23614,18 +20717,16 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}/assets`, method: "POST", query: query, - body: data, format: "json", ...params, }), @@ -23641,7 +20742,8 @@ export class Api extends HttpClient extends HttpClient this.request< SecretScanningAlert[], @@ -23703,18 +20804,7 @@ export class Api extends HttpClient + secretScanningUpdateAlert: (owner: string, repo: string, alertNumber: AlertNumber, params: RequestParams = {}) => this.request< SecretScanningAlert, void | { @@ -23725,8 +20815,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/secret-scanning/alerts/${alertNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23742,7 +20830,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/stargazers`, @@ -23852,34 +20940,10 @@ export class Api extends HttpClient + reposCreateCommitStatus: (owner: string, repo: string, sha: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/statuses/${sha}`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23895,7 +20959,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/subscribers`, @@ -23941,22 +21005,10 @@ export class Api extends HttpClient + activitySetRepoSubscription: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/subscription`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -23987,7 +21039,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/tags`, @@ -24035,7 +21087,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/teams`, @@ -24088,15 +21140,7 @@ export class Api extends HttpClient + reposReplaceAllTopics: (owner: string, repo: string, params: RequestParams = {}) => this.request< Topic, | BasicError @@ -24108,8 +21152,6 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/topics`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24125,14 +21167,14 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/traffic/clones`, @@ -24185,14 +21227,14 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/traffic/views`, @@ -24210,22 +21252,10 @@ export class Api extends HttpClient + reposTransfer: (owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/transfer`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24298,34 +21328,10 @@ export class Api extends HttpClient + reposCreateUsingTemplate: (templateOwner: string, templateRepo: string, params: RequestParams = {}) => this.request({ path: `/repos/${templateOwner}/${templateRepo}/generate`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24340,11 +21346,11 @@ export class Api extends HttpClient this.request({ path: `/repositories`, @@ -24365,13 +21371,13 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups`, @@ -24389,25 +21395,10 @@ export class Api extends HttpClient + enterpriseAdminProvisionAndInviteEnterpriseGroup: (enterprise: string, params: RequestParams = {}) => this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24443,23 +21434,11 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups/${scimGroupId}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24475,19 +21454,11 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups/${scimGroupId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24521,13 +21492,13 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users`, @@ -24545,40 +21516,10 @@ export class Api extends HttpClient + enterpriseAdminProvisionAndInviteEnterpriseUser: (enterprise: string, params: RequestParams = {}) => this.request({ path: `/scim/v2/enterprises/${enterprise}/Users`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24614,38 +21555,11 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users/${scimUserId}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24661,19 +21575,11 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users/${scimUserId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24703,7 +21609,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/scim/v2/organizations/${org}/Users`, @@ -24737,47 +21643,10 @@ export class Api extends HttpClient + scimProvisionAndInviteUser: (org: string, params: RequestParams = {}) => this.request({ path: `/scim/v2/organizations/${org}/Users`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24806,48 +21675,10 @@ export class Api extends HttpClient + scimSetInformationForProvisionedUser: (org: string, scimUserId: string, params: RequestParams = {}) => this.request({ path: `/scim/v2/organizations/${org}/Users/${scimUserId}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24860,41 +21691,10 @@ export class Api extends HttpClient + scimUpdateAttributeForUser: (org: string, scimUserId: string, params: RequestParams = {}) => this.request({ path: `/scim/v2/organizations/${org}/Users/${scimUserId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -24924,6 +21724,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -24977,6 +21777,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -25027,6 +21827,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -25091,6 +21891,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -25130,6 +21930,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -25182,11 +21982,11 @@ export class Api extends HttpClient this.request< { @@ -25215,6 +22015,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -25285,40 +22085,10 @@ export class Api extends HttpClient + teamsUpdateLegacy: (teamId: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25350,7 +22120,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions`, @@ -25386,26 +22156,10 @@ export class Api extends HttpClient + teamsCreateDiscussionLegacy: (teamId: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/discussions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25436,22 +22190,10 @@ export class Api extends HttpClient + teamsUpdateDiscussionLegacy: (teamId: number, discussionNumber: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25484,7 +22226,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments`, @@ -25520,20 +22262,10 @@ export class Api extends HttpClient + teamsCreateDiscussionCommentLegacy: (teamId: number, discussionNumber: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25573,17 +22305,11 @@ export class Api extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25622,7 +22348,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, @@ -25659,17 +22385,11 @@ export class Api extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25686,7 +22406,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/reactions`, @@ -25717,22 +22437,12 @@ export class Api extends HttpClient + * @deprecated + */ + reactionsCreateForTeamDiscussionLegacy: (teamId: number, discussionNumber: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/reactions`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25748,7 +22458,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/invitations`, @@ -25781,7 +22491,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/members`, @@ -25899,20 +22609,7 @@ export class Api extends HttpClient + teamsAddOrUpdateMembershipForUserLegacy: (teamId: number, username: string, params: RequestParams = {}) => this.request< TeamMembership, | void @@ -25930,8 +22627,6 @@ export class Api extends HttpClient({ path: `/teams/${teamId}/memberships/${username}`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -25963,7 +22658,8 @@ export class Api extends HttpClient extends HttpClient this.request< TeamProject[], @@ -26024,21 +22719,7 @@ export class Api extends HttpClient + teamsAddOrUpdateProjectPermissionsLegacy: (teamId: number, projectId: number, params: RequestParams = {}) => this.request< void, | { @@ -26054,8 +22735,6 @@ export class Api extends HttpClient({ path: `/teams/${teamId}/projects/${projectId}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -26094,7 +22773,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/repos`, @@ -26142,28 +22821,10 @@ export class Api extends HttpClient + teamsAddOrUpdateRepoPermissionsLegacy: (teamId: number, owner: string, repo: string, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/repos/${owner}/${repo}`, method: "PUT", - body: data, - type: ContentType.Json, ...params, }), @@ -26209,34 +22870,10 @@ export class Api extends HttpClient + teamsCreateOrUpdateIdpGroupConnectionsLegacy: (teamId: number, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}/team-sync/group-mappings`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26252,7 +22889,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/teams`, @@ -26299,50 +22936,10 @@ export class Api extends HttpClient + usersUpdateAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26423,23 +23020,10 @@ export class Api extends HttpClient + usersSetPrimaryEmailVisibilityForAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user/email/visibility`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26453,7 +23037,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/emails`, @@ -26483,24 +23067,10 @@ export class Api extends HttpClient + usersAddEmailForAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26513,21 +23083,10 @@ export class Api extends HttpClient + usersDeleteEmailForAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "DELETE", - body: data, - type: ContentType.Json, ...params, }), @@ -26540,7 +23099,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/followers`, @@ -26571,7 +23130,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/following`, @@ -26647,7 +23206,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/gpg_keys`, @@ -26677,18 +23236,10 @@ export class Api extends HttpClient + usersCreateGpgKeyForAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user/gpg_keys`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26733,7 +23284,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -26775,7 +23326,8 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -26858,12 +23409,10 @@ export class Api extends HttpClient + interactionsSetRestrictionsForAuthenticatedUser: (params: RequestParams = {}) => this.request({ path: `/user/interaction-limits`, method: "PUT", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -26892,7 +23441,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/issues`, @@ -26952,7 +23501,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/keys`, @@ -26982,26 +23531,10 @@ export class Api extends HttpClient + usersCreatePublicSshKeyForAuthenticated: (params: RequestParams = {}) => this.request({ path: `/user/keys`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -27046,7 +23579,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/marketplace_purchases`, @@ -27077,7 +23610,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/marketplace_purchases/stubbed`, @@ -27108,7 +23641,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/memberships/orgs`, @@ -27156,19 +23689,10 @@ export class Api extends HttpClient + orgsUpdateMembershipForAuthenticatedUser: (org: string, params: RequestParams = {}) => this.request({ path: `/user/memberships/orgs/${org}`, method: "PATCH", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -27182,7 +23706,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/migrations`, @@ -27212,32 +23736,10 @@ export class Api extends HttpClient + migrationsStartForAuthenticatedUser: (params: RequestParams = {}) => this.request({ path: `/user/migrations`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -27252,10 +23754,10 @@ export class Api extends HttpClient this.request({ path: `/user/migrations/${migrationId}`, @@ -27320,7 +23822,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/migrations/${migrationId}/repositories`, @@ -27351,7 +23853,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/orgs`, @@ -27381,21 +23883,7 @@ export class Api extends HttpClient + projectsCreateForAuthenticatedUser: (params: RequestParams = {}) => this.request< Project, | BasicError @@ -27407,8 +23895,6 @@ export class Api extends HttpClient({ path: `/user/projects`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -27422,7 +23908,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/public_emails`, @@ -27453,7 +23939,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/repos`, @@ -27514,101 +24000,10 @@ export class Api extends HttpClient + reposCreateForAuthenticatedUser: (params: RequestParams = {}) => this.request({ path: `/user/repos`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -27622,7 +24017,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/repository_invitations`, @@ -27683,7 +24078,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/starred`, @@ -27769,7 +24164,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/subscriptions`, @@ -27800,7 +24195,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/teams`, @@ -27832,7 +24227,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users`, @@ -27877,7 +24272,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events`, @@ -27910,7 +24305,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events/orgs/${org}`, @@ -27942,7 +24337,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events/public`, @@ -27974,7 +24369,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/followers`, @@ -28006,7 +24401,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/following`, @@ -28053,7 +24448,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/gists`, @@ -28087,7 +24482,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/gpg_keys`, @@ -28119,13 +24514,13 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/hovercard`, @@ -28161,7 +24556,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/keys`, @@ -28193,7 +24588,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/orgs`, @@ -28225,7 +24620,8 @@ export class Api extends HttpClient extends HttpClient this.request< Project[], @@ -28269,7 +24664,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/received_events`, @@ -28301,7 +24696,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/received_events/public`, @@ -28333,7 +24728,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/repos`, @@ -28425,7 +24820,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/starred`, @@ -28467,7 +24862,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/subscriptions`, diff --git a/tests/generated/v3.0/link-example.ts b/tests/generated/v3.0/link-example.ts index 0444a117..84c976dd 100644 --- a/tests/generated/v3.0/link-example.ts +++ b/tests/generated/v3.0/link-example.ts @@ -293,10 +293,10 @@ export class Api extends HttpClient this.request({ path: `/2.0/repositories/${username}/${slug}/pullrequests`, diff --git a/tests/generated/v3.0/oneof-example.ts b/tests/generated/v3.0/oneof-example.ts index c87ba1ab..b517e3df 100644 --- a/tests/generated/v3.0/oneof-example.ts +++ b/tests/generated/v3.0/oneof-example.ts @@ -241,12 +241,10 @@ export class Api extends HttpClient + petsPartialUpdate: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", - body: data, - type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/personal-api-example.ts b/tests/generated/v3.0/personal-api-example.ts index 0b231244..69398c15 100644 --- a/tests/generated/v3.0/personal-api-example.ts +++ b/tests/generated/v3.0/personal-api-example.ts @@ -417,12 +417,10 @@ export class Api extends HttpClient + login: (params: RequestParams = {}) => this.request({ path: `/auth`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -470,13 +468,11 @@ export class Api extends HttpClient + addJob: (params: RequestParams = {}) => this.request({ path: `/jobs`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -506,15 +502,13 @@ export class Api extends HttpClient + updateJob: (id: string, params: RequestParams = {}) => this.request({ path: `/jobs/${id}`, method: "PATCH", - body: params, secure: true, - type: ContentType.Json, format: "json", - ...requestParams, + ...params, }), /** @@ -558,13 +552,11 @@ export class Api extends HttpClient + addProjects: (params: RequestParams = {}) => this.request({ path: `/projects`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -577,13 +569,11 @@ export class Api extends HttpClient + updateProject: (id: string, params: RequestParams = {}) => this.request({ path: `/projects/${id}`, method: "PATCH", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/petstore-expanded.ts b/tests/generated/v3.0/petstore-expanded.ts index 32e92c76..fab4d1c5 100644 --- a/tests/generated/v3.0/petstore-expanded.ts +++ b/tests/generated/v3.0/petstore-expanded.ts @@ -254,7 +254,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -279,12 +279,10 @@ export class Api extends HttpClient + addPet: (params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/petstore.ts b/tests/generated/v3.0/petstore.ts index 15d2e6e4..a6e99672 100644 --- a/tests/generated/v3.0/petstore.ts +++ b/tests/generated/v3.0/petstore.ts @@ -253,14 +253,14 @@ export class Api extends HttpClient this.request({ path: `/pets`, diff --git a/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts b/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts index 08deff15..1f6f08a9 100644 --- a/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts +++ b/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts @@ -343,12 +343,10 @@ export class Api extends HttpClient + login: (params: RequestParams = {}) => this.request({ path: `/auth`, method: "POST", - body: data, - type: ContentType.Json, format: "json", ...params, }), @@ -396,13 +394,11 @@ export class Api extends HttpClient + addJob: (params: RequestParams = {}) => this.request({ path: `/jobs`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -432,13 +428,11 @@ export class Api extends HttpClient + updateJob: (id: string, params: RequestParams = {}) => this.request({ path: `/jobs/${id}`, method: "PATCH", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -486,13 +480,11 @@ export class Api extends HttpClient + addJob: (params: RequestParams = {}) => this.request({ path: `x-route`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -521,13 +513,11 @@ export class Api extends HttpClient + addProjects: (params: RequestParams = {}) => this.request({ path: `/projects`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -540,13 +530,11 @@ export class Api extends HttpClient + updateProject: (id: string, params: RequestParams = {}) => this.request({ path: `/projects/${id}`, method: "PATCH", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -577,13 +565,11 @@ export class Api extends HttpClient + addUser: (params: RequestParams = {}) => this.request({ path: `/users`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -613,13 +599,11 @@ export class Api extends HttpClient + updateUser: (id: string, params: RequestParams = {}) => this.request({ path: `/users/${id}`, method: "PATCH", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/up-banking.ts b/tests/generated/v3.0/up-banking.ts index 4c6f59af..5553637f 100644 --- a/tests/generated/v3.0/up-banking.ts +++ b/tests/generated/v3.0/up-banking.ts @@ -984,14 +984,14 @@ export class Api extends HttpClient this.request({ path: `/accounts`, @@ -1031,7 +1031,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/accounts/${accountId}/transactions`, @@ -1098,7 +1098,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/categories`, @@ -1166,14 +1166,14 @@ export class Api extends HttpClient this.request({ path: `/tags`, @@ -1194,13 +1194,11 @@ export class Api extends HttpClient + relationshipsTagsCreate: (transactionId: string, params: RequestParams = {}) => this.request({ path: `/transactions/${transactionId}/relationships/tags`, method: "POST", - body: data, secure: true, - type: ContentType.Json, ...params, }), @@ -1213,13 +1211,11 @@ export class Api extends HttpClient + relationshipsTagsDelete: (transactionId: string, params: RequestParams = {}) => this.request({ path: `/transactions/${transactionId}/relationships/tags`, method: "DELETE", - body: data, secure: true, - type: ContentType.Json, ...params, }), @@ -1233,7 +1229,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/transactions`, @@ -1320,14 +1316,14 @@ export class Api extends HttpClient this.request({ path: `/webhooks`, @@ -1347,13 +1343,11 @@ export class Api extends HttpClient + webhooksCreate: (params: RequestParams = {}) => this.request({ path: `/webhooks`, method: "POST", - body: data, secure: true, - type: ContentType.Json, format: "json", ...params, }), @@ -1422,14 +1416,14 @@ export class Api extends HttpClient this.request({ path: `/webhooks/${webhookId}/logs`, diff --git a/tests/generated/v3.0/uspto.ts b/tests/generated/v3.0/uspto.ts index 11642234..1135a8fa 100644 --- a/tests/generated/v3.0/uspto.ts +++ b/tests/generated/v3.0/uspto.ts @@ -301,33 +301,10 @@ export class Api extends HttpClient + performSearch: (version: string, dataset: string, params: RequestParams = {}) => this.request[], void>({ path: `/${dataset}/${version}/records`, method: "POST", - body: data, - type: ContentType.UrlEncoded, format: "json", ...params, }), diff --git a/tests/generated/v3.0/wrong-schema-names.ts b/tests/generated/v3.0/wrong-schema-names.ts index 1454e15f..28e3f743 100644 --- a/tests/generated/v3.0/wrong-schema-names.ts +++ b/tests/generated/v3.0/wrong-schema-names.ts @@ -300,10 +300,10 @@ export class Api extends HttpClient this.request({ path: `/2.0/repositories/${username}/${slug}/pullrequests`, diff --git a/tests/spec/deprecated/schema.ts b/tests/spec/deprecated/schema.ts index 55ce422e..23c66fcd 100644 --- a/tests/spec/deprecated/schema.ts +++ b/tests/spec/deprecated/schema.ts @@ -238,7 +238,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, diff --git a/tests/spec/extract-enums/schema.ts b/tests/spec/extract-enums/schema.ts index 7338168b..f11d6b72 100644 --- a/tests/spec/extract-enums/schema.ts +++ b/tests/spec/extract-enums/schema.ts @@ -21,10 +21,10 @@ export enum TypeNamePrefixEnumRootTypeNameSuffix { export interface TypeNamePrefixTreeTypeNameSuffix { tree?: { - mode?: TypeNamePrefixTreeModeTypeNameSuffix; - "mode-num"?: TypeNamePrefixTreeModeNumTypeNameSuffix; - type?: TypeNamePrefixTreeTypeTypeNameSuffix; - bereke?: TypeNamePrefixTreeBerekeTypeNameSuffix; + mode?: TypeNamePrefixEnumRootModeTypeNameSuffix; + "mode-num"?: TypeNamePrefixEnumRootModeNumTypeNameSuffix; + type?: TypeNamePrefixEnumRootTypeTypeNameSuffix; + bereke?: TypeNamePrefixEnumRootBerekeTypeNameSuffix; }[]; } @@ -87,7 +87,7 @@ export enum TypeNamePrefixSomeInterestEnumTypeNameSuffix { EnumKeyPrefix_HSDFDS_EnumKeySuffix = "HSDFDS", } -export enum TypeNamePrefixTreeModeTypeNameSuffix { +export enum TypeNamePrefixEnumRootModeTypeNameSuffix { EnumKeyPrefixInvalidKey100644EnumKeySuffix = "100644", EnumKeyPrefixInvalidKey100755EnumKeySuffix = "100755", EnumKeyPrefixInvalidKey040000EnumKeySuffix = "040000", @@ -95,7 +95,7 @@ export enum TypeNamePrefixTreeModeTypeNameSuffix { EnumKeyPrefixInvalidKey120000EnumKeySuffix = "120000", } -export enum TypeNamePrefixTreeModeNumTypeNameSuffix { +export enum TypeNamePrefixEnumRootModeNumTypeNameSuffix { EnumKeyPrefixInvalidKey100644EnumKeySuffix = 100644, EnumKeyPrefixInvalidKey100755EnumKeySuffix = 100755, EnumKeyPrefixInvalidKey40000EnumKeySuffix = 40000, @@ -103,13 +103,13 @@ export enum TypeNamePrefixTreeModeNumTypeNameSuffix { EnumKeyPrefixInvalidKey120000EnumKeySuffix = 120000, } -export enum TypeNamePrefixTreeTypeTypeNameSuffix { +export enum TypeNamePrefixEnumRootTypeTypeNameSuffix { EnumKeyPrefixBlobEnumKeySuffix = "blob", EnumKeyPrefixTreeEnumKeySuffix = "tree", EnumKeyPrefixCommitEnumKeySuffix = "commit", } -export enum TypeNamePrefixTreeBerekeTypeNameSuffix { +export enum TypeNamePrefixEnumRootBerekeTypeNameSuffix { EnumKeyPrefixBlaEnumKeySuffix = "Bla", EnumKeyPrefixBlablaEnumKeySuffix = "Blabla", EnumKeyPrefixBoilerEnumKeySuffix = "Boiler", diff --git a/tests/spec/multiple-schemas/paths/repro.yaml b/tests/spec/multiple-schemas/paths/repro.yaml new file mode 100644 index 00000000..27b8d933 --- /dev/null +++ b/tests/spec/multiple-schemas/paths/repro.yaml @@ -0,0 +1,8 @@ +hello: + get: + responses: + '200': + content: + application/json: + schema: + type: object \ No newline at end of file diff --git a/tests/spec/multiple-schemas/schema.yaml b/tests/spec/multiple-schemas/schema.yaml new file mode 100644 index 00000000..b262e564 --- /dev/null +++ b/tests/spec/multiple-schemas/schema.yaml @@ -0,0 +1,8 @@ +openapi: 3.0.2 +info: + version: 2.0.0 + title: repro + +paths: + /hello: + $ref: './paths/repro.yaml#/hello' \ No newline at end of file diff --git a/tests/spec/templates/spec_templates/api.eta b/tests/spec/templates/spec_templates/api.eta index bcd21d95..aa16d5a6 100644 --- a/tests/spec/templates/spec_templates/api.eta +++ b/tests/spec/templates/spec_templates/api.eta @@ -45,7 +45,7 @@ export class Api<% if (!config.singleHttpClien <% routes.outOfModule && routes.outOfModule.forEach((route) => { %> - <%~ includeFile('./procedure-call.eta', { ...it, route }) %> + <%~ await includeFile('./procedure-call.eta', { ...it, route }) %> <% }) %> @@ -53,7 +53,7 @@ export class Api<% if (!config.singleHttpClien <%~ moduleName %> = { <% routes.forEach((route) => { %> - <%~ includeFile('./procedure-call.eta', { ...it, route }) %> + <%~ await includeFile('./procedure-call.eta', { ...it, route }) %> <% }) %> } diff --git a/tests/spec/templates/spec_templates/http-client.eta b/tests/spec/templates/spec_templates/http-client.eta index 3b7e1a5f..1e4be481 100644 --- a/tests/spec/templates/spec_templates/http-client.eta +++ b/tests/spec/templates/spec_templates/http-client.eta @@ -1,5 +1,5 @@ <% const { config } = it; %> <% /* https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-clients/ */ %> -<%~ includeFile(`@base/http-clients/${config.httpClientType}-http-client`, it) %> +<%~ await includeFile(`@base/http-clients/${config.httpClientType}-http-client`, it) %> /* HTTP CLIENT TEMPLATE */ \ No newline at end of file diff --git a/tests/spec/templates/spec_templates/procedure-call.eta b/tests/spec/templates/spec_templates/procedure-call.eta index d5a85b00..57bf46bf 100644 --- a/tests/spec/templates/spec_templates/procedure-call.eta +++ b/tests/spec/templates/spec_templates/procedure-call.eta @@ -5,7 +5,7 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe const { parameters, path, method, payload, query, formData, security, requestParams } = route.request; const { type, errorType, contentTypes } = route.response; const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants; -const routeDocs = includeFile("@base/route-docs", { config, route, utils }); +const routeDocs = await includeFile("@base/route-docs", { config, route, utils }); const queryName = (query && query.name) || "query"; const pathParams = _.values(parameters); const pathParamsNames = _.map(pathParams, "name"); @@ -26,7 +26,7 @@ const rawWrapperArgs = config.extractRequestParams ? requestParams && { name: pathParams.length ? `{ ${_.join(pathParamsNames, ", ")}, ...${queryName} }` : queryName, optional: false, - type: getInlineParseContent(requestParams), + type: await getInlineParseContent(requestParams), }, ...(!requestParams ? pathParams : []), payload, diff --git a/tests/spec/templates/spec_templates/route-type.eta b/tests/spec/templates/spec_templates/route-type.eta index 1c7b84c6..5f19835a 100644 --- a/tests/spec/templates/spec_templates/route-type.eta +++ b/tests/spec/templates/spec_templates/route-type.eta @@ -4,7 +4,7 @@ const { _, pascalCase } = utils const { query, payload } = route.request const { type: responseType } = route.response -const routeDocs = includeFile("./route-docs", { config, route, utils }); +const routeDocs = await includeFile("./route-docs", { config, route, utils }); const routeNamespace = pascalCase(route.routeName.usage) const queryType = (query && query.type) || '{}' const bodyType = (payload && payload.type) || 'never' diff --git a/tests/spec/templates/spec_templates/route-types.eta b/tests/spec/templates/spec_templates/route-types.eta index 286141e7..a8fc388f 100644 --- a/tests/spec/templates/spec_templates/route-types.eta +++ b/tests/spec/templates/spec_templates/route-types.eta @@ -7,14 +7,14 @@ const { utils, config, routes } = it; <% routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %> <% routes.forEach((route) => { %> - <%~ includeFile('./route-type.eta', { route, utils, config }) %> + <%~ await includeFile('./route-type.eta', { route, utils, config }) %> <% }) %> <% }) %> <% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> export namespace <%~ moduleName %> { <% routes.forEach((route) => { %> - <%~ includeFile('./route-type.eta', { route, utils, config }) %> + <%~ await includeFile('./route-type.eta', { route, utils, config }) %> <% }) %> } From 3159265b0239c6c6e3c6ecc8c1e527b094cad31c Mon Sep 17 00:00:00 2001 From: js2me Date: Sun, 13 Nov 2022 02:13:43 +0600 Subject: [PATCH 2/9] internal: trying to add async operations in swagger-typescript-api --- src/schema-parser/schema-formatters.js | 4 ++-- src/schema-parser/schema-parser.js | 4 ++-- src/schema-parser/schema-routes.js | 2 +- src/templates.js | 31 +++++++++++++++----------- templates/base/data-contracts.ejs | 8 +++---- templates/base/http-client.ejs | 2 +- templates/base/route-type.ejs | 2 +- templates/default/api.ejs | 26 ++++++++++----------- templates/default/procedure-call.ejs | 3 +++ 9 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/schema-parser/schema-formatters.js b/src/schema-parser/schema-formatters.js index eb4b5930..285186e6 100644 --- a/src/schema-parser/schema-formatters.js +++ b/src/schema-parser/schema-formatters.js @@ -97,10 +97,10 @@ class SchemaFormatters { * @param parsedSchema {Record} * @param formatType {"base" | "inline"} */ - formatSchema = (parsedSchema, formatType = "base") => { + formatSchema = async (parsedSchema, formatType = "base") => { const schemaType = _.get(parsedSchema, ["schemaType"]) || _.get(parsedSchema, ["$parsed", "schemaType"]); const formatterFn = _.get(this, [formatType, schemaType]); - return (formatterFn && formatterFn(parsedSchema)) || parsedSchema; + return (formatterFn && (await formatterFn(parsedSchema))) || parsedSchema; }; formatDescription = (description, inline) => { diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index 0fbc3963..e94748e5 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -398,13 +398,13 @@ class SchemaParser { getInlineParseContent = async (rawTypeData, typeName) => { const parsedSchema = await this.parseSchema(rawTypeData, typeName); - const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "inline"); + const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, "inline"); return formattedSchema.content; }; getParseContent = async (rawTypeData, typeName) => { const parsedSchema = await this.parseSchema(rawTypeData, typeName); - const formattedSchema = this.schemaFormatters.formatSchema(parsedSchema, "base"); + const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, "base"); return formattedSchema.content; }; diff --git a/src/schema-parser/schema-routes.js b/src/schema-parser/schema-routes.js index 9009d2f4..d4c422e2 100644 --- a/src/schema-parser/schema-routes.js +++ b/src/schema-parser/schema-routes.js @@ -754,7 +754,7 @@ class SchemaRoutes { const routeName = await this.getRouteName(rawRouteInfo); - const requestBodyInfo = this.getRequestBodyInfo(routeInfo, routeParams, parsedSchemas, routeName); + const requestBodyInfo = await this.getRequestBodyInfo(routeInfo, routeParams, parsedSchemas, routeName); const requestParamsSchema = this.createRequestParamsSchema({ queryParams: routeParams.query, diff --git a/src/templates.js b/src/templates.js index 69bca81a..e28a9dec 100644 --- a/src/templates.js +++ b/src/templates.js @@ -155,20 +155,25 @@ class Templates { renderTemplate = async (template, configuration, options) => { if (!template) return ""; - return Eta.renderAsync( - template, - { - ...this.getRenderTemplateData(), - ...configuration, - }, - { - async: true, - ...(options || {}), - includeFile: async (path, payload, options) => { - return await this.renderTemplate(this.getTemplateContent(path), payload, options); + try { + return await Eta.renderAsync( + template, + { + ...this.getRenderTemplateData(), + ...configuration, }, - }, - ); + { + async: true, + ...(options || {}), + includeFile: async (path, payload, options) => { + return await this.renderTemplate(this.getTemplateContent(path), payload, options); + }, + }, + ); + } catch (e) { + console.error("problem in this templates\n", template); + throw e; + } }; } diff --git a/templates/base/data-contracts.ejs b/templates/base/data-contracts.ejs index 43361a36..46895544 100644 --- a/templates/base/data-contracts.ejs +++ b/templates/base/data-contracts.ejs @@ -20,9 +20,7 @@ const dataContractTemplates = { type <%~ config.Ts.CodeGenKeyword.UtilRequiredKeys %> = Omit & Required> <% } %> -<% modelTypes.forEach((contract) => { %> - <%~ includeFile('@base/data-contract-jsdoc.ejs', { ...it, data: { ...contract, ...contract.typeData } }) %> +<% for await (const contract of modelTypes) { %> + <%~ await includeFile('@base/data-contract-jsdoc.ejs', { ...it, data: { ...contract, ...contract.typeData } }) %> export <%~ (dataContractTemplates[contract.typeIdentifier] || dataContractTemplates.type)(contract) %> - - -<% }) %> +<% } %> diff --git a/templates/base/http-client.ejs b/templates/base/http-client.ejs index 043c9e1e..201adb9e 100644 --- a/templates/base/http-client.ejs +++ b/templates/base/http-client.ejs @@ -1,3 +1,3 @@ <% const { config } = it; %> <% /* https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-clients/ */ %> -<%~ includeFile(`@base/http-clients/${config.httpClientType}-http-client`, it) %> \ No newline at end of file +<%~ await includeFile(`@base/http-clients/${config.httpClientType}-http-client`, it) %> \ No newline at end of file diff --git a/templates/base/route-type.ejs b/templates/base/route-type.ejs index bdad929f..99e10592 100644 --- a/templates/base/route-type.ejs +++ b/templates/base/route-type.ejs @@ -3,7 +3,7 @@ const { route, utils, config } = it; const { _, pascalCase, require } = utils; const { query, payload, pathParams, headers } = route.request; -const routeDocs = includeFile("@base/route-docs", { config, route, utils }); +const routeDocs = await includeFile("@base/route-docs", { config, route, utils }); const routeNamespace = pascalCase(route.routeName.usage); %> diff --git a/templates/default/api.ejs b/templates/default/api.ejs index 0bf95d6e..11cea32b 100644 --- a/templates/default/api.ejs +++ b/templates/default/api.ejs @@ -23,7 +23,7 @@ const descriptionLines = _.compact([ info.description && " ", info.description && _.replace(formatDescription(info.description), /\n/g, "\n * "), ]); - +console.info(routes) %> <% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %> @@ -47,19 +47,19 @@ export class <%~ config.apiClassName %><% if ( <% } %> -<% routes.outOfModule && routes.outOfModule.forEach((route) => { %> - - <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> - -<% }) %> +<% if (routes.outOfModule) { %> + <% for await (const route of routes.outOfModule) { %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> + <% } %> +<% } %> -<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> +<% if (routes.combined) { %> + <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> <%~ moduleName %> = { - <% routes.forEach((route) => { %> - - <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> - - <% }) %> + <% for await (const route of combinedRoutes) { %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> + <% } %> } -<% }) %> + <% } %> +<% } %> } diff --git a/templates/default/procedure-call.ejs b/templates/default/procedure-call.ejs index 7efd5b7b..5f8a124e 100644 --- a/templates/default/procedure-call.ejs +++ b/templates/default/procedure-call.ejs @@ -45,6 +45,9 @@ const wrapperArgs = _ .map(argToTmpl) .join(', ') +console.info('rawWrapperArgs', rawWrapperArgs) +console.info('wrapperArgs', wrapperArgs) + // RequestParams["type"] const requestContentKind = { "JSON": "ContentType.Json", From 42e80d125010ed02b9d2ac5677d27b523ecb2360 Mon Sep 17 00:00:00 2001 From: js2me Date: Sun, 13 Nov 2022 04:11:17 +0600 Subject: [PATCH 3/9] feat: asynchronous parse routes\schemas etc operations --- src/code-gen-process.js | 13 +- src/schema-parser/schema-formatters.js | 7 +- src/schema-parser/schema-parser.js | 4 +- src/schema-parser/schema-routes.js | 6 +- templates/base/data-contracts.ejs | 3 +- templates/base/interface-data-contract.ejs | 6 +- templates/base/type-data-contract.ejs | 6 +- templates/default/api.ejs | 5 +- templates/default/procedure-call.ejs | 3 - templates/default/route-types.ejs | 24 +- templates/modular/api.ejs | 6 +- templates/modular/procedure-call.ejs | 2 +- templates/modular/route-types.ejs | 6 +- tests/generated/v2.0/adafruit.ts | 439 +- tests/generated/v2.0/another-example.ts | 93 +- tests/generated/v2.0/another-schema.ts | 6 +- tests/generated/v2.0/api-with-examples.ts | 9 +- tests/generated/v2.0/authentiq.ts | 24 +- tests/generated/v2.0/example1.ts | 5 +- tests/generated/v2.0/file-formdata-example.ts | 15 +- tests/generated/v2.0/giphy.ts | 28 +- tests/generated/v2.0/github-swagger.ts | 373 +- tests/generated/v2.0/path-args.ts | 4 +- tests/generated/v2.0/petstore-expanded.ts | 8 +- tests/generated/v2.0/petstore-simple.ts | 8 +- tests/generated/v2.0/petstore-swagger-io.ts | 60 +- .../v2.0/petstore-with-external-docs.ts | 8 +- tests/generated/v2.0/petstore.ts | 4 +- tests/generated/v2.0/query-path-param.ts | 4 +- tests/generated/v2.0/uber.ts | 10 +- tests/generated/v3.0/allof-example.ts | 4 +- tests/generated/v3.0/anyof-example.ts | 4 +- tests/generated/v3.0/api-with-examples.ts | 1 - tests/generated/v3.0/callback-example.ts | 2 +- tests/generated/v3.0/explode-param-3.0.1.ts | 16 +- tests/generated/v3.0/full-swagger-scheme.ts | 4686 +++++++++++++++-- tests/generated/v3.0/link-example.ts | 4 +- tests/generated/v3.0/oneof-example.ts | 4 +- tests/generated/v3.0/personal-api-example.ts | 22 +- tests/generated/v3.0/petstore-expanded.ts | 8 +- tests/generated/v3.0/petstore.ts | 4 +- tests/generated/v3.0/tsoa-odd-types-3.0.2.ts | 32 +- tests/generated/v3.0/up-banking.ts | 40 +- tests/generated/v3.0/uspto.ts | 26 +- tests/generated/v3.0/wrong-schema-names.ts | 4 +- tests/spec/deprecated/schema.ts | 4 +- .../spec_templates/api.eta | 20 +- tests/spec/templates/spec_templates/api.eta | 20 +- .../templates/spec_templates/route-types.eta | 34 +- 49 files changed, 5214 insertions(+), 910 deletions(-) diff --git a/src/code-gen-process.js b/src/code-gen-process.js index 9b8896c4..6b44aa1b 100644 --- a/src/code-gen-process.js +++ b/src/code-gen-process.js @@ -261,10 +261,11 @@ class CodeGenProcess { if (!typeInfo.typeData) { typeInfo.typeData = await this.schemaParser.parseSchema(typeInfo.rawTypeData, typeInfo.typeName); } - const rawTypeData = typeInfo.typeData; - const typeData = this.schemaParser.schemaFormatters.base[rawTypeData.type] - ? this.schemaParser.schemaFormatters.base[rawTypeData.type](rawTypeData) - : rawTypeData; + const typeData = await this.schemaParser.schemaFormatters.formatSchema(typeInfo.typeData, { + formatType: "base", + schemaType: typeInfo.typeData.type, + }); + let { typeIdentifier, name: originalName, content, description } = typeData; const name = this.typeName.format(originalName); @@ -275,8 +276,8 @@ class CodeGenProcess { typeIdentifier, name, description, - $content: rawTypeData.content, - rawContent: rawTypeData.content, + $content: typeInfo.typeData.content, + rawContent: typeInfo.typeData.content, content: content, typeData, }; diff --git a/src/schema-parser/schema-formatters.js b/src/schema-parser/schema-formatters.js index 285186e6..25a36dc8 100644 --- a/src/schema-parser/schema-formatters.js +++ b/src/schema-parser/schema-formatters.js @@ -95,10 +95,11 @@ class SchemaFormatters { /** * @param parsedSchema {Record} - * @param formatType {"base" | "inline"} + * @param cfg {{ formatType?: "base" | "inline", schemaType?: string } } */ - formatSchema = async (parsedSchema, formatType = "base") => { - const schemaType = _.get(parsedSchema, ["schemaType"]) || _.get(parsedSchema, ["$parsed", "schemaType"]); + formatSchema = async (parsedSchema, { schemaType: outerSchemaType, formatType = "base" } = {}) => { + const schemaType = + outerSchemaType || _.get(parsedSchema, ["schemaType"]) || _.get(parsedSchema, ["$parsed", "schemaType"]); const formatterFn = _.get(this, [formatType, schemaType]); return (formatterFn && (await formatterFn(parsedSchema))) || parsedSchema; }; diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index e94748e5..18a099d6 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -398,13 +398,13 @@ class SchemaParser { getInlineParseContent = async (rawTypeData, typeName) => { const parsedSchema = await this.parseSchema(rawTypeData, typeName); - const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, "inline"); + const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "inline" }); return formattedSchema.content; }; getParseContent = async (rawTypeData, typeName) => { const parsedSchema = await this.parseSchema(rawTypeData, typeName); - const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, "base"); + const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "base" }); return formattedSchema.content; }; diff --git a/src/schema-parser/schema-routes.js b/src/schema-parser/schema-routes.js index d4c422e2..9603f381 100644 --- a/src/schema-parser/schema-routes.js +++ b/src/schema-parser/schema-routes.js @@ -785,7 +785,7 @@ class SchemaRoutes { query: queryType ? { name: nameResolver.resolve(RESERVED_QUERY_ARG_NAMES), - optional: await this.schemaParser.parseSchema(queryObjectSchema).allFieldsAreOptional, + optional: (await this.schemaParser.parseSchema(queryObjectSchema)).allFieldsAreOptional, type: queryType, } : void 0, @@ -799,14 +799,14 @@ class SchemaRoutes { pathParams: pathType ? { name: nameResolver.resolve(RESERVED_PATH_ARG_NAMES), - optional: await this.schemaParser.parseSchema(pathObjectSchema).allFieldsAreOptional, + optional: (await this.schemaParser.parseSchema(pathObjectSchema)).allFieldsAreOptional, type: pathType, } : void 0, headers: headersType ? { name: nameResolver.resolve(RESERVED_HEADER_ARG_NAMES), - optional: await this.schemaParser.parseSchema(headersObjectSchema).allFieldsAreOptional, + optional: (await this.schemaParser.parseSchema(headersObjectSchema)).allFieldsAreOptional, type: headersType, } : void 0, diff --git a/templates/base/data-contracts.ejs b/templates/base/data-contracts.ejs index 46895544..742e569e 100644 --- a/templates/base/data-contracts.ejs +++ b/templates/base/data-contracts.ejs @@ -2,7 +2,6 @@ const { modelTypes, utils, config } = it; const { formatDescription, require, _, Ts } = utils; - const dataContractTemplates = { enum: (contract) => { return `enum ${contract.name} {\r\n${contract.content} \r\n }`; @@ -21,6 +20,8 @@ type <%~ config.Ts.CodeGenKeyword.UtilRequiredKeys %> = Om <% } %> <% for await (const contract of modelTypes) { %> + <%~ await includeFile('@base/data-contract-jsdoc.ejs', { ...it, data: { ...contract, ...contract.typeData } }) %> export <%~ (dataContractTemplates[contract.typeIdentifier] || dataContractTemplates.type)(contract) %> + <% } %> diff --git a/templates/base/interface-data-contract.ejs b/templates/base/interface-data-contract.ejs index 29bbed5f..4f075751 100644 --- a/templates/base/interface-data-contract.ejs +++ b/templates/base/interface-data-contract.ejs @@ -3,8 +3,8 @@ const { contract, utils } = it; const { formatDescription, require, _ } = utils; %> export interface <%~ contract.name %> { - <% _.forEach(contract.$content, (field) => { %> - <%~ includeFile('@base/object-field-jsdoc.ejs', { ...it, field }) %> + <% for await (const field of contract.$content) { %> + <%~ await includeFile('@base/object-field-jsdoc.ejs', { ...it, field }) %> <%~ field.name %><%~ field.isRequired ? '' : '?' %>: <%~ field.value %><%~ field.isNullable ? ' | null' : ''%>; - <% }) %> + <% } %> } diff --git a/templates/base/type-data-contract.ejs b/templates/base/type-data-contract.ejs index fb43ce22..b5311091 100644 --- a/templates/base/type-data-contract.ejs +++ b/templates/base/type-data-contract.ejs @@ -5,10 +5,10 @@ const { formatDescription, require, _ } = utils; %> <% if (contract.$content.length) { %> export type <%~ contract.name %> = { - <% _.forEach(contract.$content, (field) => { %> - <%~ includeFile('@base/object-field-jsdoc.ejs', { ...it, field }) %> + <% for await (const field of contract.$content) { %> + <%~ await includeFile('@base/object-field-jsdoc.ejs', { ...it, field }) %> <%~ field.field %>; - <% }) %> + <% } %> }<%~ utils.isNeedToAddNull(contract) ? ' | null' : ''%> <% } else { %> export type <%~ contract.name %> = Record; diff --git a/templates/default/api.ejs b/templates/default/api.ejs index 11cea32b..60c724ca 100644 --- a/templates/default/api.ejs +++ b/templates/default/api.ejs @@ -23,7 +23,6 @@ const descriptionLines = _.compact([ info.description && " ", info.description && _.replace(formatDescription(info.description), /\n/g, "\n * "), ]); -console.info(routes) %> <% if (config.httpClientType === config.constants.HTTP_CLIENT.AXIOS) { %> import { AxiosRequestConfig, AxiosResponse } from "axios"; <% } %> @@ -49,6 +48,8 @@ export class <%~ config.apiClassName %><% if ( <% if (routes.outOfModule) { %> <% for await (const route of routes.outOfModule) { %> + + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> <% } %> <% } %> @@ -57,6 +58,8 @@ export class <%~ config.apiClassName %><% if ( <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> <%~ moduleName %> = { <% for await (const route of combinedRoutes) { %> + + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> <% } %> } diff --git a/templates/default/procedure-call.ejs b/templates/default/procedure-call.ejs index 5f8a124e..7efd5b7b 100644 --- a/templates/default/procedure-call.ejs +++ b/templates/default/procedure-call.ejs @@ -45,9 +45,6 @@ const wrapperArgs = _ .map(argToTmpl) .join(', ') -console.info('rawWrapperArgs', rawWrapperArgs) -console.info('wrapperArgs', wrapperArgs) - // RequestParams["type"] const requestContentKind = { "JSON": "ContentType.Json", diff --git a/templates/default/route-types.ejs b/templates/default/route-types.ejs index f61a47bd..d9116e60 100644 --- a/templates/default/route-types.ejs +++ b/templates/default/route-types.ejs @@ -12,17 +12,21 @@ import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataCont /* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */ %> -<%if (routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %> - <% for await (const route of routes) { %> - <%~ (await includeFile('@base/route-type.ejs', { ...it, route })) %> - <% } %> -<% }) %> -<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> +<% if (routes.outOfModule) { %> + <% for await (const route of routes.outOfModule) { %> + + <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> + <% } %> +<% } %> + +<% if (routes.combined) { %> + <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> + export namespace <%~ pascalCase(moduleName) %> { - <% routes.forEach((route) => { %> + <% for await (const route of combinedRoutes) { %> <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> - <% }) %> + <% } %> } - -<% }) %> + <% } %> +<% } %> diff --git a/templates/modular/api.ejs b/templates/modular/api.ejs index ab371e31..c1335727 100644 --- a/templates/modular/api.ejs +++ b/templates/modular/api.ejs @@ -22,7 +22,7 @@ export class <%= apiClassName %><% if (!config.singl } <% } %> - <% routes.forEach((route) => { %> - <%~ includeFile('./procedure-call.ejs', { ...it, route }) %> - <% }) %> + <% for await (const route of routes) { %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> + <% } %> } diff --git a/templates/modular/procedure-call.ejs b/templates/modular/procedure-call.ejs index aa0369e2..29ef9b85 100644 --- a/templates/modular/procedure-call.ejs +++ b/templates/modular/procedure-call.ejs @@ -5,7 +5,7 @@ const { _, getInlineParseContent, getParseContent, parseSchema, getComponentByRe const { parameters, path, method, payload, query, formData, security, requestParams } = route.request; const { type, errorType, contentTypes } = route.response; const { HTTP_CLIENT, RESERVED_REQ_PARAMS_ARG_NAMES } = config.constants; -const routeDocs = includeFile("@base/route-docs", { config, route, utils }); +const routeDocs = await includeFile("@base/route-docs", { config, route, utils }); const queryName = (query && query.name) || "query"; const pathParams = _.values(parameters); const pathParamsNames = _.map(pathParams, "name"); diff --git a/templates/modular/route-types.ejs b/templates/modular/route-types.ejs index d1f52eea..c5afd86f 100644 --- a/templates/modular/route-types.ejs +++ b/templates/modular/route-types.ejs @@ -10,9 +10,9 @@ import { <%~ dataContracts.join(", ") %> } from "./<%~ config.fileNames.dataCont <% } %> export namespace <%~ pascalCase(moduleName) %> { - <% _.forEach(routes, (route) => { %> + <% for await (const route of routes) { %> - <%~ includeFile('@base/route-type.ejs', { ...it, route }) %> - <% }) %> + <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> + <% } %> } diff --git a/tests/generated/v2.0/adafruit.ts b/tests/generated/v2.0/adafruit.ts index 0433627c..2cc5ce4d 100644 --- a/tests/generated/v2.0/adafruit.ts +++ b/tests/generated/v2.0/adafruit.ts @@ -533,11 +533,19 @@ export class Api extends HttpClient + createWebhookFeedData: ( + token: string, + payload: { + value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/webhooks/feed/${token}`, method: "POST", + body: payload, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -556,6 +564,7 @@ export class Api extends HttpClient extends HttpClient extends HttpClient this.request({ path: `/${username}/activities`, @@ -626,8 +635,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/activities/${type}`, @@ -678,11 +687,13 @@ export class Api extends HttpClient + createDashboard: (username: string, dashboard: Dashboard, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards`, method: "POST", + body: dashboard, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -714,11 +725,13 @@ export class Api extends HttpClient + createBlock: (username: string, dashboardId: string, block: Block, params: RequestParams = {}) => this.request({ path: `/${username}/dashboards/${dashboardId}/blocks`, method: "POST", + body: block, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -768,11 +781,34 @@ export class Api extends HttpClient + updateBlock: ( + username: string, + dashboardId: string, + id: string, + block: { + block_feeds?: { + 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({ path: `/${username}/dashboards/${dashboardId}/blocks/${id}`, method: "PATCH", + body: block, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -786,11 +822,34 @@ export class Api extends HttpClient + replaceBlock: ( + username: string, + dashboardId: string, + id: string, + block: { + block_feeds?: { + 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({ path: `/${username}/dashboards/${dashboardId}/blocks/${id}`, method: "PUT", + body: block, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -840,11 +899,22 @@ export class Api extends HttpClient + updateDashboard: ( + username: string, + id: string, + dashboard: { + description?: string; + key?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/dashboards/${id}`, method: "PATCH", + body: dashboard, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -858,11 +928,22 @@ export class Api extends HttpClient + replaceDashboard: ( + username: string, + id: string, + dashboard: { + description?: string; + key?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/dashboards/${id}`, method: "PUT", + body: dashboard, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -896,16 +977,19 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds`, method: "POST", query: query, + body: feed, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -954,11 +1038,23 @@ export class Api extends HttpClient + updateFeed: ( + username: string, + feedKey: string, + feed: { + description?: string; + key?: string; + license?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/feeds/${feedKey}`, method: "PATCH", + body: feed, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -972,11 +1068,23 @@ export class Api extends HttpClient + replaceFeed: ( + username: string, + feedKey: string, + feed: { + description?: string; + key?: string; + license?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/feeds/${feedKey}`, method: "PUT", + body: feed, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -993,8 +1101,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data`, @@ -1029,11 +1137,26 @@ export class Api extends HttpClient + createData: ( + username: string, + feedKey: string, + datum: { + /** @format dateTime */ + created_at?: string; + ele?: string; + epoch?: number; + lat?: string; + lon?: string; + value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/feeds/${feedKey}/data`, method: "POST", + body: datum, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1047,11 +1170,13 @@ export class Api extends HttpClient + batchCreateData: (username: string, feedKey: string, data: Data, params: RequestParams = {}) => this.request({ path: `/${username}/feeds/${feedKey}/data/batch`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1068,8 +1193,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -1127,17 +1252,18 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/first`, method: "GET", query: query, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1154,17 +1280,18 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/last`, method: "GET", query: query, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1181,17 +1308,18 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/next`, method: "GET", query: query, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1208,17 +1336,18 @@ export class Api extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/previous`, method: "GET", query: query, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1237,6 +1366,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, @@ -1295,11 +1425,27 @@ export class Api extends HttpClient + updateData: ( + username: string, + feedKey: string, + id: string, + datum: { + /** @format dateTime */ + created_at?: string; + ele?: string; + epoch?: number; + lat?: string; + lon?: string; + value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, method: "PATCH", + body: datum, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1313,11 +1459,27 @@ export class Api extends HttpClient + replaceData: ( + username: string, + feedKey: string, + id: string, + datum: { + /** @format dateTime */ + created_at?: string; + ele?: string; + epoch?: number; + lat?: string; + lon?: string; + value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/feeds/${feedKey}/data/${id}`, method: "PUT", + body: datum, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1367,11 +1529,13 @@ export class Api extends HttpClient + createGroup: (username: string, group: Group, params: RequestParams = {}) => this.request({ path: `/${username}/groups`, method: "POST", + body: group, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1421,11 +1585,22 @@ export class Api extends HttpClient + updateGroup: ( + username: string, + groupKey: string, + group: { + description?: string; + key?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}`, method: "PATCH", + body: group, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1439,11 +1614,22 @@ export class Api extends HttpClient + replaceGroup: ( + username: string, + groupKey: string, + group: { + description?: string; + key?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}`, method: "PUT", + body: group, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1460,10 +1646,10 @@ export class Api extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/add`, @@ -1483,11 +1669,32 @@ export class Api extends HttpClient + createGroupData: ( + username: string, + groupKey: string, + group_feed_data: { + /** Optional created_at timestamp which will be applied to all feed values created. */ + created_at?: string; + /** An array of feed data records with `key` and `value` properties. */ + feeds: { + key: string; + value: string; + }[]; + /** A location record with `lat`, `lon`, and [optional] `ele` properties. */ + location?: { + ele?: number; + lat: number; + lon: number; + }; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}/data`, method: "POST", + body: group_feed_data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1519,11 +1726,23 @@ export class Api extends HttpClient + createGroupFeed: ( + username: string, + groupKey: string, + feed: { + description?: string; + key?: string; + license?: string; + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}/feeds`, method: "POST", + body: feed, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1541,8 +1760,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data`, @@ -1575,11 +1794,27 @@ export class Api extends HttpClient + createGroupFeedData: ( + username: string, + groupKey: string, + feedKey: string, + datum: { + /** @format dateTime */ + created_at?: string; + ele?: string; + epoch?: number; + lat?: string; + lon?: string; + value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data`, method: "POST", + body: datum, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1593,11 +1828,27 @@ export class Api extends HttpClient + batchCreateGroupFeedData: ( + username: string, + groupKey: string, + feedKey: string, + data: { + /** @format dateTime */ + created_at?: string; + ele?: string; + epoch?: number; + lat?: string; + lon?: string; + value?: string; + }[], + params: RequestParams = {}, + ) => this.request({ path: `/${username}/groups/${groupKey}/feeds/${feedKey}/data/batch`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1614,10 +1865,10 @@ export class Api extends HttpClient this.request({ path: `/${username}/groups/${groupKey}/remove`, @@ -1681,11 +1932,13 @@ export class Api extends HttpClient + createToken: (username: string, token: Token, params: RequestParams = {}) => this.request({ path: `/${username}/tokens`, method: "POST", + body: token, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1735,11 +1988,20 @@ export class Api extends HttpClient + updateToken: ( + username: string, + id: string, + token: { + token?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/tokens/${id}`, method: "PATCH", + body: token, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1753,11 +2015,20 @@ export class Api extends HttpClient + replaceToken: ( + username: string, + id: string, + token: { + token?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/tokens/${id}`, method: "PUT", + body: token, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1789,11 +2060,13 @@ export class Api extends HttpClient + createTrigger: (username: string, trigger: Trigger, params: RequestParams = {}) => this.request({ path: `/${username}/triggers`, method: "POST", + body: trigger, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1843,11 +2116,20 @@ export class Api extends HttpClient + updateTrigger: ( + username: string, + id: string, + trigger: { + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/triggers/${id}`, method: "PATCH", + body: trigger, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1861,11 +2143,20 @@ export class Api extends HttpClient + replaceTrigger: ( + username: string, + id: string, + trigger: { + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/triggers/${id}`, method: "PUT", + body: trigger, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1897,11 +2188,19 @@ export class Api extends HttpClient + createPermission: ( + username: string, + type: string, + typeId: string, + permission: Permission, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/${type}/${typeId}/acl`, method: "POST", + body: permission, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1951,11 +2250,26 @@ export class Api extends HttpClient + updatePermission: ( + username: string, + type: string, + typeId: string, + id: string, + permission: { + /** @default "r" */ + mode?: "r" | "w" | "rw"; + /** @default "public" */ + scope?: "secret" | "public" | "user" | "organization"; + scope_value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/${type}/${typeId}/acl/${id}`, method: "PATCH", + body: permission, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1969,11 +2283,26 @@ export class Api extends HttpClient + replacePermission: ( + username: string, + type: string, + typeId: string, + id: string, + permission: { + /** @default "r" */ + mode?: "r" | "w" | "rw"; + /** @default "public" */ + scope?: "secret" | "public" | "user" | "organization"; + scope_value?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${username}/${type}/${typeId}/acl/${id}`, method: "PUT", + body: permission, secure: true, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/another-example.ts b/tests/generated/v2.0/another-example.ts index 85a49467..e68edcd1 100644 --- a/tests/generated/v2.0/another-example.ts +++ b/tests/generated/v2.0/another-example.ts @@ -374,11 +374,13 @@ export class Api extends HttpClient + addPet: (body: Pet, params: RequestParams = {}) => this.request({ path: `/pet`, method: "POST", + body: body, secure: true, + type: ContentType.Json, ...params, }), @@ -391,11 +393,13 @@ export class Api extends HttpClient + updatePet: (body: Pet, params: RequestParams = {}) => this.request({ path: `/pet`, method: "PUT", + body: body, secure: true, + type: ContentType.Json, ...params, }), @@ -409,11 +413,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByStatus`, @@ -432,10 +436,19 @@ export class Api extends HttpClient + singleFormUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/single-form-url-encoded`, method: "POST", + body: data, + type: ContentType.UrlEncoded, ...params, }), @@ -447,10 +460,19 @@ export class Api extends HttpClient + formUrlEncodedRequest: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/form-url-encoded`, method: "POST", + body: data, + type: ContentType.UrlEncoded, ...params, }), @@ -464,10 +486,19 @@ export class Api extends HttpClient + formUrlEncodedRequest2: ( + data: { + /** @format string */ + param1: string; + param2: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/end-form-url-encoded`, method: "POST", + body: data, + type: ContentType.UrlEncoded, ...params, }), @@ -482,11 +513,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByTags`, @@ -524,11 +555,22 @@ export class Api extends HttpClient + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/${petId}`, method: "POST", + body: data, secure: true, + type: ContentType.FormData, ...params, }), @@ -558,11 +600,22 @@ export class Api extends HttpClient + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/${petId}/uploadImage`, method: "POST", + body: data, secure: true, + type: ContentType.FormData, format: "json", ...params, }), @@ -594,10 +647,12 @@ export class Api extends HttpClient + placeOrder: (body: Order, params: RequestParams = {}) => this.request({ path: `/store/order`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -642,10 +697,12 @@ export class Api extends HttpClient + createUser: (body: User, params: RequestParams = {}) => this.request({ path: `/user`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -657,10 +714,12 @@ export class Api extends HttpClient + createUsersWithArrayInput: (body: User[], params: RequestParams = {}) => this.request({ path: `/user/createWithArray`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -672,10 +731,12 @@ export class Api extends HttpClient + createUsersWithListInput: (body: User[], params: RequestParams = {}) => this.request({ path: `/user/createWithList`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -688,13 +749,13 @@ export class Api extends HttpClient this.request({ path: `/user/login`, @@ -743,10 +804,12 @@ export class Api extends HttpClient + updateUser: (username: string, body: User, params: RequestParams = {}) => this.request({ path: `/user/${username}`, method: "PUT", + body: body, + type: ContentType.Json, ...params, }), diff --git a/tests/generated/v2.0/another-schema.ts b/tests/generated/v2.0/another-schema.ts index 50b4de18..d336b24e 100644 --- a/tests/generated/v2.0/another-schema.ts +++ b/tests/generated/v2.0/another-schema.ts @@ -268,11 +268,11 @@ export class Api extends HttpClient this.request({ path: `/api/Foo/GetBar`, @@ -289,10 +289,12 @@ export class Api extends HttpClient + fooSetBar: (value: Bar | null, params: RequestParams = {}) => this.request({ path: `/api/Foo/SetBar`, method: "POST", + body: value, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/api-with-examples.ts b/tests/generated/v2.0/api-with-examples.ts index 0bc172d8..4ea76d2e 100644 --- a/tests/generated/v2.0/api-with-examples.ts +++ b/tests/generated/v2.0/api-with-examples.ts @@ -238,7 +238,6 @@ export class Api extends HttpClient extends HttpClient + withCharset: (someParm: string, params: RequestParams = {}) => this.request({ path: `/with-charset/`, method: "POST", + body: someParm, + type: ContentType.Json, ...params, }), }; @@ -278,10 +279,12 @@ export class Api extends HttpClient + consumesPlainText: (someParm: string, params: RequestParams = {}) => this.request({ path: `/consumes-plain-text/`, method: "POST", + body: someParm, + type: ContentType.Text, ...params, }), }; diff --git a/tests/generated/v2.0/authentiq.ts b/tests/generated/v2.0/authentiq.ts index 88993fca..7fe19e9e 100644 --- a/tests/generated/v2.0/authentiq.ts +++ b/tests/generated/v2.0/authentiq.ts @@ -315,7 +315,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -346,7 +346,7 @@ export class Api extends HttpClient + keyRegister: (body: AuthentiqID, params: RequestParams = {}) => this.request< { /** revoke key */ @@ -358,6 +358,7 @@ export class Api extends HttpClient({ path: `/key`, method: "POST", + body: body, format: "json", ...params, }), @@ -371,11 +372,11 @@ export class Api extends HttpClient this.request< { @@ -436,7 +437,7 @@ export class Api extends HttpClient + keyUpdate: (pk: string, body: AuthentiqID, params: RequestParams = {}) => this.request< { /** confirmed */ @@ -446,6 +447,7 @@ export class Api extends HttpClient({ path: `/key/${pk}`, method: "POST", + body: body, format: "json", ...params, }), @@ -457,7 +459,7 @@ export class Api extends HttpClient + keyBind: (pk: string, body: AuthentiqID, params: RequestParams = {}) => this.request< { /** confirmed */ @@ -467,6 +469,7 @@ export class Api extends HttpClient({ path: `/key/${pk}`, method: "PUT", + body: body, format: "json", ...params, }), @@ -480,11 +483,12 @@ export class Api extends HttpClient this.request< { @@ -496,6 +500,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -527,6 +533,7 @@ export class Api extends HttpClient extends HttpClient({ path: `/scope/${job}`, method: "POST", + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/example1.ts b/tests/generated/v2.0/example1.ts index 86464a5d..5fbe9b93 100644 --- a/tests/generated/v2.0/example1.ts +++ b/tests/generated/v2.0/example1.ts @@ -276,16 +276,19 @@ export class Api extends HttpClient this.request({ path: `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroupName}/providers/Microsoft.Sql/managedInstances/${managedInstanceName}/tdeCertificates`, method: "POST", query: query, + body: parameters, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/file-formdata-example.ts b/tests/generated/v2.0/file-formdata-example.ts index 183e47d1..023d994a 100644 --- a/tests/generated/v2.0/file-formdata-example.ts +++ b/tests/generated/v2.0/file-formdata-example.ts @@ -233,10 +233,23 @@ export class Api extends HttpClient + uploadFile: ( + data: { + /** + * File description + * @format binary + */ + file?: File; + /** Boolean flag */ + someFlag?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/upload-file`, method: "POST", + body: data, + type: ContentType.FormData, ...params, }), }; diff --git a/tests/generated/v2.0/giphy.ts b/tests/generated/v2.0/giphy.ts index 570b6326..358dd58a 100644 --- a/tests/generated/v2.0/giphy.ts +++ b/tests/generated/v2.0/giphy.ts @@ -498,11 +498,11 @@ export class Api extends HttpClient this.request< { @@ -532,13 +532,13 @@ export class Api extends HttpClient this.request< { @@ -566,7 +566,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -616,11 +616,11 @@ export class Api extends HttpClient this.request< { @@ -648,8 +648,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -720,13 +720,13 @@ export class Api extends HttpClient this.request< { @@ -754,7 +754,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -804,11 +804,11 @@ export class Api extends HttpClient this.request< { @@ -836,8 +836,7 @@ export class Api extends HttpClient extends HttpClient this.request< { diff --git a/tests/generated/v2.0/github-swagger.ts b/tests/generated/v2.0/github-swagger.ts index a201d019..a81c8234 100644 --- a/tests/generated/v2.0/github-swagger.ts +++ b/tests/generated/v2.0/github-swagger.ts @@ -2136,8 +2136,8 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/someop`, method: "POST", query: query, + body: data, format: "json", ...params, }), @@ -2169,19 +2171,21 @@ export class Api extends HttpClient this.request({ path: `/someop/${fooId}/bars/bar-bar`, method: "POST", query: query, + body: data, format: "json", ...params, }), @@ -2239,14 +2243,14 @@ export class Api extends HttpClient this.request({ path: `/gists`, @@ -2262,10 +2266,12 @@ export class Api extends HttpClient + gistsCreate: (body: PostGist, params: RequestParams = {}) => this.request({ path: `/gists`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -2277,14 +2283,14 @@ export class Api extends HttpClient this.request({ path: `/gists/public`, @@ -2301,14 +2307,14 @@ export class Api extends HttpClient this.request({ path: `/gists/starred`, @@ -2351,10 +2357,12 @@ export class Api extends HttpClient + gistsPartialUpdate: (id: number, body: PatchGist, params: RequestParams = {}) => this.request({ path: `/gists/${id}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -2379,10 +2387,11 @@ export class Api extends HttpClient + commentsCreate: (id: number, body: CommentBody, params: RequestParams = {}) => this.request({ path: `/gists/${id}/comments`, method: "POST", + body: body, format: "json", ...params, }), @@ -2422,10 +2431,12 @@ export class Api extends HttpClient + commentsPartialUpdate: (id: number, commentId: number, body: Comment, params: RequestParams = {}) => this.request({ path: `/gists/${id}/comments/${commentId}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -2519,7 +2530,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/issues`, @@ -2581,8 +2592,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/legacy/repos/search/${keyword}`, @@ -2628,8 +2639,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/legacy/user/search/${keyword}`, @@ -2656,10 +2667,12 @@ export class Api extends HttpClient + markdownCreate: (body: Markdown, params: RequestParams = {}) => this.request({ path: `/markdown`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -2673,6 +2686,7 @@ export class Api extends HttpClient({ path: `/markdown/raw`, method: "POST", + type: ContentType.Text, ...params, }), }; @@ -2714,8 +2728,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/notifications`, @@ -2744,10 +2758,11 @@ export class Api extends HttpClient + notificationsUpdate: (body: NotificationMarkRead, params: RequestParams = {}) => this.request({ path: `/notifications`, method: "PUT", + body: body, ...params, }), @@ -2811,10 +2826,12 @@ export class Api extends HttpClient + threadsSubscriptionUpdate: (id: number, body: PutSubscription, params: RequestParams = {}) => this.request({ path: `/notifications/threads/${id}/subscription`, method: "PUT", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -2840,10 +2857,12 @@ export class Api extends HttpClient + orgsPartialUpdate: (org: string, body: PatchOrg, params: RequestParams = {}) => this.request({ path: `/orgs/${org}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -2870,7 +2889,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/issues`, @@ -3006,11 +3025,11 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/repos`, @@ -3026,10 +3045,11 @@ export class Api extends HttpClient + reposCreate: (org: string, body: PostRepo, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/repos`, method: "POST", + body: body, format: "json", ...params, }), @@ -3054,10 +3074,12 @@ export class Api extends HttpClient + teamsCreate: (org: string, body: OrgTeamsPost, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/teams`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3111,10 +3133,12 @@ export class Api extends HttpClient + reposPartialUpdate: (owner: string, repo: string, body: RepoEdit, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3282,10 +3306,17 @@ export class Api extends HttpClient + commentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/comments/${commentId}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -3299,8 +3330,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits`, @@ -3374,10 +3405,18 @@ export class Api extends HttpClient + commitsCommentsCreate: ( + owner: string, + repo: string, + shaCode: string, + body: CommitCommentBody, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/commits/${shaCode}/comments`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3402,10 +3441,12 @@ export class Api extends HttpClient + contentsDelete: (owner: string, repo: string, path: string, body: DeleteFileBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "DELETE", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3420,13 +3461,13 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, @@ -3442,10 +3483,12 @@ export class Api extends HttpClient + contentsUpdate: (owner: string, repo: string, path: string, body: CreateFileBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "PUT", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3459,11 +3502,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contributors`, @@ -3493,10 +3536,12 @@ export class Api extends HttpClient + deploymentsCreate: (owner: string, repo: string, body: Deployment, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/deployments`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3521,10 +3566,18 @@ export class Api extends HttpClient + deploymentsStatusesCreate: ( + owner: string, + repo: string, + id: number, + body: DeploymentStatusesCreate, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/deployments/${id}/statuses`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -3597,11 +3650,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/forks`, @@ -3617,10 +3670,12 @@ export class Api extends HttpClient + forksCreate: (owner: string, repo: string, body: ForkBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/forks`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3631,10 +3686,12 @@ export class Api extends HttpClient + gitBlobsCreate: (owner: string, repo: string, body: Blob, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/blobs`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3659,10 +3716,12 @@ export class Api extends HttpClient + gitCommitsCreate: (owner: string, repo: string, body: RepoCommitBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/commits`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3701,10 +3760,12 @@ export class Api extends HttpClient + gitRefsCreate: (owner: string, repo: string, body: RefsBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3744,10 +3805,12 @@ export class Api extends HttpClient + gitRefsPartialUpdate: (owner: string, repo: string, ref: string, body: GitRefPatch, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/refs/${ref}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3758,10 +3821,12 @@ export class Api extends HttpClient + gitTagsCreate: (owner: string, repo: string, body: TagBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/tags`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3786,10 +3851,12 @@ export class Api extends HttpClient + gitTreesCreate: (owner: string, repo: string, body: Tree, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/git/trees`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -3804,11 +3871,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/trees/${shaCode}`, @@ -3838,10 +3905,11 @@ export class Api extends HttpClient + hooksCreate: (owner: string, repo: string, body: HookBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks`, method: "POST", + body: body, format: "json", ...params, }), @@ -3881,10 +3949,11 @@ export class Api extends HttpClient + hooksPartialUpdate: (owner: string, repo: string, hookId: number, body: HookBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -3911,7 +3980,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues`, @@ -3948,10 +4017,11 @@ export class Api extends HttpClient + issuesCreate: (owner: string, repo: string, body: Issue, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues`, method: "POST", + body: body, format: "json", ...params, }), @@ -3965,8 +4035,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/comments`, @@ -4020,10 +4090,17 @@ export class Api extends HttpClient + issuesCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4080,10 +4157,11 @@ export class Api extends HttpClient + issuesPartialUpdate: (owner: string, repo: string, number: number, body: Issue, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4110,10 +4188,17 @@ export class Api extends HttpClient + issuesCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: CommentBody, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/comments`, method: "POST", + body: body, format: "json", ...params, }), @@ -4167,10 +4252,11 @@ export class Api extends HttpClient + issuesLabelsCreate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/labels`, method: "POST", + body: body, format: "json", ...params, }), @@ -4181,10 +4267,11 @@ export class Api extends HttpClient + issuesLabelsUpdate: (owner: string, repo: string, number: number, body: EmailsPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/issues/${number}/labels`, method: "PUT", + body: body, format: "json", ...params, }), @@ -4224,10 +4311,11 @@ export class Api extends HttpClient + keysCreate: (owner: string, repo: string, body: UserKeysPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/keys`, method: "POST", + body: body, format: "json", ...params, }), @@ -4281,10 +4369,11 @@ export class Api extends HttpClient + labelsCreate: (owner: string, repo: string, body: EmailsPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels`, method: "POST", + body: body, format: "json", ...params, }), @@ -4324,10 +4413,11 @@ export class Api extends HttpClient + labelsPartialUpdate: (owner: string, repo: string, name: string, body: EmailsPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/labels/${name}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4352,10 +4442,12 @@ export class Api extends HttpClient + mergesCreate: (owner: string, repo: string, body: MergesBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/merges`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4369,8 +4461,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones`, @@ -4396,10 +4488,11 @@ export class Api extends HttpClient + milestonesCreate: (owner: string, repo: string, body: MilestoneUpdate, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/milestones`, method: "POST", + body: body, format: "json", ...params, }), @@ -4439,10 +4532,17 @@ export class Api extends HttpClient + milestonesPartialUpdate: ( + owner: string, + repo: string, + number: number, + body: MilestoneUpdate, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/milestones/${number}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4470,8 +4570,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/notifications`, @@ -4500,10 +4600,11 @@ export class Api extends HttpClient + notificationsUpdate: (owner: string, repo: string, body: NotificationMarkRead, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/notifications`, method: "PUT", + body: body, ...params, }), @@ -4516,8 +4617,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls`, @@ -4546,10 +4647,12 @@ export class Api extends HttpClient + pullsCreate: (owner: string, repo: string, body: PullsPost, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4563,8 +4666,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/comments`, @@ -4618,10 +4721,17 @@ export class Api extends HttpClient + pullsCommentsPartialUpdate: ( + owner: string, + repo: string, + commentId: number, + body: CommentBody, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4648,10 +4758,12 @@ export class Api extends HttpClient + pullsPartialUpdate: (owner: string, repo: string, number: number, body: PullUpdate, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4678,10 +4790,18 @@ export class Api extends HttpClient + pullsCommentsCreate: ( + owner: string, + repo: string, + number: number, + body: PullsCommentPost, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}/comments`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4733,10 +4853,12 @@ export class Api extends HttpClient + pullsMergeUpdate: (owner: string, repo: string, number: number, body: MergePullBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/pulls/${number}/merge`, method: "PUT", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4750,11 +4872,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/readme`, @@ -4784,10 +4906,11 @@ export class Api extends HttpClient + releasesCreate: (owner: string, repo: string, body: ReleaseCreate, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases`, method: "POST", + body: body, format: "json", ...params, }), @@ -4825,10 +4948,18 @@ export class Api extends HttpClient + releasesAssetsPartialUpdate: ( + owner: string, + repo: string, + id: string, + body: AssetPatch, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/releases/assets/${id}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -4868,10 +4999,11 @@ export class Api extends HttpClient + releasesPartialUpdate: (owner: string, repo: string, id: string, body: ReleaseCreate, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/releases/${id}`, method: "PATCH", + body: body, format: "json", ...params, }), @@ -4996,10 +5128,12 @@ export class Api extends HttpClient + statusesCreate: (owner: string, repo: string, ref: string, body: HeadBranch, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/statuses/${ref}`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -5051,10 +5185,12 @@ export class Api extends HttpClient + subscriptionUpdate: (owner: string, repo: string, body: SubscriptionBody, params: RequestParams = {}) => this.request({ path: `/repos/${owner}/${repo}/subscription`, method: "PUT", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -5130,14 +5266,14 @@ export class Api extends HttpClient this.request({ path: `/repositories`, @@ -5155,7 +5291,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/code`, @@ -5201,7 +5337,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/issues`, @@ -5229,7 +5365,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/repositories`, @@ -5271,7 +5407,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/search/users`, @@ -5339,10 +5475,12 @@ export class Api extends HttpClient + teamsPartialUpdate: (teamId: number, body: EditTeam, params: RequestParams = {}) => this.request({ path: `/teams/${teamId}`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -5522,10 +5660,12 @@ export class Api extends HttpClient + userPartialUpdate: (body: UserUpdate, params: RequestParams = {}) => this.request({ path: `/user`, method: "PATCH", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -5536,10 +5676,12 @@ export class Api extends HttpClient + emailsDelete: (body: UserEmails, params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "DELETE", + body: body, + type: ContentType.Json, ...params, }), @@ -5562,10 +5704,11 @@ export class Api extends HttpClient + emailsCreate: (body: EmailsPost, params: RequestParams = {}) => this.request({ path: `/user/emails`, method: "POST", + body: body, ...params, }), @@ -5643,7 +5786,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/issues`, @@ -5694,10 +5837,11 @@ export class Api extends HttpClient + keysCreate: (body: UserKeysPost, params: RequestParams = {}) => this.request({ path: `/user/keys`, method: "POST", + body: body, format: "json", ...params, }), @@ -5750,11 +5894,11 @@ export class Api extends HttpClient this.request({ path: `/user/repos`, @@ -5770,10 +5914,11 @@ export class Api extends HttpClient + reposCreate: (body: PostRepo, params: RequestParams = {}) => this.request({ path: `/user/repos`, method: "POST", + body: body, format: "json", ...params, }), @@ -5785,13 +5930,13 @@ export class Api extends HttpClient this.request({ path: `/user/starred`, @@ -5918,11 +6063,11 @@ export class Api extends HttpClient this.request({ path: `/users`, @@ -6007,14 +6152,14 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/gists`, @@ -6086,11 +6231,11 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/repos`, diff --git a/tests/generated/v2.0/path-args.ts b/tests/generated/v2.0/path-args.ts index 09dcb131..0d1a861b 100644 --- a/tests/generated/v2.0/path-args.ts +++ b/tests/generated/v2.0/path-args.ts @@ -239,14 +239,14 @@ export class Api extends HttpClient this.request({ path: `/pets/${param1}/${param2}/${param3}`, diff --git a/tests/generated/v2.0/petstore-expanded.ts b/tests/generated/v2.0/petstore-expanded.ts index 0185c637..2158c9d3 100644 --- a/tests/generated/v2.0/petstore-expanded.ts +++ b/tests/generated/v2.0/petstore-expanded.ts @@ -288,8 +288,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -313,10 +313,12 @@ export class Api extends HttpClient + addPet: (pet: NewPet, params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", + body: pet, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore-simple.ts b/tests/generated/v2.0/petstore-simple.ts index d016bea7..7950a2df 100644 --- a/tests/generated/v2.0/petstore-simple.ts +++ b/tests/generated/v2.0/petstore-simple.ts @@ -262,8 +262,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -287,10 +287,12 @@ export class Api extends HttpClient + addPet: (pet: NewPet, params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", + body: pet, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore-swagger-io.ts b/tests/generated/v2.0/petstore-swagger-io.ts index e46b670c..cadbd75e 100644 --- a/tests/generated/v2.0/petstore-swagger-io.ts +++ b/tests/generated/v2.0/petstore-swagger-io.ts @@ -320,11 +320,22 @@ export class Api extends HttpClient + updatePetWithForm: ( + petId: number, + data: { + /** Updated name of the pet */ + name?: string; + /** Updated status of the pet */ + status?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/${petId}`, method: "POST", + body: data, secure: true, + type: ContentType.FormData, ...params, }), @@ -354,11 +365,22 @@ export class Api extends HttpClient + uploadFile: ( + petId: number, + data: { + /** Additional data to pass to server */ + additionalMetadata?: string; + /** file to upload */ + file?: File; + }, + params: RequestParams = {}, + ) => this.request({ path: `/pet/${petId}/uploadImage`, method: "POST", + body: data, secure: true, + type: ContentType.FormData, format: "json", ...params, }), @@ -372,11 +394,13 @@ export class Api extends HttpClient + addPet: (body: Pet, params: RequestParams = {}) => this.request({ path: `/pet`, method: "POST", + body: body, secure: true, + type: ContentType.Json, ...params, }), @@ -389,11 +413,13 @@ export class Api extends HttpClient + updatePet: (body: Pet, params: RequestParams = {}) => this.request({ path: `/pet`, method: "PUT", + body: body, secure: true, + type: ContentType.Json, ...params, }), @@ -407,11 +433,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByStatus`, @@ -433,11 +459,11 @@ export class Api extends HttpClient this.request({ path: `/pet/findByTags`, @@ -506,10 +532,12 @@ export class Api extends HttpClient + placeOrder: (body: Order, params: RequestParams = {}) => this.request({ path: `/store/order`, method: "POST", + body: body, + type: ContentType.Json, format: "json", ...params, }), @@ -539,10 +567,12 @@ export class Api extends HttpClient + updateUser: (username: string, body: User, params: RequestParams = {}) => this.request({ path: `/user/${username}`, method: "PUT", + body: body, + type: ContentType.Json, ...params, }), @@ -570,13 +600,13 @@ export class Api extends HttpClient this.request({ path: `/user/login`, @@ -609,10 +639,12 @@ export class Api extends HttpClient + createUser: (body: User, params: RequestParams = {}) => this.request({ path: `/user`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -624,10 +656,12 @@ export class Api extends HttpClient + createUsersWithArrayInput: (body: User[], params: RequestParams = {}) => this.request({ path: `/user/createWithArray`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), @@ -639,10 +673,12 @@ export class Api extends HttpClient + createUsersWithListInput: (body: User[], params: RequestParams = {}) => this.request({ path: `/user/createWithList`, method: "POST", + body: body, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v2.0/petstore-with-external-docs.ts b/tests/generated/v2.0/petstore-with-external-docs.ts index db7d25e4..3e901f9c 100644 --- a/tests/generated/v2.0/petstore-with-external-docs.ts +++ b/tests/generated/v2.0/petstore-with-external-docs.ts @@ -255,8 +255,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -280,10 +280,12 @@ export class Api extends HttpClient + addPet: (pet: NewPet, params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", + body: pet, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v2.0/petstore.ts b/tests/generated/v2.0/petstore.ts index 33597045..88d19bd3 100644 --- a/tests/generated/v2.0/petstore.ts +++ b/tests/generated/v2.0/petstore.ts @@ -251,14 +251,14 @@ export class Api extends HttpClient this.request({ path: `/pets`, diff --git a/tests/generated/v2.0/query-path-param.ts b/tests/generated/v2.0/query-path-param.ts index 8a3e8062..6495af64 100644 --- a/tests/generated/v2.0/query-path-param.ts +++ b/tests/generated/v2.0/query-path-param.ts @@ -237,14 +237,14 @@ export class Api extends HttpClient this.request({ path: `/foobarbaz/${query}`, diff --git a/tests/generated/v2.0/uber.ts b/tests/generated/v2.0/uber.ts index 8aceed13..b2762c2a 100644 --- a/tests/generated/v2.0/uber.ts +++ b/tests/generated/v2.0/uber.ts @@ -317,7 +317,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/products`, @@ -350,7 +350,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/estimates/price`, @@ -391,7 +391,6 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/estimates/time`, @@ -447,8 +447,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/history`, diff --git a/tests/generated/v3.0/allof-example.ts b/tests/generated/v3.0/allof-example.ts index 9da5d763..ed5ab192 100644 --- a/tests/generated/v3.0/allof-example.ts +++ b/tests/generated/v3.0/allof-example.ts @@ -245,10 +245,12 @@ export class Api extends HttpClient + petsPartialUpdate: (data: Cat | Dog, params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", + body: data, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/anyof-example.ts b/tests/generated/v3.0/anyof-example.ts index d1864909..d999e9c7 100644 --- a/tests/generated/v3.0/anyof-example.ts +++ b/tests/generated/v3.0/anyof-example.ts @@ -241,10 +241,12 @@ export class Api extends HttpClient + petsPartialUpdate: (data: PetByAge | PetByType | (PetByAge & PetByType), params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", + body: data, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/api-with-examples.ts b/tests/generated/v3.0/api-with-examples.ts index 707d61b5..9264c480 100644 --- a/tests/generated/v3.0/api-with-examples.ts +++ b/tests/generated/v3.0/api-with-examples.ts @@ -238,7 +238,6 @@ export class Api extends HttpClient extends HttpClient extends HttpClient this.request< { diff --git a/tests/generated/v3.0/explode-param-3.0.1.ts b/tests/generated/v3.0/explode-param-3.0.1.ts index 038ba83f..5b48d4b3 100644 --- a/tests/generated/v3.0/explode-param-3.0.1.ts +++ b/tests/generated/v3.0/explode-param-3.0.1.ts @@ -253,10 +253,20 @@ export class Api extends HttpClient + createFile: ( + user: string, + data: { + /** @default "" */ + meme: string; + memeType?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/${user}/foos`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -269,10 +279,10 @@ export class Api extends HttpClient this.request({ path: `/something/`, diff --git a/tests/generated/v3.0/full-swagger-scheme.ts b/tests/generated/v3.0/full-swagger-scheme.ts index 11aa892a..a3edf418 100644 --- a/tests/generated/v3.0/full-swagger-scheme.ts +++ b/tests/generated/v3.0/full-swagger-scheme.ts @@ -8940,7 +8940,6 @@ export class Api extends HttpClient extends HttpClient + appsUpdateWebhookConfigForApp: ( + data: { + /** The URL to which the payloads will be delivered. */ + url?: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + }, + params: RequestParams = {}, + ) => this.request({ path: `/app/hook/config`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -8999,8 +9012,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/app/installations`, @@ -9070,7 +9083,21 @@ export class Api extends HttpClient + appsCreateInstallationAccessToken: ( + installationId: number, + data: { + /** List of repository names that the token should have access to */ + repositories?: string[]; + /** + * List of repository IDs that the token should have access to + * @example [1] + */ + repository_ids?: number[]; + /** The permissions granted to the user-to-server access token. */ + permissions?: AppPermissions; + }, + params: RequestParams = {}, + ) => this.request< InstallationToken, | BasicError @@ -9082,6 +9109,8 @@ export class Api extends HttpClient({ path: `/app/installations/${installationId}/access_tokens`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9153,8 +9182,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/applications/grants`, @@ -9216,10 +9245,19 @@ export class Api extends HttpClient + appsDeleteAuthorization: ( + clientId: string, + data: { + /** The OAuth access token used to authenticate to the GitHub API. */ + access_token?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/applications/${clientId}/grant`, method: "DELETE", + body: data, + type: ContentType.Json, ...params, }), @@ -9247,10 +9285,19 @@ export class Api extends HttpClient + appsCheckToken: ( + clientId: string, + data: { + /** The access_token of the OAuth application. */ + access_token: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/applications/${clientId}/token`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9263,10 +9310,19 @@ export class Api extends HttpClient + appsResetToken: ( + clientId: string, + data: { + /** The access_token of the OAuth application. */ + access_token: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/applications/${clientId}/token`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9279,10 +9335,19 @@ export class Api extends HttpClient + appsDeleteToken: ( + clientId: string, + data: { + /** The OAuth access token used to authenticate to the GitHub API. */ + access_token?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/applications/${clientId}/token`, method: "DELETE", + body: data, + type: ContentType.Json, ...params, }), @@ -9294,10 +9359,41 @@ export class Api extends HttpClient + appsScopeToken: ( + clientId: string, + data: { + /** + * **Required.** The OAuth access token used to authenticate to the GitHub API. + * @example "e72e16c7e42f292c6912e7710c838347ae178b4a" + */ + access_token?: string; + /** + * The name of the user or organization to scope the user-to-server access token to. **Required** unless `target_id` is specified. + * @example "octocat" + */ + target?: string; + /** + * The ID of the user or organization to scope the user-to-server access token to. **Required** unless `target` is specified. + * @example 1 + */ + target_id?: number; + /** The list of repository IDs to scope the user-to-server access token to. `repositories` may not be specified if `repository_ids` is specified. */ + repositories?: string[]; + /** + * The list of repository names to scope the user-to-server access token to. `repository_ids` may not be specified if `repositories` is specified. + * @example [1] + */ + repository_ids?: number[]; + /** The permissions granted to the user-to-server access token. */ + permissions?: AppPermissions; + }, + params: RequestParams = {}, + ) => this.request({ path: `/applications/${clientId}/token/scoped`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9387,8 +9483,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/authorizations`, @@ -9418,10 +9514,40 @@ export class Api extends HttpClient + oauthAuthorizationsCreateAuthorization: ( + data: { + /** + * A list of scopes that this authorization is in. + * @example ["public_repo","user"] + */ + scopes?: string[] | null; + /** + * A note to remind you what the OAuth token is for. + * @example "Update all gems" + */ + note?: string; + /** A URL to remind you what app the OAuth token is for. */ + note_url?: string; + /** + * The OAuth app client key for which to create the token. + * @maxLength 20 + */ + client_id?: string; + /** + * The OAuth app client secret for which to create the token. + * @maxLength 40 + */ + client_secret?: string; + /** A unique string to distinguish an authorization from others created for the same client ID and user. */ + fingerprint?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/authorizations`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9435,10 +9561,36 @@ export class Api extends HttpClient + oauthAuthorizationsGetOrCreateAuthorizationForApp: ( + clientId: string, + data: { + /** + * The OAuth app client secret for which to create the token. + * @maxLength 40 + */ + client_secret: string; + /** + * A list of scopes that this authorization is in. + * @example ["public_repo","user"] + */ + scopes?: string[] | null; + /** + * A note to remind you what the OAuth token is for. + * @example "Update all gems" + */ + note?: string; + /** A URL to remind you what app the OAuth token is for. */ + note_url?: string; + /** A unique string to distinguish an authorization from others created for the same client ID and user. */ + fingerprint?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/authorizations/clients/${clientId}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9455,11 +9607,32 @@ export class Api extends HttpClient this.request({ path: `/authorizations/clients/${clientId}/${fingerprint}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9490,10 +9663,35 @@ export class Api extends HttpClient + oauthAuthorizationsUpdateAuthorization: ( + authorizationId: number, + data: { + /** + * A list of scopes that this authorization is in. + * @example ["public_repo","user"] + */ + scopes?: string[] | null; + /** A list of scopes to add to this authorization. */ + add_scopes?: string[]; + /** A list of scopes to remove from this authorization. */ + remove_scopes?: string[]; + /** + * A note to remind you what the OAuth token is for. + * @example "Update all gems" + */ + note?: string; + /** A URL to remind you what app the OAuth token is for. */ + note_url?: string; + /** A unique string to distinguish an authorization from others created for the same client ID and user. */ + fingerprint?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/authorizations/${authorizationId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9569,7 +9767,24 @@ export class Api extends HttpClient + appsCreateContentAttachment: ( + contentReferenceId: number, + data: { + /** + * The title of the attachment + * @maxLength 1024 + * @example "Title of the attachment" + */ + title: string; + /** + * The body of the attachment + * @maxLength 262144 + * @example "Body of the attachment" + */ + body: string; + }, + params: RequestParams = {}, + ) => this.request< ContentReferenceAttachment, | BasicError @@ -9581,6 +9796,8 @@ export class Api extends HttpClient({ path: `/content_references/${contentReferenceId}/attachments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9627,10 +9844,21 @@ export class Api extends HttpClient + enterpriseAdminSetGithubActionsPermissionsEnterprise: ( + enterprise: string, + data: { + /** The policy that controls the organizations in the enterprise that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`. */ + enabled_organizations: EnabledOrganizations; + /** The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`. */ + allowed_actions?: AllowedActions; + }, + params: RequestParams = {}, + ) => this.request({ path: `/enterprises/${enterprise}/actions/permissions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -9644,8 +9872,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -9682,11 +9910,17 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/permissions/organizations`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -9752,10 +9986,16 @@ export class Api extends HttpClient + enterpriseAdminSetAllowedActionsEnterprise: ( + enterprise: string, + data: SelectedActions, + params: RequestParams = {}, + ) => this.request({ path: `/enterprises/${enterprise}/actions/permissions/selected-actions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -9769,8 +10009,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -9805,10 +10045,25 @@ export class Api extends HttpClient + enterpriseAdminCreateSelfHostedRunnerGroupForEnterprise: ( + enterprise: string, + data: { + /** Name of the runner group. */ + name: string; + /** Visibility of a runner group. You can select all organizations or select individual organization. Can be one of: `all` or `selected` */ + visibility?: "selected" | "all"; + /** List of organization IDs that can access the runner group. */ + selected_organization_ids?: number[]; + /** List of runner IDs to add to the runner group. */ + runners?: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/enterprises/${enterprise}/actions/runner-groups`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9844,11 +10099,22 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -9883,8 +10149,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -9922,11 +10188,17 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}/organizations`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -9981,8 +10253,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10020,11 +10292,17 @@ export class Api extends HttpClient this.request({ path: `/enterprises/${enterprise}/actions/runner-groups/${runnerGroupId}/runners`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -10078,8 +10356,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10203,8 +10481,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/enterprises/${enterprise}/audit-log`, @@ -10300,8 +10578,7 @@ export class Api extends HttpClient extends HttpClient this.request< Event[], @@ -10357,8 +10635,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists`, @@ -10389,10 +10667,34 @@ export class Api extends HttpClient + gistsCreate: ( + data: { + /** + * Description of the gist + * @example "Example Ruby script" + */ + description?: string; + /** + * Names and content for the files that make up the gist + * @example {"hello.rb":{"content":"puts \"Hello, World!\""}} + */ + files: Record< + string, + { + /** Content of the file */ + content: string; + } + >; + /** Flag indicating whether the gist is public */ + public?: boolean | "true" | "false"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/gists`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -10406,8 +10708,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/public`, @@ -10439,8 +10741,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/starred`, @@ -10499,10 +10801,35 @@ export class Api extends HttpClient + gistsUpdate: ( + gistId: string, + data: null & { + /** + * Description of the gist + * @example "Example Ruby script" + */ + description?: string; + /** + * Names of files to be updated + * @example {"hello.rb":{"content":"blah","filename":"goodbye.rb"}} + */ + files?: Record< + string, + (object | null) & { + /** The new content of the file */ + content?: string; + /** The new filename for the file */ + filename?: string | null; + } + >; + }, + params: RequestParams = {}, + ) => this.request({ path: `/gists/${gistId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -10532,8 +10859,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/comments`, @@ -10562,10 +10889,23 @@ export class Api extends HttpClient + gistsCreateComment: ( + gistId: string, + data: { + /** + * The comment text. + * @maxLength 65535 + * @example "Body of the attachment" + */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/gists/${gistId}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -10606,10 +10946,24 @@ export class Api extends HttpClient + gistsUpdateComment: ( + gistId: string, + commentId: number, + data: { + /** + * The comment text. + * @maxLength 65535 + * @example "Body of the attachment" + */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/gists/${gistId}/comments/${commentId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -10639,8 +10993,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/commits`, @@ -10671,8 +11025,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/gists/${gistId}/forks`, @@ -10813,8 +11167,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -10868,8 +11222,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/issues`, @@ -10933,8 +11287,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/licenses`, @@ -10976,10 +11330,26 @@ export class Api extends HttpClient + markdownRender: ( + data: { + /** The Markdown text to render in HTML. */ + text: string; + /** + * The rendering mode. + * @default "markdown" + * @example "markdown" + */ + mode?: "markdown" | "gfm"; + /** The repository context to use when creating references in `gfm` mode. */ + context?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/markdown`, method: "POST", + body: data, + type: ContentType.Json, ...params, }), @@ -10991,10 +11361,12 @@ export class Api extends HttpClient + markdownRenderRaw: (data: WebhookConfigUrl, params: RequestParams = {}) => this.request({ path: `/markdown/raw`, method: "POST", + body: data, + type: ContentType.Text, ...params, }), }; @@ -11024,8 +11396,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/plans`, @@ -11056,8 +11428,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/plans/${planId}/accounts`, @@ -11110,8 +11482,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/stubbed/plans`, @@ -11142,8 +11514,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/marketplace_listing/stubbed/plans/${planId}/accounts`, @@ -11200,8 +11572,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/networks/${owner}/${repo}/events`, @@ -11232,8 +11604,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/notifications`, @@ -11276,7 +11648,18 @@ export class Api extends HttpClient + activityMarkNotificationsAsRead: ( + data: { + /** + * Describes the last point that notifications were checked. + * @format date-time + */ + last_read_at?: string; + /** Whether the notification has been read. */ + read?: boolean; + }, + params: RequestParams = {}, + ) => this.request< { message?: string; @@ -11285,6 +11668,8 @@ export class Api extends HttpClient({ path: `/notifications`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -11344,10 +11729,22 @@ export class Api extends HttpClient + activitySetThreadSubscription: ( + threadId: number, + data: { + /** + * Whether to block all notifications from a thread. + * @default false + */ + ignored?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/notifications/threads/${threadId}/subscription`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -11377,11 +11774,11 @@ export class Api extends HttpClient this.request({ path: `/octocat`, @@ -11400,8 +11797,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/organizations`, @@ -11444,7 +11841,100 @@ export class Api extends HttpClient + orgsUpdate: ( + org: string, + data: { + /** Billing email address. This address is not publicized. */ + billing_email?: string; + /** The company name. */ + company?: string; + /** The publicly visible email address. */ + email?: string; + /** The Twitter username of the company. */ + twitter_username?: string; + /** The location. */ + location?: string; + /** The shorthand name of the company. */ + name?: string; + /** The description of the company. */ + description?: string; + /** Toggles whether an organization can use organization projects. */ + has_organization_projects?: boolean; + /** Toggles whether repositories that belong to the organization can use repository projects. */ + has_repository_projects?: boolean; + /** + * Default permission level members have for organization repositories: + * \* `read` - can pull, but not push to or administer this repository. + * \* `write` - can pull and push, but not administer this repository. + * \* `admin` - can pull, push, and administer this repository. + * \* `none` - no permissions granted by default. + * @default "read" + */ + default_repository_permission?: "read" | "write" | "admin" | "none"; + /** + * Toggles the ability of non-admin organization members to create repositories. Can be one of: + * \* `true` - all organization members can create repositories. + * \* `false` - only organization owners can create repositories. + * Default: `true` + * **Note:** A parameter can override this parameter. See `members_allowed_repository_creation_type` in this table for details. **Note:** A parameter can override this parameter. See `members_allowed_repository_creation_type` in this table for details. + * @default true + */ + members_can_create_repositories?: boolean; + /** + * Toggles whether organization members can create internal repositories, which are visible to all enterprise members. You can only allow members to create internal repositories if your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+. Can be one of: + * \* `true` - all organization members can create internal repositories. + * \* `false` - only organization owners can create internal repositories. + * Default: `true`. For more information, see "[Restricting repository creation in your organization](https://help.github.com/github/setting-up-and-managing-organizations-and-teams/restricting-repository-creation-in-your-organization)" in the GitHub Help documentation. + */ + members_can_create_internal_repositories?: boolean; + /** + * Toggles whether organization members can create private repositories, which are visible to organization members with permission. Can be one of: + * \* `true` - all organization members can create private repositories. + * \* `false` - only organization owners can create private repositories. + * Default: `true`. For more information, see "[Restricting repository creation in your organization](https://help.github.com/github/setting-up-and-managing-organizations-and-teams/restricting-repository-creation-in-your-organization)" in the GitHub Help documentation. + */ + members_can_create_private_repositories?: boolean; + /** + * Toggles whether organization members can create public repositories, which are visible to anyone. Can be one of: + * \* `true` - all organization members can create public repositories. + * \* `false` - only organization owners can create public repositories. + * Default: `true`. For more information, see "[Restricting repository creation in your organization](https://help.github.com/github/setting-up-and-managing-organizations-and-teams/restricting-repository-creation-in-your-organization)" in the GitHub Help documentation. + */ + members_can_create_public_repositories?: boolean; + /** + * Specifies which types of repositories non-admin organization members can create. Can be one of: + * \* `all` - all organization members can create public and private repositories. + * \* `private` - members can create private repositories. This option is only available to repositories that are part of an organization on GitHub Enterprise Cloud. + * \* `none` - only admin members can create repositories. + * **Note:** This parameter is deprecated and will be removed in the future. Its return value ignores internal repositories. Using this parameter overrides values set in `members_can_create_repositories`. See the parameter deprecation notice in the operation description for details. + */ + members_allowed_repository_creation_type?: "all" | "private" | "none"; + /** + * Toggles whether organization members can create GitHub Pages sites. Can be one of: + * \* `true` - all organization members can create GitHub Pages sites. + * \* `false` - no organization members can create GitHub Pages sites. Existing published sites will not be impacted. + * @default true + */ + members_can_create_pages?: boolean; + /** + * Toggles whether organization members can create public GitHub Pages sites. Can be one of: + * \* `true` - all organization members can create public GitHub Pages sites. + * \* `false` - no organization members can create public GitHub Pages sites. Existing published sites will not be impacted. + * @default true + */ + members_can_create_public_pages?: boolean; + /** + * Toggles whether organization members can create private GitHub Pages sites. Can be one of: + * \* `true` - all organization members can create private GitHub Pages sites. + * \* `false` - no organization members can create private GitHub Pages sites. Existing published sites will not be impacted. + * @default true + */ + members_can_create_private_pages?: boolean; + /** @example ""http://github.blog"" */ + blog?: string; + }, + params: RequestParams = {}, + ) => this.request< OrganizationFull, | BasicError @@ -11456,6 +11946,8 @@ export class Api extends HttpClient({ path: `/orgs/${org}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -11484,10 +11976,21 @@ export class Api extends HttpClient + actionsSetGithubActionsPermissionsOrganization: ( + org: string, + data: { + /** The policy that controls the repositories in the organization that are allowed to run GitHub Actions. Can be one of: `all`, `none`, or `selected`. */ + enabled_repositories: EnabledRepositories; + /** The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`. */ + allowed_actions?: AllowedActions; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/permissions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -11501,8 +12004,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -11537,10 +12040,19 @@ export class Api extends HttpClient + actionsSetSelectedRepositoriesEnabledGithubActionsOrganization: ( + org: string, + data: { + /** List of repository IDs to enable for GitHub Actions. */ + selected_repository_ids: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/permissions/repositories`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -11606,10 +12118,12 @@ export class Api extends HttpClient + actionsSetAllowedActionsOrganization: (org: string, data: SelectedActions, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/actions/permissions/selected-actions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -11623,8 +12137,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -11659,10 +12173,28 @@ export class Api extends HttpClient + actionsCreateSelfHostedRunnerGroupForOrg: ( + org: string, + data: { + /** Name of the runner group. */ + name: string; + /** + * Visibility of a runner group. You can select all repositories, select individual repositories, or limit access to private repositories. Can be one of: `all`, `selected`, or `private`. + * @default "all" + */ + visibility?: "selected" | "all" | "private"; + /** List of repository IDs that can access the runner group. */ + selected_repository_ids?: number[]; + /** List of runner IDs to add to the runner group. */ + runners?: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/runner-groups`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -11691,10 +12223,22 @@ export class Api extends HttpClient - this.request({ + actionsUpdateSelfHostedRunnerGroupForOrg: ( + org: string, + runnerGroupId: number, + data: { + /** Name of the runner group. */ + name?: string; + /** Visibility of a runner group. You can select all repositories, select individual repositories, or all private repositories. Can be one of: `all`, `selected`, or `private`. */ + visibility?: "selected" | "all" | "private"; + }, + params: RequestParams = {}, + ) => + this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -11751,11 +12295,17 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}/repositories`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -11810,8 +12360,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -11846,10 +12396,20 @@ export class Api extends HttpClient + actionsSetSelfHostedRunnersInGroupForOrg: ( + org: string, + runnerGroupId: number, + data: { + /** List of runner IDs to add to the runner group. */ + runners: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/runner-groups/${runnerGroupId}/runners`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -11903,8 +12463,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12020,8 +12580,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12088,10 +12648,31 @@ export class Api extends HttpClient + actionsCreateOrUpdateOrgSecret: ( + org: string, + secretName: string, + data: { + /** Value for your secret, encrypted with [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages) using the public key retrieved from the [Get an organization public key](https://docs.github.com/rest/reference/actions#get-an-organization-public-key) endpoint. */ + encrypted_value?: string; + /** ID of the key you used to encrypt the secret. */ + key_id?: string; + /** + * Configures the access that repositories have to the organization secret. Can be one of: + * \- `all` - All repositories in an organization can access the secret. + * \- `private` - Private repositories in an organization can access the secret. + * \- `selected` - Only specific repositories can access the secret. + */ + visibility?: "all" | "private" | "selected"; + /** An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can manage the list of selected repositories using the [List selected repositories for an organization secret](https://docs.github.com/rest/reference/actions#list-selected-repositories-for-an-organization-secret), [Set selected repositories for an organization secret](https://docs.github.com/rest/reference/actions#set-selected-repositories-for-an-organization-secret), and [Remove selected repository from an organization secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) endpoints. */ + selected_repository_ids?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/secrets/${secretName}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -12140,10 +12721,20 @@ export class Api extends HttpClient + actionsSetSelectedReposForOrgSecret: ( + org: string, + secretName: string, + data: { + /** An array of repository ids that can access the organization secret. You can only provide a list of repository ids when the `visibility` is set to `selected`. You can add and remove individual repositories using the [Set selected repositories for an organization secret](https://docs.github.com/rest/reference/actions#set-selected-repositories-for-an-organization-secret) and [Remove selected repository from an organization secret](https://docs.github.com/rest/reference/actions#remove-selected-repository-from-an-organization-secret) endpoints. */ + selected_repository_ids?: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/actions/secrets/${secretName}/repositories`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -12197,8 +12788,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/audit-log`, @@ -12344,8 +12935,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/events`, @@ -12376,8 +12967,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/failed_invitations`, @@ -12408,8 +12999,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/hooks`, @@ -12438,10 +13029,44 @@ export class Api extends HttpClient + orgsCreateWebhook: ( + org: string, + data: { + /** Must be passed as "web". */ + name: string; + /** Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/rest/reference/orgs#create-hook-config-params). */ + config: { + /** The URL to which the payloads will be delivered. */ + url: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + /** @example ""kdaigle"" */ + username?: string; + /** @example ""password"" */ + password?: string; + }; + /** + * Determines what [events](https://docs.github.com/webhooks/event-payloads) the hook is triggered for. + * @default ["push"] + */ + events?: string[]; + /** + * Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications. + * @default true + */ + active?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/hooks`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12470,10 +13095,41 @@ export class Api extends HttpClient + orgsUpdateWebhook: ( + org: string, + hookId: number, + data: { + /** Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/rest/reference/orgs#update-hook-config-params). */ + config?: { + /** The URL to which the payloads will be delivered. */ + url: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + }; + /** + * Determines what [events](https://docs.github.com/webhooks/event-payloads) the hook is triggered for. + * @default ["push"] + */ + events?: string[]; + /** + * Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications. + * @default true + */ + active?: boolean; + /** @example ""web"" */ + name?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/hooks/${hookId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12517,10 +13173,26 @@ export class Api extends HttpClient + orgsUpdateWebhookConfigForOrg: ( + org: string, + hookId: number, + data: { + /** The URL to which the payloads will be delivered. */ + url?: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/hooks/${hookId}/config`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12566,8 +13238,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -12618,10 +13290,12 @@ export class Api extends HttpClient + interactionsSetRestrictionsForOrg: (org: string, data: InteractionLimit, params: RequestParams = {}) => this.request({ path: `/orgs/${org}/interaction-limits`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12651,8 +13325,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/invitations`, @@ -12681,10 +13355,31 @@ export class Api extends HttpClient + orgsCreateInvitation: ( + org: string, + data: { + /** **Required unless you provide `email`**. GitHub user ID for the person you are inviting. */ + invitee_id?: number; + /** **Required unless you provide `invitee_id`**. Email address of the person you are inviting, which can be an existing GitHub user. */ + email?: string; + /** + * Specify role for new member. Can be one of: + * \* `admin` - Organization owners with full administrative rights to the organization and complete access to all repositories and teams. + * \* `direct_member` - Non-owner organization members with ability to see other members and join teams by invitation. + * \* `billing_manager` - Non-owner organization members with ability to manage the billing settings of your organization. + * @default "direct_member" + */ + role?: "admin" | "direct_member" | "billing_manager"; + /** Specify IDs for the teams you want to invite new members to. */ + team_ids?: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/invitations`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12715,8 +13410,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/invitations/${invitationId}/teams`, @@ -12747,8 +13442,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/issues`, @@ -12808,8 +13503,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/members`, @@ -12899,10 +13594,25 @@ export class Api extends HttpClient + orgsSetMembershipForUser: ( + org: string, + username: string, + data: { + /** + * The role to give the user in the organization. Can be one of: + * \* `admin` - The user will become an owner of the organization. + * \* `member` - The user will become a non-owner member of the organization. + * @default "member" + */ + role?: "admin" | "member"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/memberships/${username}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -12932,8 +13642,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/migrations`, @@ -12962,10 +13672,30 @@ export class Api extends HttpClient + migrationsStartForOrg: ( + org: string, + data: { + /** A list of arrays indicating which repositories should be migrated. */ + repositories: string[]; + /** + * Indicates whether repositories should be locked (to prevent manipulation) while migrating data. + * @default false + */ + lock_repositories?: boolean; + /** + * Indicates whether attachments should be excluded from the migration (to reduce migration archive file size). + * @default false + */ + exclude_attachments?: boolean; + exclude?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/migrations`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13042,8 +13772,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/migrations/${migrationId}/repositories`, @@ -13074,8 +13804,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/outside_collaborators`, @@ -13156,8 +13886,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/projects`, @@ -13191,10 +13921,21 @@ export class Api extends HttpClient + projectsCreateForOrg: ( + org: string, + data: { + /** The name of the project. */ + name: string; + /** The description of the project. */ + body?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/projects`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13209,8 +13950,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/public_members`, @@ -13286,8 +14027,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/repos`, @@ -13325,10 +14066,84 @@ export class Api extends HttpClient + reposCreateInOrg: ( + org: string, + data: { + /** The name of the repository. */ + name: string; + /** A short description of the repository. */ + description?: string; + /** A URL with more information about the repository. */ + homepage?: string; + /** + * Either `true` to create a private repository or `false` to create a public one. + * @default false + */ + private?: boolean; + /** + * Can be `public` or `private`. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, `visibility` can also be `internal`. For more information, see "[Creating an internal repository](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-repository-visibility#about-internal-repositories)" in the GitHub Help documentation. + * The `visibility` parameter overrides the `private` parameter when you use both parameters with the `nebula-preview` preview header. + */ + visibility?: "public" | "private" | "visibility" | "internal"; + /** + * Either `true` to enable issues for this repository or `false` to disable them. + * @default true + */ + has_issues?: boolean; + /** + * Either `true` to enable projects for this repository or `false` to disable them. **Note:** If you're creating a repository in an organization that has disabled repository projects, the default is `false`, and if you pass `true`, the API returns an error. + * @default true + */ + has_projects?: boolean; + /** + * Either `true` to enable the wiki for this repository or `false` to disable it. + * @default true + */ + has_wiki?: boolean; + /** + * Either `true` to make this repo available as a template repository or `false` to prevent it. + * @default false + */ + is_template?: boolean; + /** The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization. */ + team_id?: number; + /** + * Pass `true` to create an initial commit with empty README. + * @default false + */ + auto_init?: boolean; + /** Desired language or platform [.gitignore template](https://github.com/github/gitignore) to apply. Use the name of the template without the extension. For example, "Haskell". */ + gitignore_template?: string; + /** Choose an [open source license template](https://choosealicense.com/) that best suits your needs, and then use the [license keyword](https://help.github.com/articles/licensing-a-repository/#searching-github-by-license-type) as the `license_template` string. For example, "mit" or "mpl-2.0". */ + license_template?: string; + /** + * Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. + * @default true + */ + allow_squash_merge?: boolean; + /** + * Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. + * @default true + */ + allow_merge_commit?: boolean; + /** + * Either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. + * @default true + */ + allow_rebase_merge?: boolean; + /** + * Either `true` to allow automatically deleting head branches when pull requests are merged, or `false` to prevent automatic deletion. + * @default false + */ + delete_branch_on_merge?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/repos`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13391,8 +14206,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/team-sync/groups`, @@ -13423,8 +14238,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams`, @@ -13453,10 +14268,46 @@ export class Api extends HttpClient + teamsCreate: ( + org: string, + data: { + /** The name of the team. */ + name: string; + /** The description of the team. */ + description?: string; + /** List GitHub IDs for organization members who will become team maintainers. */ + maintainers?: string[]; + /** The full name (e.g., "organization-name/repository-name") of repositories to add the team to. */ + repo_names?: string[]; + /** + * The level of privacy this team should have. The options are: + * **For a non-nested team:** + * \* `secret` - only visible to organization owners and members of this team. + * \* `closed` - visible to all members of this organization. + * Default: `secret` + * **For a parent or child team:** + * \* `closed` - visible to all members of this organization. + * Default for child team: `closed` + */ + privacy?: "secret" | "closed"; + /** + * **Deprecated**. The permission that new repositories will be added to the team with when none is specified. Can be one of: + * \* `pull` - team members can pull, but not push to or administer newly-added repositories. + * \* `push` - team members can pull and push, but not administer newly-added repositories. + * \* `admin` - team members can pull, push and administer newly-added repositories. + * @default "pull" + */ + permission?: "pull" | "push" | "admin"; + /** The ID of a team to set as the parent team. */ + parent_team_id?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/teams`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13485,10 +14336,41 @@ export class Api extends HttpClient + teamsUpdateInOrg: ( + org: string, + teamSlug: string, + data: { + /** The name of the team. */ + name: string; + /** The description of the team. */ + description?: string; + /** + * The level of privacy this team should have. Editing teams without specifying this parameter leaves `privacy` intact. When a team is nested, the `privacy` for parent teams cannot be `secret`. The options are: + * **For a non-nested team:** + * \* `secret` - only visible to organization owners and members of this team. + * \* `closed` - visible to all members of this organization. + * **For a parent or child team:** + * \* `closed` - visible to all members of this organization. + */ + privacy?: "secret" | "closed"; + /** + * **Deprecated**. The permission that new repositories will be added to the team with when none is specified. Can be one of: + * \* `pull` - team members can pull, but not push to or administer newly-added repositories. + * \* `push` - team members can pull and push, but not administer newly-added repositories. + * \* `admin` - team members can pull, push and administer newly-added repositories. + * @default "pull" + */ + permission?: "pull" | "push" | "admin"; + /** The ID of a team to set as the parent team. */ + parent_team_id?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/teams/${teamSlug}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13519,8 +14401,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions`, @@ -13554,10 +14436,27 @@ export class Api extends HttpClient + teamsCreateDiscussionInOrg: ( + org: string, + teamSlug: string, + data: { + /** The discussion post's title. */ + title: string; + /** The discussion post's body text. */ + body: string; + /** + * Private posts are only visible to team members, organization owners, and team maintainers. Public posts are visible to all members of the organization. Set to `true` to create a private post. + * @default false + */ + private?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13586,10 +14485,23 @@ export class Api extends HttpClient + teamsUpdateDiscussionInOrg: ( + org: string, + teamSlug: string, + discussionNumber: number, + data: { + /** The discussion post's title. */ + title?: string; + /** The discussion post's body text. */ + body?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13621,8 +14533,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments`, @@ -13660,11 +14572,17 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13704,11 +14622,17 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13747,8 +14671,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, @@ -13784,11 +14708,17 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13827,8 +14757,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/reactions`, @@ -13863,11 +14793,17 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/discussions/${discussionNumber}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -13904,8 +14840,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/invitations`, @@ -13937,8 +14873,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/members`, @@ -13995,6 +14931,15 @@ export class Api extends HttpClient this.request< @@ -14010,6 +14955,8 @@ export class Api extends HttpClient({ path: `/orgs/${org}/teams/${teamSlug}/memberships/${username}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14040,8 +14987,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/projects`, @@ -14095,6 +15042,16 @@ export class Api extends HttpClient this.request< @@ -14106,6 +15063,8 @@ export class Api extends HttpClient({ path: `/orgs/${org}/teams/${teamSlug}/projects/${projectId}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -14135,8 +15094,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/repos`, @@ -14192,11 +15151,26 @@ export class Api extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/repos/${owner}/${repo}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -14239,10 +15213,27 @@ export class Api extends HttpClient + teamsCreateOrUpdateIdpGroupConnectionsInOrg: ( + org: string, + teamSlug: string, + data: { + /** The IdP groups you want to connect to a GitHub team. When updating, the new `groups` object will replace the original one. You must include any existing groups that you don't want to remove. */ + groups: { + /** ID of the IdP group. */ + group_id: string; + /** Name of the IdP group. */ + group_name: string; + /** Description of the IdP group. */ + group_description: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/orgs/${org}/teams/${teamSlug}/team-sync/group-mappings`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14258,8 +15249,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/orgs/${org}/teams/${teamSlug}/teams`, @@ -14305,10 +15296,27 @@ export class Api extends HttpClient + projectsUpdateCard: ( + cardId: number, + data: { + /** + * The project card's note + * @example "Update all gems" + */ + note?: string | null; + /** + * Whether or not the card is archived + * @example false + */ + archived?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/projects/columns/cards/${cardId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14344,7 +15352,23 @@ export class Api extends HttpClient + projectsMoveCard: ( + cardId: number, + data: { + /** + * The position of the card in a column + * @pattern ^(?:top|bottom|after:\d+)$ + * @example "bottom" + */ + position: string; + /** + * The unique identifier of the column the card should be moved to + * @example 42 + */ + column_id?: number; + }, + params: RequestParams = {}, + ) => this.request< object, | BasicError @@ -14371,6 +15395,8 @@ export class Api extends HttpClient({ path: `/projects/columns/cards/${cardId}/moves`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14399,10 +15425,22 @@ export class Api extends HttpClient + projectsUpdateColumn: ( + columnId: number, + data: { + /** + * Name of the project column + * @example "Remaining tasks" + */ + name: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/projects/columns/${columnId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14432,8 +15470,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/projects/columns/${columnId}/cards`, @@ -14467,7 +15505,30 @@ export class Api extends HttpClient + projectsCreateCard: ( + columnId: number, + data: + | { + /** + * The project card's note + * @example "Update all gems" + */ + note: string | null; + } + | { + /** + * The unique identifier of the content associated with the card + * @example 42 + */ + content_id: number; + /** + * The piece of content associated with the card + * @example "PullRequest" + */ + content_type: string; + }, + params: RequestParams = {}, + ) => this.request< ProjectCard, | BasicError @@ -14484,6 +15545,8 @@ export class Api extends HttpClient({ path: `/projects/columns/${columnId}/cards`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14496,10 +15559,23 @@ export class Api extends HttpClient + projectsMoveColumn: ( + columnId: number, + data: { + /** + * The position of the column in a project + * @pattern ^(?:first|last|after:\d+)$ + * @example "last" + */ + position: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/projects/columns/${columnId}/moves`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14528,7 +15604,31 @@ export class Api extends HttpClient + projectsUpdate: ( + projectId: number, + data: { + /** + * Name of the project + * @example "Week One Sprint" + */ + name?: string; + /** + * Body of the project + * @example "This project represents the sprint of the first week in January" + */ + body?: string | null; + /** + * State of the project; either 'open' or 'closed' + * @example "open" + */ + state?: string; + /** The baseline permission that all organization members have on this project */ + organization_permission?: "read" | "write" | "admin" | "none"; + /** Whether or not this project can be seen by everyone. */ + private?: boolean; + }, + params: RequestParams = {}, + ) => this.request< Project, | BasicError @@ -14542,6 +15642,8 @@ export class Api extends HttpClient({ path: `/projects/${projectId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14579,8 +15681,7 @@ export class Api extends HttpClient extends HttpClient this.request< SimpleUser[], @@ -14625,7 +15727,19 @@ export class Api extends HttpClient + projectsAddCollaborator: ( + projectId: number, + username: string, + data: { + /** + * The permission to grant the collaborator. + * @default "write" + * @example "write" + */ + permission?: "read" | "write" | "admin"; + }, + params: RequestParams = {}, + ) => this.request< void, | BasicError @@ -14637,6 +15751,8 @@ export class Api extends HttpClient({ path: `/projects/${projectId}/collaborators/${username}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -14697,8 +15813,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/projects/${projectId}/columns`, @@ -14727,10 +15843,22 @@ export class Api extends HttpClient + projectsCreateColumn: ( + projectId: number, + data: { + /** + * Name of the project column + * @example "Remaining tasks" + */ + name: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/projects/${projectId}/columns`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14801,10 +15929,79 @@ export class Api extends HttpClient + reposUpdate: ( + owner: string, + repo: string, + data: { + /** The name of the repository. */ + name?: string; + /** A short description of the repository. */ + description?: string; + /** A URL with more information about the repository. */ + homepage?: string; + /** + * Either `true` to make the repository private or `false` to make it public. Default: `false`. + * **Note**: You will get a `422` error if the organization restricts [changing repository visibility](https://help.github.com/articles/repository-permission-levels-for-an-organization#changing-the-visibility-of-repositories) to organization owners and a non-owner tries to change the value of private. **Note**: You will get a `422` error if the organization restricts [changing repository visibility](https://help.github.com/articles/repository-permission-levels-for-an-organization#changing-the-visibility-of-repositories) to organization owners and a non-owner tries to change the value of private. + * @default false + */ + private?: boolean; + /** Can be `public` or `private`. If your organization is associated with an enterprise account using GitHub Enterprise Cloud or GitHub Enterprise Server 2.20+, `visibility` can also be `internal`. The `visibility` parameter overrides the `private` parameter when you use both along with the `nebula-preview` preview header. */ + visibility?: "public" | "private" | "visibility" | "internal"; + /** + * Either `true` to enable issues for this repository or `false` to disable them. + * @default true + */ + has_issues?: boolean; + /** + * Either `true` to enable projects for this repository or `false` to disable them. **Note:** If you're creating a repository in an organization that has disabled repository projects, the default is `false`, and if you pass `true`, the API returns an error. + * @default true + */ + has_projects?: boolean; + /** + * Either `true` to enable the wiki for this repository or `false` to disable it. + * @default true + */ + has_wiki?: boolean; + /** + * Either `true` to make this repo available as a template repository or `false` to prevent it. + * @default false + */ + is_template?: boolean; + /** Updates the default branch for this repository. */ + default_branch?: string; + /** + * Either `true` to allow squash-merging pull requests, or `false` to prevent squash-merging. + * @default true + */ + allow_squash_merge?: boolean; + /** + * Either `true` to allow merging pull requests with a merge commit, or `false` to prevent merging pull requests with merge commits. + * @default true + */ + allow_merge_commit?: boolean; + /** + * Either `true` to allow rebase-merging pull requests, or `false` to prevent rebase-merging. + * @default true + */ + allow_rebase_merge?: boolean; + /** + * Either `true` to allow automatically deleting head branches when pull requests are merged, or `false` to prevent automatic deletion. + * @default false + */ + delete_branch_on_merge?: boolean; + /** + * `true` to archive this repository. **Note**: You cannot unarchive repositories through the API. + * @default false + */ + archived?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -14842,8 +16039,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -14977,10 +16174,22 @@ export class Api extends HttpClient + actionsSetGithubActionsPermissionsRepository: ( + owner: string, + repo: string, + data: { + /** Whether GitHub Actions is enabled on the repository. */ + enabled: ActionsEnabled; + /** The permissions policy that controls the actions that are allowed to run. Can be one of: `all`, `local_only`, or `selected`. */ + allowed_actions?: AllowedActions; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/actions/permissions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -15008,10 +16217,17 @@ export class Api extends HttpClient + actionsSetAllowedActionsRepository: ( + owner: string, + repo: string, + data: SelectedActions, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/actions/permissions/selected-actions`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -15026,8 +16242,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15149,8 +16365,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15228,8 +16444,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15283,8 +16499,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15390,8 +16606,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15458,10 +16674,23 @@ export class Api extends HttpClient + actionsCreateOrUpdateRepoSecret: ( + owner: string, + repo: string, + secretName: string, + data: { + /** Value for your secret, encrypted with [LibSodium](https://libsodium.gitbook.io/doc/bindings_for_other_languages) using the public key retrieved from the [Get a repository public key](https://docs.github.com/rest/reference/actions#get-a-repository-public-key) endpoint. */ + encrypted_value?: string; + /** ID of the key you used to encrypt the secret. */ + key_id?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/actions/secrets/${secretName}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -15491,8 +16720,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15562,11 +16791,19 @@ export class Api extends HttpClient; + }, params: RequestParams = {}, ) => this.request({ path: `/repos/${owner}/${repo}/actions/workflows/${workflowId}/dispatches`, method: "POST", + body: data, + type: ContentType.Json, ...params, }), @@ -15597,8 +16834,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -15660,8 +16897,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/assignees`, @@ -15738,8 +16975,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/branches`, @@ -15809,7 +17046,54 @@ export class Api extends HttpClient + reposUpdateBranchProtection: ( + owner: string, + repo: string, + branch: string, + data: { + /** Require status checks to pass before merging. Set to `null` to disable. */ + required_status_checks: { + /** Require branches to be up to date before merging. */ + strict: boolean; + /** The list of status checks to require in order to merge into this branch */ + contexts: string[]; + } | null; + /** Enforce all configured restrictions for administrators. Set to `true` to enforce required status checks for repository administrators. Set to `null` to disable. */ + enforce_admins: boolean | null; + /** Require at least one approving review on a pull request, before merging. Set to `null` to disable. */ + required_pull_request_reviews: { + /** Specify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories. */ + dismissal_restrictions?: { + /** The list of user `login`s with dismissal access */ + users?: string[]; + /** The list of team `slug`s with dismissal access */ + teams?: string[]; + }; + /** Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit. */ + dismiss_stale_reviews?: boolean; + /** Blocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) review them. */ + require_code_owner_reviews?: boolean; + /** Specify the number of reviewers required to approve pull requests. Use a number between 1 and 6. */ + required_approving_review_count?: number; + } | null; + /** Restrict who can push to the protected branch. User, app, and team `restrictions` are only available for organization-owned repositories. Set to `null` to disable. */ + restrictions: { + /** The list of user `login`s with push access */ + users: string[]; + /** The list of team `slug`s with push access */ + teams: string[]; + /** The list of app `slug`s with push access */ + apps?: string[]; + } | null; + /** Enforces a linear commit Git history, which prevents anyone from pushing merge commits to a branch. Set to `true` to enforce a linear commit history. Set to `false` to disable a linear commit Git history. Your repository must allow squash merging or rebase merging before you can enable a linear commit history. Default: `false`. For more information, see "[Requiring a linear commit history](https://help.github.com/github/administering-a-repository/requiring-a-linear-commit-history)" in the GitHub Help documentation. */ + required_linear_history?: boolean; + /** Permits force pushes to the protected branch by anyone with write access to the repository. Set to `true` to allow force pushes. Set to `false` or `null` to block force pushes. Default: `false`. For more information, see "[Enabling force pushes to a protected branch](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)" in the GitHub Help documentation." */ + allow_force_pushes?: boolean | null; + /** Allows deletion of the protected branch by anyone with write access to the repository. Set to `false` to prevent deletion of the protected branch. Default: `false`. For more information, see "[Enabling force pushes to a protected branch](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)" in the GitHub Help documentation. */ + allow_deletions?: boolean; + }, + params: RequestParams = {}, + ) => this.request< ProtectedBranch, | BasicError @@ -15821,6 +17105,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/branches/${branch}/protection`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -15911,10 +17197,32 @@ export class Api extends HttpClient + reposUpdatePullRequestReviewProtection: ( + owner: string, + repo: string, + branch: string, + data: { + /** Specify which users and teams can dismiss pull request reviews. Pass an empty `dismissal_restrictions` object to disable. User and team `dismissal_restrictions` are only available for organization-owned repositories. Omit this parameter for personal repositories. */ + dismissal_restrictions?: { + /** The list of user `login`s with dismissal access */ + users?: string[]; + /** The list of team `slug`s with dismissal access */ + teams?: string[]; + }; + /** Set to `true` if you want to automatically dismiss approving reviews when someone pushes a new commit. */ + dismiss_stale_reviews?: boolean; + /** Blocks merging pull requests until [code owners](https://help.github.com/articles/about-code-owners/) have reviewed. */ + require_code_owner_reviews?: boolean; + /** Specifies the number of reviewers required to approve pull requests. Use a number between 1 and 6. */ + required_approving_review_count?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_pull_request_reviews`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16005,10 +17313,23 @@ export class Api extends HttpClient + reposUpdateStatusCheckProtection: ( + owner: string, + repo: string, + branch: string, + data: { + /** Require branches to be up to date before merging. */ + strict?: boolean; + /** The list of status checks to require in order to merge into this branch */ + contexts?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16052,10 +17373,21 @@ export class Api extends HttpClient + reposAddStatusCheckContexts: ( + owner: string, + repo: string, + branch: string, + data: { + /** contexts parameter */ + contexts: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16068,10 +17400,21 @@ export class Api extends HttpClient + reposSetStatusCheckContexts: ( + owner: string, + repo: string, + branch: string, + data: { + /** contexts parameter */ + contexts: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16084,10 +17427,21 @@ export class Api extends HttpClient + reposRemoveStatusCheckContexts: ( + owner: string, + repo: string, + branch: string, + data: { + /** contexts parameter */ + contexts: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/required_status_checks/contexts`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16152,10 +17506,21 @@ export class Api extends HttpClient + reposAddAppAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** apps parameter */ + apps: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16168,10 +17533,21 @@ export class Api extends HttpClient + reposSetAppAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** apps parameter */ + apps: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16184,10 +17560,21 @@ export class Api extends HttpClient + reposRemoveAppAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** apps parameter */ + apps: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/apps`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16221,10 +17608,21 @@ export class Api extends HttpClient + reposAddTeamAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** teams parameter */ + teams: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16237,10 +17635,21 @@ export class Api extends HttpClient + reposSetTeamAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** teams parameter */ + teams: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16253,10 +17662,21 @@ export class Api extends HttpClient + reposRemoveTeamAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** teams parameter */ + teams: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/teams`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16290,10 +17710,21 @@ export class Api extends HttpClient + reposAddUserAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** users parameter */ + users: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16306,10 +17737,21 @@ export class Api extends HttpClient + reposSetUserAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** users parameter */ + users: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16322,10 +17764,21 @@ export class Api extends HttpClient + reposRemoveUserAccessRestrictions: ( + owner: string, + repo: string, + branch: string, + data: { + /** users parameter */ + users: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/protection/restrictions/users`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16338,10 +17791,21 @@ export class Api extends HttpClient + reposRenameBranch: ( + owner: string, + repo: string, + branch: string, + data: { + /** The new name of the branch. */ + new_name: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/branches/${branch}/rename`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16354,10 +17818,125 @@ export class Api extends HttpClient + checksCreate: ( + owner: string, + repo: string, + data: ( + | { + status?: "completed"; + [key: string]: any; + } + | { + status?: "queued" | "in_progress"; + [key: string]: any; + } + | ({ + status?: "completed"; + [key: string]: any; + } & { + status?: "queued" | "in_progress"; + [key: string]: any; + }) + ) & { + /** The name of the check. For example, "code-coverage". */ + name: string; + /** The SHA of the commit. */ + head_sha: string; + /** The URL of the integrator's site that has the full details of the check. If the integrator does not provide this, then the homepage of the GitHub app is used. */ + details_url?: string; + /** A reference for the run on the integrator's system. */ + external_id?: string; + /** + * The current status. Can be one of `queued`, `in_progress`, or `completed`. + * @default "queued" + */ + status?: "queued" | "in_progress" | "completed"; + /** The time that the check run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + started_at?: string; + /** + * **Required if you provide `completed_at` or a `status` of `completed`**. The final conclusion of the check. Can be one of `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required`. When the conclusion is `action_required`, additional details should be provided on the site specified by `details_url`. + * **Note:** Providing `conclusion` will automatically set the `status` parameter to `completed`. Only GitHub can change a check run conclusion to `stale`. + */ + conclusion?: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required"; + /** The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + completed_at?: string; + /** Check runs can accept a variety of data in the `output` object, including a `title` and `summary` and can optionally provide descriptive details about the run. See the [`output` object](https://docs.github.com/rest/reference/checks#output-object) description. */ + output?: { + /** The title of the check run. */ + title: string; + /** + * The summary of the check run. This parameter supports Markdown. + * @maxLength 65535 + */ + summary: string; + /** + * The details of the check run. This parameter supports Markdown. + * @maxLength 65535 + */ + text?: string; + /** + * Adds information from your analysis to specific lines of code. Annotations are visible on GitHub in the **Checks** and **Files changed** tab of the pull request. The Checks API limits the number of annotations to a maximum of 50 per API request. To create more than 50 annotations, you have to make multiple requests to the [Update a check run](https://docs.github.com/rest/reference/checks#update-a-check-run) endpoint. Each time you update the check run, annotations are appended to the list of annotations that already exist for the check run. For details about how you can view annotations on GitHub, see "[About status checks](https://help.github.com/articles/about-status-checks#checks)". See the [`annotations` object](https://docs.github.com/rest/reference/checks#annotations-object) description for details about how to use this parameter. + * @maxItems 50 + */ + annotations?: { + /** The path of the file to add an annotation to. For example, `assets/css/main.css`. */ + path: string; + /** The start line of the annotation. */ + start_line: number; + /** The end line of the annotation. */ + end_line: number; + /** The start column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. */ + start_column?: number; + /** The end column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. */ + end_column?: number; + /** The level of the annotation. Can be one of `notice`, `warning`, or `failure`. */ + annotation_level: "notice" | "warning" | "failure"; + /** A short description of the feedback for these lines of code. The maximum size is 64 KB. */ + message: string; + /** The title that represents the annotation. The maximum size is 255 characters. */ + title?: string; + /** Details about this annotation. The maximum size is 64 KB. */ + raw_details?: string; + }[]; + /** Adds images to the output displayed in the GitHub pull request UI. See the [`images` object](https://docs.github.com/rest/reference/checks#images-object) description for details. */ + images?: { + /** The alternative text for the image. */ + alt: string; + /** The full URL of the image. */ + image_url: string; + /** A short image description. */ + caption?: string; + }[]; + }; + /** + * Displays a button on GitHub that can be clicked to alert your app to do additional tasks. For example, a code linting app can display a button that automatically fixes detected errors. The button created in this object is displayed after the check run completes. When a user clicks the button, GitHub sends the [`check_run.requested_action` webhook](https://docs.github.com/webhooks/event-payloads/#check_run) to your app. Each action includes a `label`, `identifier` and `description`. A maximum of three actions are accepted. See the [`actions` object](https://docs.github.com/rest/reference/checks#actions-object) description. To learn more about check runs and requested actions, see "[Check runs and requested actions](https://docs.github.com/rest/reference/checks#check-runs-and-requested-actions)." To learn more about check runs and requested actions, see "[Check runs and requested actions](https://docs.github.com/rest/reference/checks#check-runs-and-requested-actions)." + * @maxItems 3 + */ + actions?: { + /** + * The text to be displayed on a button in the web UI. The maximum size is 20 characters. + * @maxLength 20 + */ + label: string; + /** + * A short explanation of what this action would do. The maximum size is 40 characters. + * @maxLength 40 + */ + description: string; + /** + * A reference for the action on the integrator's system. The maximum size is 20 characters. + * @maxLength 20 + */ + identifier: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/check-runs`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16386,10 +17965,121 @@ export class Api extends HttpClient + checksUpdate: ( + owner: string, + repo: string, + checkRunId: number, + data: ( + | { + status?: "completed"; + [key: string]: any; + } + | { + status?: "queued" | "in_progress"; + [key: string]: any; + } + | ({ + status?: "completed"; + [key: string]: any; + } & { + status?: "queued" | "in_progress"; + [key: string]: any; + }) + ) & { + /** The name of the check. For example, "code-coverage". */ + name?: string; + /** The URL of the integrator's site that has the full details of the check. */ + details_url?: string; + /** A reference for the run on the integrator's system. */ + external_id?: string; + /** This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + started_at?: string; + /** The current status. Can be one of `queued`, `in_progress`, or `completed`. */ + status?: "queued" | "in_progress" | "completed"; + /** + * **Required if you provide `completed_at` or a `status` of `completed`**. The final conclusion of the check. Can be one of `success`, `failure`, `neutral`, `cancelled`, `skipped`, `timed_out`, or `action_required`. + * **Note:** Providing `conclusion` will automatically set the `status` parameter to `completed`. Only GitHub can change a check run conclusion to `stale`. + */ + conclusion?: "success" | "failure" | "neutral" | "cancelled" | "skipped" | "timed_out" | "action_required"; + /** The time the check completed. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + completed_at?: string; + /** Check runs can accept a variety of data in the `output` object, including a `title` and `summary` and can optionally provide descriptive details about the run. See the [`output` object](https://docs.github.com/rest/reference/checks#output-object-1) description. */ + output?: { + /** **Required**. */ + title?: string; + /** + * Can contain Markdown. + * @maxLength 65535 + */ + summary: string; + /** + * Can contain Markdown. + * @maxLength 65535 + */ + text?: string; + /** + * Adds information from your analysis to specific lines of code. Annotations are visible in GitHub's pull request UI. Annotations are visible in GitHub's pull request UI. The Checks API limits the number of annotations to a maximum of 50 per API request. To create more than 50 annotations, you have to make multiple requests to the [Update a check run](https://docs.github.com/rest/reference/checks#update-a-check-run) endpoint. Each time you update the check run, annotations are appended to the list of annotations that already exist for the check run. For details about annotations in the UI, see "[About status checks](https://help.github.com/articles/about-status-checks#checks)". See the [`annotations` object](https://docs.github.com/rest/reference/checks#annotations-object-1) description for details. + * @maxItems 50 + */ + annotations?: { + /** The path of the file to add an annotation to. For example, `assets/css/main.css`. */ + path: string; + /** The start line of the annotation. */ + start_line: number; + /** The end line of the annotation. */ + end_line: number; + /** The start column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. */ + start_column?: number; + /** The end column of the annotation. Annotations only support `start_column` and `end_column` on the same line. Omit this parameter if `start_line` and `end_line` have different values. */ + end_column?: number; + /** The level of the annotation. Can be one of `notice`, `warning`, or `failure`. */ + annotation_level: "notice" | "warning" | "failure"; + /** A short description of the feedback for these lines of code. The maximum size is 64 KB. */ + message: string; + /** The title that represents the annotation. The maximum size is 255 characters. */ + title?: string; + /** Details about this annotation. The maximum size is 64 KB. */ + raw_details?: string; + }[]; + /** Adds images to the output displayed in the GitHub pull request UI. See the [`images` object](https://docs.github.com/rest/reference/checks#annotations-object-1) description for details. */ + images?: { + /** The alternative text for the image. */ + alt: string; + /** The full URL of the image. */ + image_url: string; + /** A short image description. */ + caption?: string; + }[]; + }; + /** + * Possible further actions the integrator can perform, which a user may trigger. Each action includes a `label`, `identifier` and `description`. A maximum of three actions are accepted. See the [`actions` object](https://docs.github.com/rest/reference/checks#actions-object) description. To learn more about check runs and requested actions, see "[Check runs and requested actions](https://docs.github.com/rest/reference/checks#check-runs-and-requested-actions)." + * @maxItems 3 + */ + actions?: { + /** + * The text to be displayed on a button in the web UI. The maximum size is 20 characters. + * @maxLength 20 + */ + label: string; + /** + * A short explanation of what this action would do. The maximum size is 40 characters. + * @maxLength 40 + */ + description: string; + /** + * A reference for the action on the integrator's system. The maximum size is 20 characters. + * @maxLength 20 + */ + identifier: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/check-runs/${checkRunId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16406,8 +18096,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/check-runs/${checkRunId}/annotations`, @@ -16436,10 +18126,20 @@ export class Api extends HttpClient + checksCreateSuite: ( + owner: string, + repo: string, + data: { + /** The sha of the head commit. */ + head_sha: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/check-suites`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16452,10 +18152,28 @@ export class Api extends HttpClient + checksSetSuitesPreferences: ( + owner: string, + repo: string, + data: { + /** Enables or disables automatic creation of CheckSuite events upon pushes to the repository. Enabled by default. See the [`auto_trigger_checks` object](https://docs.github.com/rest/reference/checks#auto_trigger_checks-object) description for details. */ + auto_trigger_checks?: { + /** The `id` of the GitHub App. */ + app_id: number; + /** + * Set to `true` to enable automatic creation of CheckSuite events upon pushes to the repository, or `false` to disable them. + * @default true + */ + setting: boolean; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/check-suites/preferences`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16488,8 +18206,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -16551,13 +18269,13 @@ export class Api extends HttpClient`. */ ref?: CodeScanningAlertRef; }, + params: RequestParams = {}, ) => this.request< CodeScanningAlertCodeScanningAlertItems[], @@ -16607,10 +18325,23 @@ export class Api extends HttpClient + codeScanningUpdateAlert: ( + owner: string, + repo: string, + alertNumber: AlertNumber, + data: { + /** Sets the state of the code scanning alert. Can be one of `open` or `dismissed`. You must provide `dismissed_reason` when you set the state to `dismissed`. */ + state: CodeScanningAlertSetState; + /** **Required when the state is dismissed.** The reason for dismissing or closing the alert. Can be one of: `false positive`, `won't fix`, and `used in tests`. */ + dismissed_reason?: CodeScanningAlertDismissedReason; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/alerts/${alertNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16626,13 +18357,13 @@ export class Api extends HttpClient`. */ ref?: CodeScanningAnalysisRef; /** Set a single code scanning tool name to filter alerts by tool. */ tool_name?: CodeScanningAnalysisToolName; }, + params: RequestParams = {}, ) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/analyses`, @@ -16650,10 +18381,38 @@ export class Api extends HttpClient + codeScanningUploadSarif: ( + owner: string, + repo: string, + data: { + /** The commit SHA of the code scanning analysis file. */ + commit_sha: CodeScanningAnalysisCommitSha; + /** The full Git reference of the code scanning analysis file, formatted as `refs/heads/`. */ + ref: CodeScanningAnalysisRef; + /** A Base64 string representing the SARIF file to upload. You must first compress your SARIF file using [`gzip`](http://www.gnu.org/software/gzip/manual/gzip.html) and then translate the contents of the file into a Base64 encoding string. */ + sarif: CodeScanningAnalysisSarifFile; + /** + * The base directory used in the analysis, as it appears in the SARIF file. + * This property is used to convert file paths from absolute to relative, so that alerts can be mapped to their correct location in the repository. + * @format uri + * @example "file:///github/workspace/" + */ + checkout_uri?: string; + /** + * The time that the analysis run began. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. + * @format date + */ + started_at?: string; + /** The name of the tool used to generate the code scanning analysis alert. */ + tool_name: CodeScanningAnalysisToolName; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/code-scanning/sarifs`, method: "POST", + body: data, + type: ContentType.Json, ...params, }), @@ -16668,8 +18427,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/collaborators`, @@ -16721,10 +18480,31 @@ export class Api extends HttpClient + reposAddCollaborator: ( + owner: string, + repo: string, + username: string, + data: { + /** + * The permission to grant the collaborator. **Only valid on organization-owned repositories.** Can be one of: + * \* `pull` - can pull, but not push to or administer this repository. + * \* `push` - can pull and push, but not administer this repository. + * \* `admin` - can pull, push and administer this repository. + * \* `maintain` - Recommended for project managers who need to manage the repository without access to sensitive or destructive actions. + * \* `triage` - Recommended for contributors who need to proactively manage issues and pull requests without write access. + * @default "push" + */ + permission?: "pull" | "push" | "admin" | "maintain" | "triage"; + /** @example ""push"" */ + permissions?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/collaborators/${username}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16771,8 +18551,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/comments`, @@ -16817,10 +18597,21 @@ export class Api extends HttpClient + reposUpdateCommitComment: ( + owner: string, + repo: string, + commentId: number, + data: { + /** The contents of the comment */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/comments/${commentId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16852,8 +18643,7 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -16891,7 +18682,16 @@ export class Api extends HttpClient + reactionsCreateForCommitComment: ( + owner: string, + repo: string, + commentId: number, + data: { + /** The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the commit comment. */ + content: "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes"; + }, + params: RequestParams = {}, + ) => this.request< Reaction, | { @@ -16902,6 +18702,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/comments/${commentId}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -16938,8 +18740,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits`, @@ -17005,8 +18807,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits/${commitSha}/comments`, @@ -17035,10 +18837,27 @@ export class Api extends HttpClient + reposCreateCommitComment: ( + owner: string, + repo: string, + commitSha: string, + data: { + /** The contents of the comment. */ + body: string; + /** Relative path of the file to comment on. */ + path?: string; + /** Line index in the diff to comment on. */ + position?: number; + /** **Deprecated**. Use **position** parameter instead. Line number in the file to comment on. */ + line?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/commits/${commitSha}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17055,8 +18874,7 @@ export class Api extends HttpClient extends HttpClient this.request< PullRequestSimple[], @@ -17111,8 +18930,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -17160,8 +18979,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -17223,8 +19042,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/commits/${ref}/statuses`, @@ -17305,11 +19124,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, @@ -17327,10 +19146,45 @@ export class Api extends HttpClient + reposCreateOrUpdateFileContents: ( + owner: string, + repo: string, + path: string, + data: { + /** The commit message. */ + message: string; + /** The new file content, using Base64 encoding. */ + content: string; + /** **Required if you are updating a file**. The blob SHA of the file being replaced. */ + sha?: string; + /** The branch name. Default: the repository’s default branch (usually `master`) */ + branch?: string; + /** The person that committed the file. Default: the authenticated user. */ + committer?: { + /** The name of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted. */ + name: string; + /** The email of the author or committer of the commit. You'll receive a `422` status code if `email` is omitted. */ + email: string; + /** @example ""2013-01-05T13:13:22+05:00"" */ + date?: string; + }; + /** The author of the file. Default: The `committer` or the authenticated user if you omit `committer`. */ + author?: { + /** The name of the author or committer of the commit. You'll receive a `422` status code if `name` is omitted. */ + name: string; + /** The email of the author or committer of the commit. You'll receive a `422` status code if `email` is omitted. */ + email: string; + /** @example ""2013-01-15T17:13:22+05:00"" */ + date?: string; + }; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17343,7 +19197,34 @@ export class Api extends HttpClient + reposDeleteFile: ( + owner: string, + repo: string, + path: string, + data: { + /** The commit message. */ + message: string; + /** The blob SHA of the file being replaced. */ + sha: string; + /** The branch name. Default: the repository’s default branch (usually `master`) */ + branch?: string; + /** object containing information about the committer. */ + committer?: { + /** The name of the author (or committer) of the commit */ + name?: string; + /** The email of the author (or committer) of the commit */ + email?: string; + }; + /** object containing information about the author. */ + author?: { + /** The name of the author (or committer) of the commit */ + name?: string; + /** The email of the author (or committer) of the commit */ + email?: string; + }; + }, + params: RequestParams = {}, + ) => this.request< FileCommit, | BasicError @@ -17356,6 +19237,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/contents/${path}`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17371,8 +19254,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/contributors`, @@ -17406,8 +19289,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/deployments`, @@ -17456,7 +19339,52 @@ export class Api extends HttpClient + reposCreateDeployment: ( + owner: string, + repo: string, + data: { + /** The ref to deploy. This can be a branch, tag, or SHA. */ + ref: string; + /** + * Specifies a task to execute (e.g., `deploy` or `deploy:migrations`). + * @default "deploy" + */ + task?: string; + /** + * Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch. + * @default true + */ + auto_merge?: boolean; + /** The [status](https://docs.github.com/rest/reference/repos#statuses) contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts. */ + required_contexts?: string[]; + /** JSON payload with extra information about the deployment. */ + payload?: Record | string; + /** + * Name for the target deployment environment (e.g., `production`, `staging`, `qa`). + * @default "production" + */ + environment?: string; + /** + * Short description of the deployment. + * @default "" + */ + description?: string | null; + /** + * Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: `false` + * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. + * @default false + */ + transient_environment?: boolean; + /** + * Specifies if the given environment is one that end-users directly interact with. Default: `true` when `environment` is `production` and `false` otherwise. + * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. + */ + production_environment?: boolean; + /** @example ""1776-07-04T00:00:00.000-07:52"" */ + created_at?: string; + }, + params: RequestParams = {}, + ) => this.request< Deployment, | { @@ -17468,6 +19396,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/deployments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17515,8 +19445,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/deployments/${deploymentId}/statuses`, @@ -17545,10 +19475,51 @@ export class Api extends HttpClient + reposCreateDeploymentStatus: ( + owner: string, + repo: string, + deploymentId: number, + data: { + /** The state of the status. Can be one of `error`, `failure`, `inactive`, `in_progress`, `queued` `pending`, or `success`. **Note:** To use the `inactive` state, you must provide the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. To use the `in_progress` and `queued` states, you must provide the [`application/vnd.github.flash-preview+json`](https://docs.github.com/rest/overview/api-previews#deployment-statuses) custom media type. When you set a transient deployment to `inactive`, the deployment will be shown as `destroyed` in GitHub. */ + state: "error" | "failure" | "inactive" | "in_progress" | "queued" | "pending" | "success"; + /** + * The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. **Note:** It's recommended to use the `log_url` parameter, which replaces `target_url`. + * @default "" + */ + target_url?: string; + /** + * The full URL of the deployment's output. This parameter replaces `target_url`. We will continue to accept `target_url` to support legacy uses, but we recommend replacing `target_url` with `log_url`. Setting `log_url` will automatically set `target_url` to the same value. Default: `""` + * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. + * @default "" + */ + log_url?: string; + /** + * A short description of the status. The maximum description length is 140 characters. + * @default "" + */ + description?: string; + /** Name for the target deployment environment, which can be changed when setting a deploy status. For example, `production`, `staging`, or `qa`. **Note:** This parameter requires you to use the [`application/vnd.github.flash-preview+json`](https://docs.github.com/rest/overview/api-previews#deployment-statuses) custom media type. */ + environment?: "production" | "staging" | "qa"; + /** + * Sets the URL for accessing your environment. Default: `""` + * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. + * @default "" + */ + environment_url?: string; + /** + * Adds a new `inactive` status to all prior non-transient, non-production environment deployments with the same repository and `environment` name as the created status's deployment. An `inactive` status is only added to deployments that had a `success` state. Default: `true` + * **Note:** To add an `inactive` status to `production` environments, you must use the [`application/vnd.github.flash-preview+json`](https://docs.github.com/rest/overview/api-previews#deployment-statuses) custom media type. + * **Note:** This parameter requires you to use the [`application/vnd.github.ant-man-preview+json`](https://docs.github.com/rest/overview/api-previews#enhanced-deployments) custom media type. + */ + auto_inactive?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/deployments/${deploymentId}/statuses`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17590,10 +19561,22 @@ export class Api extends HttpClient + reposCreateDispatchEvent: ( + owner: string, + repo: string, + data: { + /** A custom webhook event name. */ + event_type: string; + /** JSON payload with extra information about the webhook event that your action or worklow may use. */ + client_payload?: Record; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/dispatches`, method: "POST", + body: data, + type: ContentType.Json, ...params, }), @@ -17608,8 +19591,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/events`, @@ -17641,8 +19624,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/forks`, @@ -17676,10 +19659,20 @@ export class Api extends HttpClient + reposCreateFork: ( + owner: string, + repo: string, + data: { + /** Optional parameter to specify the organization name if forking into an organization. */ + organization?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/forks`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17692,10 +19685,25 @@ export class Api extends HttpClient + gitCreateBlob: ( + owner: string, + repo: string, + data: { + /** The new blob's content. */ + content: string; + /** + * The encoding used for `content`. Currently, `"utf-8"` and `"base64"` are supported. + * @default "utf-8" + */ + encoding?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/blobs`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17724,10 +19732,44 @@ export class Api extends HttpClient + gitCreateCommit: ( + owner: string, + repo: string, + data: { + /** The commit message */ + message: string; + /** The SHA of the tree object this commit points to */ + tree: string; + /** The SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided; for a merge commit, an array of more than one should be provided. */ + parents?: string[]; + /** Information about the author of the commit. By default, the `author` will be the authenticated user and the current date. See the `author` and `committer` object below for details. */ + author?: { + /** The name of the author (or committer) of the commit */ + name?: string; + /** The email of the author (or committer) of the commit */ + email?: string; + /** Indicates when this commit was authored (or committed). This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + date?: string; + }; + /** Information about the person who is making the commit. By default, `committer` will use the information set in `author`. See the `author` and `committer` object below for details. */ + committer?: { + /** The name of the author (or committer) of the commit */ + name?: string; + /** The email of the author (or committer) of the commit */ + email?: string; + /** Indicates when this commit was authored (or committed). This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + date?: string; + }; + /** The [PGP signature](https://en.wikipedia.org/wiki/Pretty_Good_Privacy) of the commit. GitHub adds the signature to the `gpgsig` header of the created commit. For a commit signature to be verifiable by Git or GitHub, it must be an ASCII-armored detached PGP signature over the string commit as it would be written to the object database. To pass a `signature` parameter, you need to first manually create a valid PGP signature, which can be complicated. You may find it easier to [use the command line](https://git-scm.com/book/id/v2/Git-Tools-Signing-Your-Work) to create signed commits. */ + signature?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/commits`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17760,8 +19802,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/matching-refs/${ref}`, @@ -17806,10 +19848,24 @@ export class Api extends HttpClient + gitCreateRef: ( + owner: string, + repo: string, + data: { + /** The name of the fully qualified reference (ie: `refs/heads/master`). If it doesn't start with 'refs' and have at least two slashes, it will be rejected. */ + ref: string; + /** The SHA1 value for this reference. */ + sha: string; + /** @example ""refs/heads/newbranch"" */ + key?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/refs`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17822,10 +19878,26 @@ export class Api extends HttpClient + gitUpdateRef: ( + owner: string, + repo: string, + ref: string, + data: { + /** The SHA1 value to set this reference to */ + sha: string; + /** + * Indicates whether to force the update or to make sure the update is a fast-forward update. Leaving this out or setting it to `false` will make sure you're not overwriting work. + * @default false + */ + force?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/refs/${ref}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17853,10 +19925,35 @@ export class Api extends HttpClient + gitCreateTag: ( + owner: string, + repo: string, + data: { + /** The tag's name. This is typically a version (e.g., "v0.0.1"). */ + tag: string; + /** The tag message. */ + message: string; + /** The SHA of the git object this is tagging. */ + object: string; + /** The type of the object we're tagging. Normally this is a `commit` but it can also be a `tree` or a `blob`. */ + type: "commit" | "tree" | "blob"; + /** An object with information about the individual creating the tag. */ + tagger?: { + /** The name of the author of the tag */ + name?: string; + /** The email of the author of the tag */ + email?: string; + /** When this object was tagged. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + date?: string; + }; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/tags`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17885,10 +19982,44 @@ export class Api extends HttpClient + gitCreateTree: ( + owner: string, + repo: string, + data: { + /** Objects (of `path`, `mode`, `type`, and `sha`) specifying a tree structure. */ + tree: { + /** The file referenced in the tree. */ + path?: string; + /** The file mode; one of `100644` for file (blob), `100755` for executable (blob), `040000` for subdirectory (tree), `160000` for submodule (commit), or `120000` for a blob that specifies the path of a symlink. */ + mode?: "100644" | "100755" | "040000" | "160000" | "120000"; + /** Either `blob`, `tree`, or `commit`. */ + type?: "blob" | "tree" | "commit"; + /** + * The SHA1 checksum ID of the object in the tree. Also called `tree.sha`. If the value is `null` then the file will be deleted. + * + * **Note:** Use either `tree.sha` or `content` to specify the contents of the entry. Using both `tree.sha` and `content` will return an error. + */ + sha?: string | null; + /** + * The content you want this file to have. GitHub will write this blob out and use that SHA for this entry. Use either this, or `tree.sha`. + * + * **Note:** Use either `tree.sha` or `content` to specify the contents of the entry. Using both `tree.sha` and `content` will return an error. + */ + content?: string; + }[]; + /** + * The SHA1 of an existing Git tree object which will be used as the base for the new tree. If provided, a new Git tree object will be created from entries in the Git tree object pointed to by `base_tree` and entries defined in the `tree` parameter. Entries defined in the `tree` parameter will overwrite items from `base_tree` with the same `path`. If you're creating new changes on a branch, then normally you'd set `base_tree` to the SHA1 of the Git tree object of the current latest commit on the branch you're working on. + * If not provided, GitHub will create a new Git tree object from only the entries defined in the `tree` parameter. If you create a new commit pointing to such a tree, then all files which were a part of the parent commit's tree and were not defined in the `tree` parameter will be listed as deleted by the new commit. + */ + base_tree?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/git/trees`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17905,11 +20036,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/git/trees/${treeSha}`, @@ -17930,8 +20061,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/hooks`, @@ -17960,10 +20091,45 @@ export class Api extends HttpClient + reposCreateWebhook: ( + owner: string, + repo: string, + data: { + /** Use `web` to create a webhook. Default: `web`. This parameter only accepts the value `web`. */ + name?: string; + /** Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/rest/reference/repos#create-hook-config-params). */ + config: { + /** The URL to which the payloads will be delivered. */ + url: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + /** @example ""abc"" */ + token?: string; + /** @example ""sha256"" */ + digest?: string; + }; + /** + * Determines what [events](https://docs.github.com/webhooks/event-payloads) the hook is triggered for. + * @default ["push"] + */ + events?: string[]; + /** + * Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications. + * @default true + */ + active?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/hooks`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -17992,10 +20158,48 @@ export class Api extends HttpClient + reposUpdateWebhook: ( + owner: string, + repo: string, + hookId: number, + data: { + /** Key/value pairs to provide settings for this webhook. [These are defined below](https://docs.github.com/rest/reference/repos#create-hook-config-params). */ + config?: { + /** The URL to which the payloads will be delivered. */ + url: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + /** @example ""bar@example.com"" */ + address?: string; + /** @example ""The Serious Room"" */ + room?: string; + }; + /** + * Determines what [events](https://docs.github.com/webhooks/event-payloads) the hook is triggered for. This replaces the entire array of events. + * @default ["push"] + */ + events?: string[]; + /** Determines a list of events to be added to the list of events that the Hook triggers for. */ + add_events?: string[]; + /** Determines a list of events to be removed from the list of events that the Hook triggers for. */ + remove_events?: string[]; + /** + * Determines if notifications are sent when the webhook is triggered. Set to `true` to send notifications. + * @default true + */ + active?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18039,10 +20243,27 @@ export class Api extends HttpClient + reposUpdateWebhookConfigForRepo: ( + owner: string, + repo: string, + hookId: number, + data: { + /** The URL to which the payloads will be delivered. */ + url?: WebhookConfigUrl; + /** The media type used to serialize the payloads. Supported values include `json` and `form`. The default is `form`. */ + content_type?: WebhookConfigContentType; + /** If provided, the `secret` will be used as the `key` to generate the HMAC hex digest value for [delivery signature headers](https://docs.github.com/webhooks/event-payloads/#delivery-headers). */ + secret?: WebhookConfigSecret; + /** Determines whether the SSL certificate of the host for `url` will be verified when delivering payloads. Supported values include `0` (verification is performed) and `1` (verification is not performed). The default is `0`. **We strongly recommend not setting this to `1` as you are subject to man-in-the-middle and other attacks.** */ + insecure_ssl?: WebhookConfigInsecureSsl; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/hooks/${hookId}/config`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18101,10 +20322,28 @@ export class Api extends HttpClient + migrationsStartImport: ( + owner: string, + repo: string, + data: { + /** The URL of the originating repository. */ + vcs_url: string; + /** The originating VCS type. Can be one of `subversion`, `git`, `mercurial`, or `tfvc`. Please be aware that without this parameter, the import job will take additional time to detect the VCS type before beginning the import. This detection step will be reflected in the response. */ + vcs?: "subversion" | "git" | "mercurial" | "tfvc"; + /** If authentication is required, the username to provide to `vcs_url`. */ + vcs_username?: string; + /** If authentication is required, the password to provide to `vcs_url`. */ + vcs_password?: string; + /** For a tfvc import, the name of the project that is being imported. */ + tfvc_project?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/import`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18117,10 +20356,26 @@ export class Api extends HttpClient + migrationsUpdateImport: ( + owner: string, + repo: string, + data: { + /** The username to provide to the originating repository. */ + vcs_username?: string; + /** The password to provide to the originating repository. */ + vcs_password?: string; + /** @example ""git"" */ + vcs?: string; + /** @example ""project1"" */ + tfvc_project?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/import`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18151,11 +20406,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/import/authors`, @@ -18173,10 +20428,25 @@ export class Api extends HttpClient + migrationsMapCommitAuthor: ( + owner: string, + repo: string, + authorId: number, + data: { + /** The new Git author email. */ + email?: string; + /** The new Git author name. */ + name?: string; + /** @example ""can't touch this"" */ + remote_id?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/import/authors/${authorId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18205,10 +20475,20 @@ export class Api extends HttpClient + migrationsSetLfsPreference: ( + owner: string, + repo: string, + data: { + /** Can be one of `opt_in` (large files will be stored using Git LFS) or `opt_out` (large files will be removed during the import). */ + use_lfs: "opt_in" | "opt_out"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/import/lfs`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18253,10 +20533,17 @@ export class Api extends HttpClient + interactionsSetRestrictionsForRepo: ( + owner: string, + repo: string, + data: InteractionLimit, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/interaction-limits`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18287,8 +20574,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/invitations`, @@ -18317,10 +20604,21 @@ export class Api extends HttpClient + reposUpdateInvitation: ( + owner: string, + repo: string, + invitationId: number, + data: { + /** The permissions that the associated user will have on the repository. Valid values are `read`, `write`, `maintain`, `triage`, and `admin`. */ + permissions?: "read" | "write" | "maintain" | "triage" | "admin"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/invitations/${invitationId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18351,8 +20649,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues`, @@ -18408,7 +20706,33 @@ export class Api extends HttpClient + issuesCreate: ( + owner: string, + repo: string, + data: { + /** The title of the issue. */ + title: string | number; + /** The contents of the issue. */ + body?: string; + /** Login for the user that this issue should be assigned to. _NOTE: Only users with push access can set the assignee for new issues. The assignee is silently dropped otherwise. **This field is deprecated.**_ */ + assignee?: string | null; + /** The `number` of the milestone to associate this issue with. _NOTE: Only users with push access can set the milestone for new issues. The milestone is silently dropped otherwise._ */ + milestone?: string | number | null; + /** Labels to associate with this issue. _NOTE: Only users with push access can set labels for new issues. Labels are silently dropped otherwise._ */ + labels?: ( + | string + | { + id?: number; + name?: string; + description?: string | null; + color?: string | null; + } + )[]; + /** Logins for Users to assign to this issue. _NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise._ */ + assignees?: string[]; + }, + params: RequestParams = {}, + ) => this.request< Issue, | BasicError @@ -18421,6 +20745,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18436,8 +20762,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/comments`, @@ -18491,10 +20817,21 @@ export class Api extends HttpClient + issuesUpdateComment: ( + owner: string, + repo: string, + commentId: number, + data: { + /** The contents of the comment. */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18526,8 +20863,7 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -18565,7 +20902,16 @@ export class Api extends HttpClient + reactionsCreateForIssueComment: ( + owner: string, + repo: string, + commentId: number, + data: { + /** The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the issue comment. */ + content: "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes"; + }, + params: RequestParams = {}, + ) => this.request< Reaction, | { @@ -18576,6 +20922,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/comments/${commentId}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18612,8 +20960,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/events`, @@ -18674,7 +21022,36 @@ export class Api extends HttpClient + issuesUpdate: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** The title of the issue. */ + title?: string | number; + /** The contents of the issue. */ + body?: string; + /** Login for the user that this issue should be assigned to. **This field is deprecated.** */ + assignee?: string | null; + /** State of the issue. Either `open` or `closed`. */ + state?: "open" | "closed"; + /** The `number` of the milestone to associate this issue with or `null` to remove current. _NOTE: Only users with push access can set the milestone for issues. The milestone is silently dropped otherwise._ */ + milestone?: string | number | null; + /** Labels to associate with this issue. Pass one or more Labels to _replace_ the set of Labels on this Issue. Send an empty array (`[]`) to clear all Labels from the Issue. _NOTE: Only users with push access can set labels for issues. Labels are silently dropped otherwise._ */ + labels?: ( + | string + | { + id?: number; + name?: string; + description?: string | null; + color?: string | null; + } + )[]; + /** Logins for Users to assign to this issue. Pass one or more user logins to _replace_ the set of assignees on this Issue. Send an empty array (`[]`) to clear all assignees from the Issue. _NOTE: Only users with push access can set assignees for new issues. Assignees are silently dropped otherwise._ */ + assignees?: string[]; + }, + params: RequestParams = {}, + ) => this.request< Issue, | BasicError @@ -18687,6 +21064,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/${issueNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18699,10 +21078,21 @@ export class Api extends HttpClient + issuesAddAssignees: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** Usernames of people to assign this issue to. _NOTE: Only users with push access can add assignees to an issue. Assignees are silently ignored otherwise._ */ + assignees?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18715,10 +21105,21 @@ export class Api extends HttpClient + issuesRemoveAssignees: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** Usernames of assignees to remove from an issue. _NOTE: Only users with push access can remove assignees from an issue. Assignees are silently ignored otherwise._ */ + assignees?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/assignees`, method: "DELETE", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18735,8 +21136,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/comments`, @@ -18767,10 +21168,21 @@ export class Api extends HttpClient + issuesCreateComment: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** The contents of the comment. */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18787,8 +21199,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/events`, @@ -18821,8 +21233,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, @@ -18851,10 +21263,21 @@ export class Api extends HttpClient + issuesAddLabels: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** The name of the label to add to the issue. Must contain at least one label. **Note:** Alternatively, you can pass a single label as a `string` or an `array` of labels directly, but GitHub recommends passing an object with the `labels` key. */ + labels: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18867,10 +21290,21 @@ export class Api extends HttpClient + issuesSetLabels: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** The names of the labels to add to the issue. You can pass an empty array to remove all labels. **Note:** Alternatively, you can pass a single label as a `string` or an `array` of labels directly, but GitHub recommends passing an object with the `labels` key. */ + labels?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/labels`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -18914,10 +21348,27 @@ export class Api extends HttpClient + issuesLock: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** + * The reason for locking the issue or pull request conversation. Lock will fail if you don't use one of these reasons: + * \* `off-topic` + * \* `too heated` + * \* `resolved` + * \* `spam` + */ + lock_reason?: "off-topic" | "too heated" | "resolved" | "spam"; + } | null, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/lock`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -18948,8 +21399,7 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -18987,7 +21438,16 @@ export class Api extends HttpClient + reactionsCreateForIssue: ( + owner: string, + repo: string, + issueNumber: number, + data: { + /** The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the issue. */ + content: "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes"; + }, + params: RequestParams = {}, + ) => this.request< Reaction, | { @@ -18998,6 +21458,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/issues/${issueNumber}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19035,8 +21497,7 @@ export class Api extends HttpClient extends HttpClient this.request< IssueEventForIssue[], @@ -19075,8 +21537,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/keys`, @@ -19105,10 +21567,28 @@ export class Api extends HttpClient + reposCreateDeployKey: ( + owner: string, + repo: string, + data: { + /** A name for the key. */ + title?: string; + /** The contents of the key. */ + key: string; + /** + * If `true`, the key will only be able to read repository contents. Otherwise, the key will be able to read and write. + * + * Deploy keys with write access can perform the same actions as an organization member with admin access, or a collaborator on a personal repository. For more information, see "[Repository permission levels for an organization](https://help.github.com/articles/repository-permission-levels-for-an-organization/)" and "[Permission levels for a user account repository](https://help.github.com/articles/permission-levels-for-a-user-account-repository/)." + */ + read_only?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/keys`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19155,8 +21635,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/labels`, @@ -19185,10 +21665,24 @@ export class Api extends HttpClient + issuesCreateLabel: ( + owner: string, + repo: string, + data: { + /** The name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing `:strawberry:` will render the emoji ![:strawberry:](https://github.githubassets.com/images/icons/emoji/unicode/1f353.png ":strawberry:"). For a full list of available emoji and codes, see [emoji-cheat-sheet.com](http://emoji-cheat-sheet.com/). */ + name: string; + /** The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`. */ + color?: string; + /** A short description of the label. */ + description?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/labels`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19217,10 +21711,25 @@ export class Api extends HttpClient + issuesUpdateLabel: ( + owner: string, + repo: string, + name: string, + data: { + /** The new name of the label. Emoji can be added to label names, using either native emoji or colon-style markup. For example, typing `:strawberry:` will render the emoji ![:strawberry:](https://github.githubassets.com/images/icons/emoji/unicode/1f353.png ":strawberry:"). For a full list of available emoji and codes, see [emoji-cheat-sheet.com](http://emoji-cheat-sheet.com/). */ + new_name?: string; + /** The [hexadecimal color code](http://www.color-hex.com/) for the label, without the leading `#`. */ + color?: string; + /** A short description of the label. */ + description?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/labels/${name}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19280,7 +21789,19 @@ export class Api extends HttpClient + reposMerge: ( + owner: string, + repo: string, + data: { + /** The name of the base branch that the head will be merged into. */ + base: string; + /** The head to merge. This can be a branch name or a commit SHA1. */ + head: string; + /** Commit message to use for the merge commit. If omitted, a default message will be used. */ + commit_message?: string; + }, + params: RequestParams = {}, + ) => this.request< Commit, | BasicError @@ -19293,6 +21814,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/merges`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19308,8 +21831,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones`, @@ -19353,10 +21876,29 @@ export class Api extends HttpClient + issuesCreateMilestone: ( + owner: string, + repo: string, + data: { + /** The title of the milestone. */ + title: string; + /** + * The state of the milestone. Either `open` or `closed`. + * @default "open" + */ + state?: "open" | "closed"; + /** A description of the milestone. */ + description?: string; + /** The milestone due date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + due_on?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/milestones`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19385,10 +21927,30 @@ export class Api extends HttpClient + issuesUpdateMilestone: ( + owner: string, + repo: string, + milestoneNumber: number, + data: { + /** The title of the milestone. */ + title?: string; + /** + * The state of the milestone. Either `open` or `closed`. + * @default "open" + */ + state?: "open" | "closed"; + /** A description of the milestone. */ + description?: string; + /** The milestone due date. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. */ + due_on?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/milestones/${milestoneNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19420,8 +21982,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/milestones/${milestoneNumber}/labels`, @@ -19453,8 +22015,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/notifications`, @@ -19497,10 +22059,20 @@ export class Api extends HttpClient + activityMarkRepoNotificationsAsRead: ( + owner: string, + repo: string, + data: { + /** Describes the last point that notifications were checked. Anything updated since this time will not be marked as read. If you omit this parameter, all notifications are marked as read. This is a timestamp in [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format: `YYYY-MM-DDTHH:MM:SSZ`. Default: The current timestamp. */ + last_read_at?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/notifications`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -19528,7 +22100,23 @@ export class Api extends HttpClient + reposCreatePagesSite: ( + owner: string, + repo: string, + data: { + /** The source branch and directory used to publish your Pages site. */ + source: { + /** The repository branch used to publish your site's source files. */ + branch: string; + /** + * The repository directory that includes the source files for the Pages site. Allowed paths are `/` or `/docs`. Default: `/` + * @default "/" + */ + path?: "/" | "/docs"; + }; + }, + params: RequestParams = {}, + ) => this.request< Page, | BasicError @@ -19540,6 +22128,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pages`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19552,10 +22142,43 @@ export class Api extends HttpClient + reposUpdateInformationAboutPagesSite: ( + owner: string, + repo: string, + data: { + /** Specify a custom domain for the repository. Sending a `null` value will remove the custom domain. For more about custom domains, see "[Using a custom domain with GitHub Pages](https://help.github.com/articles/using-a-custom-domain-with-github-pages/)." */ + cname?: string | null; + /** Configures access controls for the GitHub Pages site. If public is set to `true`, the site is accessible to anyone on the internet. If set to `false`, the site will only be accessible to users who have at least `read` access to the repository that published the site. This includes anyone in your Enterprise if the repository is set to `internal` visibility. This feature is only available to repositories in an organization on an Enterprise plan. */ + public?: boolean; + /** Update the source for the repository. Must include the branch name, and may optionally specify the subdirectory `/docs`. Possible values are `"gh-pages"`, `"master"`, and `"master /docs"`. */ + source: + | "gh-pages" + | "master" + | "master /docs" + | { + /** The repository branch used to publish your site's source files. */ + branch: string; + /** The repository directory that includes the source files for the Pages site. Allowed paths are `/` or `/docs`. */ + path: "/" | "/docs"; + } + | ( + | "gh-pages" + | "master" + | ("master /docs" & { + /** The repository branch used to publish your site's source files. */ + branch: string; + /** The repository directory that includes the source files for the Pages site. Allowed paths are `/` or `/docs`. */ + path: "/" | "/docs"; + }) + ); + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pages`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -19593,8 +22216,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pages/builds`, @@ -19674,8 +22297,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/projects`, @@ -19709,10 +22332,22 @@ export class Api extends HttpClient + projectsCreateForRepo: ( + owner: string, + repo: string, + data: { + /** The name of the project. */ + name: string; + /** The description of the project. */ + body?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/projects`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19728,8 +22363,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls`, @@ -19774,10 +22409,32 @@ export class Api extends HttpClient + pullsCreate: ( + owner: string, + repo: string, + data: { + /** The title of the new pull request. */ + title?: string; + /** The name of the branch where your changes are implemented. For cross-repository pull requests in the same network, namespace `head` with a user like this: `username:branch`. */ + head: string; + /** The name of the branch you want the changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repository that requests a merge to a base of another repository. */ + base: string; + /** The contents of the pull request. */ + body?: string; + /** Indicates whether [maintainers can modify](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request. */ + maintainer_can_modify?: boolean; + /** Indicates whether the pull request is a draft. See "[Draft Pull Requests](https://help.github.com/en/articles/about-pull-requests#draft-pull-requests)" in the GitHub Help documentation to learn more. */ + draft?: boolean; + /** @example 1 */ + issue?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19793,8 +22450,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/comments`, @@ -19848,10 +22505,21 @@ export class Api extends HttpClient + pullsUpdateReviewComment: ( + owner: string, + repo: string, + commentId: number, + data: { + /** The text of the reply to the review comment. */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19883,8 +22551,7 @@ export class Api extends HttpClient extends HttpClient this.request< Reaction[], @@ -19926,6 +22594,10 @@ export class Api extends HttpClient this.request< @@ -19938,6 +22610,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/comments/${commentId}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -19987,10 +22661,29 @@ export class Api extends HttpClient + pullsUpdate: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** The title of the pull request. */ + title?: string; + /** The contents of the pull request. */ + body?: string; + /** State of this Pull Request. Either `open` or `closed`. */ + state?: "open" | "closed"; + /** The name of the branch you want your changes pulled into. This should be an existing branch on the current repository. You cannot update the base branch on a pull request to point to another repository. */ + base?: string; + /** Indicates whether [maintainers can modify](https://help.github.com/articles/allowing-changes-to-a-pull-request-branch-created-from-a-fork/) the pull request. */ + maintainer_can_modify?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20007,8 +22700,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments`, @@ -20046,10 +22739,37 @@ export class Api extends HttpClient + pullsCreateReviewComment: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** The text of the review comment. */ + body: string; + /** The SHA of the commit needing a comment. Not using the latest commit SHA may render your comment outdated if a subsequent commit modifies the line you specify as the `position`. */ + commit_id?: string; + /** The relative path to the file that necessitates a comment. */ + path: string; + /** **Required without `comfort-fade` preview**. The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note above. */ + position?: number; + /** **Required with `comfort-fade` preview**. In a split diff view, the side of the diff that the pull request's changes appear on. Can be `LEFT` or `RIGHT`. Use `LEFT` for deletions that appear in red. Use `RIGHT` for additions that appear in green or unchanged lines that appear in white and are shown for context. For a multi-line comment, side represents whether the last line of the comment range is a deletion or addition. For more information, see "[Diff view options](https://help.github.com/en/articles/about-comparing-branches-in-pull-requests#diff-view-options)" in the GitHub Help documentation. */ + side?: "LEFT" | "RIGHT"; + /** **Required with `comfort-fade` preview**. The line of the blob in the pull request diff that the comment applies to. For a multi-line comment, the last line of the range that your comment applies to. */ + line?: number; + /** **Required when using multi-line comments**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_line` is the first line in the pull request diff that your multi-line comment applies to. To learn more about multi-line comments, see "[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)" in the GitHub Help documentation. */ + start_line?: number; + /** **Required when using multi-line comments**. To create multi-line comments, you must use the `comfort-fade` preview header. The `start_side` is the starting side of the diff that the comment applies to. Can be `LEFT` or `RIGHT`. To learn more about multi-line comments, see "[Commenting on a pull request](https://help.github.com/en/articles/commenting-on-a-pull-request#adding-line-comments-to-a-pull-request)" in the GitHub Help documentation. See `side` in this table for additional context. */ + start_side?: "LEFT" | "RIGHT" | "side"; + /** @example 2 */ + in_reply_to?: number; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20067,11 +22787,17 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/comments/${commentId}/replies`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20088,8 +22814,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/commits`, @@ -20122,8 +22848,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/files`, @@ -20167,7 +22893,22 @@ export class Api extends HttpClient + pullsMerge: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** Title for the automatic commit message. */ + commit_title?: string; + /** Extra detail to append to automatic commit message. */ + commit_message?: string; + /** SHA that pull request head must match to allow merge. */ + sha?: string; + /** Merge method to use. Possible values are `merge`, `squash` or `rebase`. Default is `merge`. */ + merge_method?: "merge" | "squash" | "rebase"; + } | null, + params: RequestParams = {}, + ) => this.request< PullRequestMergeResult, | BasicError @@ -20179,6 +22920,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/merge`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20195,8 +22938,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, @@ -20225,10 +22968,23 @@ export class Api extends HttpClient + pullsRequestReviewers: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** An array of user `login`s that will be requested. */ + reviewers?: string[]; + /** An array of team `slug`s that will be requested. */ + team_reviewers?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20241,10 +22997,23 @@ export class Api extends HttpClient + pullsRemoveRequestedReviewers: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** An array of user `login`s that will be removed. */ + reviewers?: string[]; + /** An array of team `slug`s that will be removed. */ + team_reviewers?: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/requested_reviewers`, method: "DELETE", + body: data, + type: ContentType.Json, ...params, }), @@ -20260,8 +23029,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews`, @@ -20290,10 +23059,42 @@ export class Api extends HttpClient + pullsCreateReview: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** The SHA of the commit that needs a review. Not using the latest commit SHA may render your review comment outdated if a subsequent commit modifies the line you specify as the `position`. Defaults to the most recent commit in the pull request when you do not specify a value. */ + commit_id?: string; + /** **Required** when using `REQUEST_CHANGES` or `COMMENT` for the `event` parameter. The body text of the pull request review. */ + body?: string; + /** The review action you want to perform. The review actions include: `APPROVE`, `REQUEST_CHANGES`, or `COMMENT`. By leaving this blank, you set the review action state to `PENDING`, which means you will need to [submit the pull request review](https://docs.github.com/rest/reference/pulls#submit-a-review-for-a-pull-request) when you are ready. */ + event?: "APPROVE" | "REQUEST_CHANGES" | "COMMENT"; + /** Use the following table to specify the location, destination, and contents of the draft review comment. */ + comments?: { + /** The relative path to the file that necessitates a review comment. */ + path: string; + /** The position in the diff where you want to add a review comment. Note this value is not the same as the line number in the file. For help finding the position value, read the note below. */ + position?: number; + /** Text of the review comment. */ + body: string; + /** @example 28 */ + line?: number; + /** @example "RIGHT" */ + side?: string; + /** @example 26 */ + start_line?: number; + /** @example "LEFT" */ + start_side?: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20327,11 +23128,17 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20371,8 +23178,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/comments`, @@ -20406,11 +23213,19 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/dismissals`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20428,11 +23243,19 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/reviews/${reviewId}/events`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20445,7 +23268,16 @@ export class Api extends HttpClient + pullsUpdateBranch: ( + owner: string, + repo: string, + pullNumber: number, + data: { + /** The expected SHA of the pull request's HEAD ref. This is the most recent commit on the pull request's branch. If the expected SHA does not match the pull request's HEAD, you will receive a `422 Unprocessable Entity` status. You can use the "[List commits](https://docs.github.com/rest/reference/repos#list-commits)" endpoint to find the most recent commit SHA. Default: SHA of the pull request's current HEAD ref. */ + expected_head_sha?: string; + } | null, + params: RequestParams = {}, + ) => this.request< { message?: string; @@ -20460,6 +23292,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/pulls/${pullNumber}/update-branch`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20475,11 +23309,11 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/readme`, @@ -20500,8 +23334,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases`, @@ -20530,10 +23364,36 @@ export class Api extends HttpClient + reposCreateRelease: ( + owner: string, + repo: string, + data: { + /** The name of the tag. */ + tag_name: string; + /** Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually `master`). */ + target_commitish?: string; + /** The name of the release. */ + name?: string; + /** Text describing the contents of the tag. */ + body?: string; + /** + * `true` to create a draft (unpublished) release, `false` to create a published one. + * @default false + */ + draft?: boolean; + /** + * `true` to identify the release as a prerelease. `false` to identify the release as a full release. + * @default false + */ + prerelease?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/releases`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20569,10 +23429,25 @@ export class Api extends HttpClient + reposUpdateReleaseAsset: ( + owner: string, + repo: string, + assetId: number, + data: { + /** The file name of the asset. */ + name?: string; + /** An alternate short description of the asset. Used in place of the filename. */ + label?: string; + /** @example ""uploaded"" */ + state?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/releases/assets/${assetId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20648,10 +23523,31 @@ export class Api extends HttpClient + reposUpdateRelease: ( + owner: string, + repo: string, + releaseId: number, + data: { + /** The name of the tag. */ + tag_name?: string; + /** Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually `master`). */ + target_commitish?: string; + /** The name of the release. */ + name?: string; + /** Text describing the contents of the tag. */ + body?: string; + /** `true` makes the release a draft, and `false` publishes the release. */ + draft?: boolean; + /** `true` to identify the release as a prerelease, `false` to identify the release as a full release. */ + prerelease?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20683,8 +23579,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}/assets`, @@ -20717,16 +23613,18 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/releases/${releaseId}/assets`, method: "POST", query: query, + body: data, format: "json", ...params, }), @@ -20742,8 +23640,7 @@ export class Api extends HttpClient extends HttpClient this.request< SecretScanningAlert[], @@ -20804,7 +23702,18 @@ export class Api extends HttpClient + secretScanningUpdateAlert: ( + owner: string, + repo: string, + alertNumber: AlertNumber, + data: { + /** Sets the state of the secret scanning alert. Can be either `open` or `resolved`. You must provide `resolution` when you set the state to `resolved`. */ + state: SecretScanningAlertState; + /** **Required when the `state` is `resolved`.** The reason for resolving the alert. Can be one of `false_positive`, `wont_fix`, `revoked`, or `used_in_tests`. */ + resolution?: SecretScanningAlertResolution; + }, + params: RequestParams = {}, + ) => this.request< SecretScanningAlert, void | { @@ -20815,6 +23724,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/secret-scanning/alerts/${alertNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20830,8 +23741,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/stargazers`, @@ -20940,10 +23851,34 @@ export class Api extends HttpClient + reposCreateCommitStatus: ( + owner: string, + repo: string, + sha: string, + data: { + /** The state of the status. Can be one of `error`, `failure`, `pending`, or `success`. */ + state: "error" | "failure" | "pending" | "success"; + /** + * The target URL to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the source of the status. + * For example, if your continuous integration system is posting build status, you would want to provide the deep link for the build output for this specific SHA: + * `http://ci.example.com/user/repo/build/sha` + */ + target_url?: string; + /** A short description of the status. */ + description?: string; + /** + * A string label to differentiate this status from the status of other systems. This field is case-insensitive. + * @default "default" + */ + context?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/statuses/${sha}`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -20959,8 +23894,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/subscribers`, @@ -21005,10 +23940,22 @@ export class Api extends HttpClient + activitySetRepoSubscription: ( + owner: string, + repo: string, + data: { + /** Determines if notifications should be received from this repository. */ + subscribed?: boolean; + /** Determines if all notifications should be blocked from this repository. */ + ignored?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/subscription`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21039,8 +23986,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/tags`, @@ -21087,8 +24034,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/repos/${owner}/${repo}/teams`, @@ -21140,7 +24087,15 @@ export class Api extends HttpClient + reposReplaceAllTopics: ( + owner: string, + repo: string, + data: { + /** An array of topics to add to the repository. Pass one or more topics to _replace_ the set of existing topics. Send an empty array (`[]`) to clear all topics from the repository. **Note:** Topic `names` cannot contain uppercase letters. */ + names: string[]; + }, + params: RequestParams = {}, + ) => this.request< Topic, | BasicError @@ -21152,6 +24107,8 @@ export class Api extends HttpClient({ path: `/repos/${owner}/${repo}/topics`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21167,14 +24124,14 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/traffic/clones`, @@ -21227,14 +24184,14 @@ export class Api extends HttpClient this.request({ path: `/repos/${owner}/${repo}/traffic/views`, @@ -21252,10 +24209,22 @@ export class Api extends HttpClient + reposTransfer: ( + owner: string, + repo: string, + data: { + /** The username or organization name the repository will be transferred to. */ + new_owner: string; + /** ID of the team or teams to add to the repository. Teams can only be added to organization-owned repositories. */ + team_ids?: number[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${owner}/${repo}/transfer`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21328,10 +24297,34 @@ export class Api extends HttpClient + reposCreateUsingTemplate: ( + templateOwner: string, + templateRepo: string, + data: { + /** The organization or person who will own the new repository. To create a new repository in an organization, the authenticated user must be a member of the specified organization. */ + owner?: string; + /** The name of the new repository. */ + name: string; + /** A short description of the new repository. */ + description?: string; + /** + * Set to `true` to include the directory structure and files from all branches in the template repository, and not just the default branch. Default: `false`. + * @default false + */ + include_all_branches?: boolean; + /** + * Either `true` to create a new private repository or `false` to create a new public one. + * @default false + */ + private?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/repos/${templateOwner}/${templateRepo}/generate`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21346,11 +24339,11 @@ export class Api extends HttpClient this.request({ path: `/repositories`, @@ -21371,13 +24364,13 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups`, @@ -21395,10 +24388,25 @@ export class Api extends HttpClient + enterpriseAdminProvisionAndInviteEnterpriseGroup: ( + enterprise: string, + data: { + /** The SCIM schema URIs. */ + schemas: string[]; + /** The name of the SCIM group. This must match the GitHub organization that the group maps to. */ + displayName: string; + members?: { + /** The SCIM user ID for a user. */ + value: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21434,11 +24442,23 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups/${scimGroupId}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21454,11 +24474,19 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Groups/${scimGroupId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21492,13 +24520,13 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users`, @@ -21516,10 +24544,40 @@ export class Api extends HttpClient + enterpriseAdminProvisionAndInviteEnterpriseUser: ( + enterprise: string, + data: { + /** The SCIM schema URIs. */ + schemas: string[]; + /** The username for the user. */ + userName: string; + name: { + /** The first name of the user. */ + givenName: string; + /** The last name of the user. */ + familyName: string; + }; + /** List of user emails. */ + emails: { + /** The email address. */ + value: string; + /** The type of email address. */ + type: string; + /** Whether this email address is the primary address. */ + primary: boolean; + }[]; + /** List of SCIM group IDs the user is a member of. */ + groups?: { + value?: string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/scim/v2/enterprises/${enterprise}/Users`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21555,11 +24613,38 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users/${scimUserId}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21575,11 +24660,19 @@ export class Api extends HttpClient this.request({ path: `/scim/v2/enterprises/${enterprise}/Users/${scimUserId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21609,8 +24702,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/scim/v2/organizations/${org}/Users`, @@ -21643,10 +24736,47 @@ export class Api extends HttpClient + scimProvisionAndInviteUser: ( + org: string, + data: { + /** + * Configured by the admin. Could be an email, login, or username + * @example "someone@example.com" + */ + userName: string; + /** + * The name of the user, suitable for display to end-users + * @example "Jon Doe" + */ + displayName?: string; + /** @example {"givenName":"Jane","familyName":"User"} */ + name: { + givenName: string; + familyName: string; + formatted?: string; + }; + /** + * user emails + * @minItems 1 + * @example [{"value":"someone@example.com","primary":true},{"value":"another@example.com","primary":false}] + */ + emails: { + value: string; + primary?: boolean; + type?: string; + }[]; + schemas?: string[]; + externalId?: string; + groups?: string[]; + active?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/scim/v2/organizations/${org}/Users`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21675,10 +24805,48 @@ export class Api extends HttpClient + scimSetInformationForProvisionedUser: ( + org: string, + scimUserId: string, + data: { + schemas?: string[]; + /** + * The name of the user, suitable for display to end-users + * @example "Jon Doe" + */ + displayName?: string; + externalId?: string; + groups?: string[]; + active?: boolean; + /** + * Configured by the admin. Could be an email, login, or username + * @example "someone@example.com" + */ + userName: string; + /** @example {"givenName":"Jane","familyName":"User"} */ + name: { + givenName: string; + familyName: string; + formatted?: string; + }; + /** + * user emails + * @minItems 1 + * @example [{"value":"someone@example.com","primary":true},{"value":"another@example.com","primary":false}] + */ + emails: { + type?: string; + value: string; + primary?: boolean; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/scim/v2/organizations/${org}/Users/${scimUserId}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21691,10 +24859,41 @@ export class Api extends HttpClient + scimUpdateAttributeForUser: ( + org: string, + scimUserId: string, + data: { + schemas?: string[]; + /** + * Set of operations to be performed + * @minItems 1 + * @example [{"op":"replace","value":{"active":false}}] + */ + Operations: { + op: "add" | "remove" | "replace"; + path?: string; + value?: + | { + active?: boolean | null; + userName?: string | null; + externalId?: string | null; + givenName?: string | null; + familyName?: string | null; + } + | { + value?: string; + primary?: boolean; + }[] + | string; + }[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/scim/v2/organizations/${org}/Users/${scimUserId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -21724,7 +24923,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -21777,7 +24976,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -21827,7 +25026,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -21891,7 +25090,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -21930,7 +25129,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -21982,11 +25181,11 @@ export class Api extends HttpClient this.request< { @@ -22015,7 +25214,6 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -22085,10 +25284,40 @@ export class Api extends HttpClient + teamsUpdateLegacy: ( + teamId: number, + data: { + /** The name of the team. */ + name: string; + /** The description of the team. */ + description?: string; + /** + * The level of privacy this team should have. Editing teams without specifying this parameter leaves `privacy` intact. The options are: + * **For a non-nested team:** + * \* `secret` - only visible to organization owners and members of this team. + * \* `closed` - visible to all members of this organization. + * **For a parent or child team:** + * \* `closed` - visible to all members of this organization. + */ + privacy?: "secret" | "closed"; + /** + * **Deprecated**. The permission that new repositories will be added to the team with when none is specified. Can be one of: + * \* `pull` - team members can pull, but not push to or administer newly-added repositories. + * \* `push` - team members can pull and push, but not administer newly-added repositories. + * \* `admin` - team members can pull, push and administer newly-added repositories. + * @default "pull" + */ + permission?: "pull" | "push" | "admin"; + /** The ID of a team to set as the parent team. */ + parent_team_id?: number | null; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22120,8 +25349,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions`, @@ -22156,10 +25385,26 @@ export class Api extends HttpClient + teamsCreateDiscussionLegacy: ( + teamId: number, + data: { + /** The discussion post's title. */ + title: string; + /** The discussion post's body text. */ + body: string; + /** + * Private posts are only visible to team members, organization owners, and team maintainers. Public posts are visible to all members of the organization. Set to `true` to create a private post. + * @default false + */ + private?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/discussions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22190,10 +25435,22 @@ export class Api extends HttpClient + teamsUpdateDiscussionLegacy: ( + teamId: number, + discussionNumber: number, + data: { + /** The discussion post's title. */ + title?: string; + /** The discussion post's body text. */ + body?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22226,8 +25483,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments`, @@ -22262,10 +25519,20 @@ export class Api extends HttpClient + teamsCreateDiscussionCommentLegacy: ( + teamId: number, + discussionNumber: number, + data: { + /** The discussion comment's body text. */ + body: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22305,11 +25572,17 @@ export class Api extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22348,8 +25621,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, @@ -22385,11 +25658,17 @@ export class Api extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/comments/${commentNumber}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22406,8 +25685,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/reactions`, @@ -22439,10 +25718,20 @@ export class Api extends HttpClient + reactionsCreateForTeamDiscussionLegacy: ( + teamId: number, + discussionNumber: number, + data: { + /** The [reaction type](https://docs.github.com/rest/reference/reactions#reaction-types) to add to the team discussion. */ + content: "+1" | "-1" | "laugh" | "confused" | "heart" | "hooray" | "rocket" | "eyes"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/discussions/${discussionNumber}/reactions`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22458,8 +25747,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/invitations`, @@ -22491,8 +25780,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/members`, @@ -22609,7 +25898,20 @@ export class Api extends HttpClient + teamsAddOrUpdateMembershipForUserLegacy: ( + teamId: number, + username: string, + data: { + /** + * The role that this user should have in the team. Can be one of: + * \* `member` - a normal member of the team. + * \* `maintainer` - a team maintainer. Able to add/remove other team members, promote other team members to team maintainer, and edit the team's name and description. + * @default "member" + */ + role?: "member" | "maintainer"; + }, + params: RequestParams = {}, + ) => this.request< TeamMembership, | void @@ -22627,6 +25929,8 @@ export class Api extends HttpClient({ path: `/teams/${teamId}/memberships/${username}`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22658,8 +25962,7 @@ export class Api extends HttpClient extends HttpClient this.request< TeamProject[], @@ -22719,7 +26023,21 @@ export class Api extends HttpClient + teamsAddOrUpdateProjectPermissionsLegacy: ( + teamId: number, + projectId: number, + data: { + /** + * The permission to grant to the team for this project. Can be one of: + * \* `read` - team members can read, but not write to or administer this project. + * \* `write` - team members can read and write, but not administer this project. + * \* `admin` - team members can read, write and administer this project. + * Default: the team's `permission` attribute will be used to determine what permission to grant the team on this project. Note that, if you choose not to pass any parameters, you'll need to set `Content-Length` to zero when calling out to this endpoint. For more information, see "[HTTP verbs](https://docs.github.com/rest/overview/resources-in-the-rest-api#http-verbs)." + */ + permission?: "read" | "write" | "admin"; + }, + params: RequestParams = {}, + ) => this.request< void, | { @@ -22735,6 +26053,8 @@ export class Api extends HttpClient({ path: `/teams/${teamId}/projects/${projectId}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -22773,8 +26093,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/repos`, @@ -22821,10 +26141,28 @@ export class Api extends HttpClient + teamsAddOrUpdateRepoPermissionsLegacy: ( + teamId: number, + owner: string, + repo: string, + data: { + /** + * The permission to grant the team on this repository. Can be one of: + * \* `pull` - team members can pull, but not push to or administer this repository. + * \* `push` - team members can pull and push, but not administer this repository. + * \* `admin` - team members can pull, push and administer this repository. + * + * If no permission is specified, the team's `permission` attribute will be used to determine what permission to grant the team on this repository. + */ + permission?: "pull" | "push" | "admin"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/repos/${owner}/${repo}`, method: "PUT", + body: data, + type: ContentType.Json, ...params, }), @@ -22870,10 +26208,34 @@ export class Api extends HttpClient + teamsCreateOrUpdateIdpGroupConnectionsLegacy: ( + teamId: number, + data: { + /** The IdP groups you want to connect to a GitHub team. When updating, the new `groups` object will replace the original one. You must include any existing groups that you don't want to remove. */ + groups: { + /** ID of the IdP group. */ + group_id: string; + /** Name of the IdP group. */ + group_name: string; + /** Description of the IdP group. */ + group_description: string; + /** @example ""caceab43fc9ffa20081c"" */ + id?: string; + /** @example ""external-team-6c13e7288ef7"" */ + name?: string; + /** @example ""moar cheese pleese"" */ + description?: string; + }[]; + /** @example ""I am not a timestamp"" */ + synced_at?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/teams/${teamId}/team-sync/group-mappings`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -22889,8 +26251,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/teams/${teamId}/teams`, @@ -22936,10 +26298,50 @@ export class Api extends HttpClient + usersUpdateAuthenticated: ( + data: { + /** + * The new name of the user. + * @example "Omar Jahandar" + */ + name?: string; + /** + * The publicly visible email address of the user. + * @example "omar@example.com" + */ + email?: string; + /** + * The new blog URL of the user. + * @example "blog.example.com" + */ + blog?: string; + /** + * The new Twitter username of the user. + * @example "therealomarj" + */ + twitter_username?: string | null; + /** + * The new company of the user. + * @example "Acme corporation" + */ + company?: string; + /** + * The new location of the user. + * @example "Berlin, Germany" + */ + location?: string; + /** The new hiring availability of the user. */ + hireable?: boolean; + /** The new short biography of the user. */ + bio?: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23020,10 +26422,23 @@ export class Api extends HttpClient + usersSetPrimaryEmailVisibilityForAuthenticated: ( + data: { + /** + * An email address associated with the GitHub user account to manage. + * @example "org@example.com" + */ + email: string; + /** Denotes whether an email is publically visible. */ + visibility: "public" | "private"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/email/visibility`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23037,8 +26452,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/emails`, @@ -23067,10 +26482,24 @@ export class Api extends HttpClient + usersAddEmailForAuthenticated: ( + data: + | { + /** + * Adds one or more email addresses to your GitHub account. Must contain at least one email address. **Note:** Alternatively, you can pass a single email address or an `array` of emails addresses directly, but we recommend that you pass an object using the `emails` key. + * @example [] + */ + emails: string[]; + } + | string[] + | string, + params: RequestParams = {}, + ) => this.request({ path: `/user/emails`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23083,10 +26512,21 @@ export class Api extends HttpClient + usersDeleteEmailForAuthenticated: ( + data: + | { + /** Email addresses associated with the GitHub user account. */ + emails: string[]; + } + | string[] + | string, + params: RequestParams = {}, + ) => this.request({ path: `/user/emails`, method: "DELETE", + body: data, + type: ContentType.Json, ...params, }), @@ -23099,8 +26539,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/followers`, @@ -23130,8 +26570,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/following`, @@ -23206,8 +26646,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/gpg_keys`, @@ -23236,10 +26676,18 @@ export class Api extends HttpClient + usersCreateGpgKeyForAuthenticated: ( + data: { + /** A GPG key in ASCII-armored format. */ + armored_public_key: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/gpg_keys`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23284,8 +26732,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -23326,8 +26774,7 @@ export class Api extends HttpClient extends HttpClient this.request< { @@ -23409,10 +26857,12 @@ export class Api extends HttpClient + interactionsSetRestrictionsForAuthenticatedUser: (data: InteractionLimit, params: RequestParams = {}) => this.request({ path: `/user/interaction-limits`, method: "PUT", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23441,8 +26891,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/issues`, @@ -23501,8 +26951,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/keys`, @@ -23531,10 +26981,26 @@ export class Api extends HttpClient + usersCreatePublicSshKeyForAuthenticated: ( + data: { + /** + * A descriptive name for the new key. + * @example "Personal MacBook Air" + */ + title?: string; + /** + * The public SSH key to add to your GitHub account. + * @pattern ^ssh-(rsa|dss|ed25519) |^ecdsa-sha2-nistp(256|384|521) + */ + key: string; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/keys`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23579,8 +27045,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/marketplace_purchases`, @@ -23610,8 +27076,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/marketplace_purchases/stubbed`, @@ -23641,8 +27107,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/memberships/orgs`, @@ -23689,10 +27155,19 @@ export class Api extends HttpClient + orgsUpdateMembershipForAuthenticatedUser: ( + org: string, + data: { + /** The state that the membership should be in. Only `"active"` will be accepted. */ + state: "active"; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/memberships/orgs/${org}`, method: "PATCH", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23706,8 +27181,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/migrations`, @@ -23736,10 +27211,32 @@ export class Api extends HttpClient + migrationsStartForAuthenticatedUser: ( + data: { + /** + * Lock the repositories being migrated at the start of the migration + * @example true + */ + lock_repositories?: boolean; + /** + * Do not include attachments in the migration + * @example true + */ + exclude_attachments?: boolean; + /** + * Exclude attributes from the API response to improve performance + * @example ["repositories"] + */ + exclude?: "repositories"[]; + repositories: string[]; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/migrations`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23754,10 +27251,10 @@ export class Api extends HttpClient this.request({ path: `/user/migrations/${migrationId}`, @@ -23822,8 +27319,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/migrations/${migrationId}/repositories`, @@ -23853,8 +27350,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/orgs`, @@ -23883,7 +27380,21 @@ export class Api extends HttpClient + projectsCreateForAuthenticatedUser: ( + data: { + /** + * Name of the project + * @example "Week One Sprint" + */ + name: string; + /** + * Body of the project + * @example "This project represents the sprint of the first week in January" + */ + body?: string | null; + }, + params: RequestParams = {}, + ) => this.request< Project, | BasicError @@ -23895,6 +27406,8 @@ export class Api extends HttpClient({ path: `/user/projects`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -23908,8 +27421,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/public_emails`, @@ -23939,8 +27452,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/repos`, @@ -24000,10 +27513,101 @@ export class Api extends HttpClient + reposCreateForAuthenticatedUser: ( + data: { + /** + * The name of the repository. + * @example "Team Environment" + */ + name: string; + /** A short description of the repository. */ + description?: string; + /** A URL with more information about the repository. */ + homepage?: string; + /** + * Whether the repository is private or public. + * @default false + */ + private?: boolean; + /** + * Whether issues are enabled. + * @default true + * @example true + */ + has_issues?: boolean; + /** + * Whether projects are enabled. + * @default true + * @example true + */ + has_projects?: boolean; + /** + * Whether the wiki is enabled. + * @default true + * @example true + */ + has_wiki?: boolean; + /** The id of the team that will be granted access to this repository. This is only valid when creating a repository in an organization. */ + team_id?: number; + /** + * Whether the repository is initialized with a minimal README. + * @default false + */ + auto_init?: boolean; + /** + * The desired language or platform to apply to the .gitignore. + * @example "Haskell" + */ + gitignore_template?: string; + /** + * The license keyword of the open source license for this repository. + * @example "mit" + */ + license_template?: string; + /** + * Whether to allow squash merges for pull requests. + * @default true + * @example true + */ + allow_squash_merge?: boolean; + /** + * Whether to allow merge commits for pull requests. + * @default true + * @example true + */ + allow_merge_commit?: boolean; + /** + * Whether to allow rebase merges for pull requests. + * @default true + * @example true + */ + allow_rebase_merge?: boolean; + /** + * Whether to delete head branches when pull requests are merged + * @default false + * @example false + */ + delete_branch_on_merge?: boolean; + /** + * Whether downloads are enabled. + * @default true + * @example true + */ + has_downloads?: boolean; + /** + * Whether this repository acts as a template that can be used to generate new repositories. + * @default false + * @example true + */ + is_template?: boolean; + }, + params: RequestParams = {}, + ) => this.request({ path: `/user/repos`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -24017,8 +27621,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/repository_invitations`, @@ -24078,8 +27682,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/starred`, @@ -24164,8 +27768,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/subscriptions`, @@ -24195,8 +27799,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/user/teams`, @@ -24227,8 +27831,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users`, @@ -24272,8 +27876,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events`, @@ -24305,8 +27909,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events/orgs/${org}`, @@ -24337,8 +27941,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/events/public`, @@ -24369,8 +27973,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/followers`, @@ -24401,8 +28005,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/following`, @@ -24448,8 +28052,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/gists`, @@ -24482,8 +28086,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/gpg_keys`, @@ -24514,13 +28118,13 @@ export class Api extends HttpClient this.request({ path: `/users/${username}/hovercard`, @@ -24556,8 +28160,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/keys`, @@ -24588,8 +28192,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/orgs`, @@ -24620,8 +28224,7 @@ export class Api extends HttpClient extends HttpClient this.request< Project[], @@ -24664,8 +28268,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/received_events`, @@ -24696,8 +28300,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/received_events/public`, @@ -24728,8 +28332,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/repos`, @@ -24820,8 +28424,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/starred`, @@ -24862,8 +28466,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/users/${username}/subscriptions`, diff --git a/tests/generated/v3.0/link-example.ts b/tests/generated/v3.0/link-example.ts index 84c976dd..0444a117 100644 --- a/tests/generated/v3.0/link-example.ts +++ b/tests/generated/v3.0/link-example.ts @@ -293,10 +293,10 @@ export class Api extends HttpClient this.request({ path: `/2.0/repositories/${username}/${slug}/pullrequests`, diff --git a/tests/generated/v3.0/oneof-example.ts b/tests/generated/v3.0/oneof-example.ts index b517e3df..c87ba1ab 100644 --- a/tests/generated/v3.0/oneof-example.ts +++ b/tests/generated/v3.0/oneof-example.ts @@ -241,10 +241,12 @@ export class Api extends HttpClient + petsPartialUpdate: (data: Cat | Dog, params: RequestParams = {}) => this.request({ path: `/pets`, method: "PATCH", + body: data, + type: ContentType.Json, ...params, }), }; diff --git a/tests/generated/v3.0/personal-api-example.ts b/tests/generated/v3.0/personal-api-example.ts index 69398c15..0b231244 100644 --- a/tests/generated/v3.0/personal-api-example.ts +++ b/tests/generated/v3.0/personal-api-example.ts @@ -417,10 +417,12 @@ export class Api extends HttpClient + login: (data: AuthUserType, params: RequestParams = {}) => this.request({ path: `/auth`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -468,11 +470,13 @@ export class Api extends HttpClient + addJob: (data: JobUpdateType, params: RequestParams = {}) => this.request({ path: `/jobs`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -502,13 +506,15 @@ export class Api extends HttpClient + updateJob: (id: string, params: JobUpdateType, requestParams: RequestParams = {}) => this.request({ path: `/jobs/${id}`, method: "PATCH", + body: params, secure: true, + type: ContentType.Json, format: "json", - ...params, + ...requestParams, }), /** @@ -552,11 +558,13 @@ export class Api extends HttpClient + addProjects: (data: ProjectUpdateType, params: RequestParams = {}) => this.request({ path: `/projects`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -569,11 +577,13 @@ export class Api extends HttpClient + updateProject: (id: string, data: ProjectUpdateType, params: RequestParams = {}) => this.request({ path: `/projects/${id}`, method: "PATCH", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/petstore-expanded.ts b/tests/generated/v3.0/petstore-expanded.ts index fab4d1c5..32e92c76 100644 --- a/tests/generated/v3.0/petstore-expanded.ts +++ b/tests/generated/v3.0/petstore-expanded.ts @@ -254,8 +254,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, @@ -279,10 +279,12 @@ export class Api extends HttpClient + addPet: (data: NewPet, params: RequestParams = {}) => this.request({ path: `/pets`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/petstore.ts b/tests/generated/v3.0/petstore.ts index a6e99672..15d2e6e4 100644 --- a/tests/generated/v3.0/petstore.ts +++ b/tests/generated/v3.0/petstore.ts @@ -253,14 +253,14 @@ export class Api extends HttpClient this.request({ path: `/pets`, diff --git a/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts b/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts index 1f6f08a9..08deff15 100644 --- a/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts +++ b/tests/generated/v3.0/tsoa-odd-types-3.0.2.ts @@ -343,10 +343,12 @@ export class Api extends HttpClient + login: (data?: AuthUser, params: RequestParams = {}) => this.request({ path: `/auth`, method: "POST", + body: data, + type: ContentType.Json, format: "json", ...params, }), @@ -394,11 +396,13 @@ export class Api extends HttpClient + addJob: (data: PickJobGithub, params: RequestParams = {}) => this.request({ path: `/jobs`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -428,11 +432,13 @@ export class Api extends HttpClient + updateJob: (id: string, data: JobUpdate, params: RequestParams = {}) => this.request({ path: `/jobs/${id}`, method: "PATCH", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -480,11 +486,13 @@ export class Api extends HttpClient + addJob: (data: PickJobGithub, params: RequestParams = {}) => this.request({ path: `x-route`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -513,11 +521,13 @@ export class Api extends HttpClient + addProjects: (data: ProjectUpdate, params: RequestParams = {}) => this.request({ path: `/projects`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -530,11 +540,13 @@ export class Api extends HttpClient + updateProject: (id: string, data: ProjectUpdate, params: RequestParams = {}) => this.request({ path: `/projects/${id}`, method: "PATCH", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -565,11 +577,13 @@ export class Api extends HttpClient + addUser: (data: AuthUser, params: RequestParams = {}) => this.request({ path: `/users`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -599,11 +613,13 @@ export class Api extends HttpClient + updateUser: (id: string, data: UserUpdate, params: RequestParams = {}) => this.request({ path: `/users/${id}`, method: "PATCH", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), diff --git a/tests/generated/v3.0/up-banking.ts b/tests/generated/v3.0/up-banking.ts index 5553637f..4c6f59af 100644 --- a/tests/generated/v3.0/up-banking.ts +++ b/tests/generated/v3.0/up-banking.ts @@ -984,14 +984,14 @@ export class Api extends HttpClient this.request({ path: `/accounts`, @@ -1031,8 +1031,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/accounts/${accountId}/transactions`, @@ -1098,8 +1098,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/categories`, @@ -1166,14 +1166,14 @@ export class Api extends HttpClient this.request({ path: `/tags`, @@ -1194,11 +1194,13 @@ export class Api extends HttpClient + relationshipsTagsCreate: (transactionId: string, data: UpdateTransactionTagsRequest, params: RequestParams = {}) => this.request({ path: `/transactions/${transactionId}/relationships/tags`, method: "POST", + body: data, secure: true, + type: ContentType.Json, ...params, }), @@ -1211,11 +1213,13 @@ export class Api extends HttpClient + relationshipsTagsDelete: (transactionId: string, data: UpdateTransactionTagsRequest, params: RequestParams = {}) => this.request({ path: `/transactions/${transactionId}/relationships/tags`, method: "DELETE", + body: data, secure: true, + type: ContentType.Json, ...params, }), @@ -1229,8 +1233,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/transactions`, @@ -1316,14 +1320,14 @@ export class Api extends HttpClient this.request({ path: `/webhooks`, @@ -1343,11 +1347,13 @@ export class Api extends HttpClient + webhooksCreate: (data: CreateWebhookRequest, params: RequestParams = {}) => this.request({ path: `/webhooks`, method: "POST", + body: data, secure: true, + type: ContentType.Json, format: "json", ...params, }), @@ -1416,14 +1422,14 @@ export class Api extends HttpClient this.request({ path: `/webhooks/${webhookId}/logs`, diff --git a/tests/generated/v3.0/uspto.ts b/tests/generated/v3.0/uspto.ts index 1135a8fa..55de00b4 100644 --- a/tests/generated/v3.0/uspto.ts +++ b/tests/generated/v3.0/uspto.ts @@ -275,7 +275,6 @@ export class Api extends HttpClient extends HttpClient + performSearch: ( + version: string, + dataset: string, + data: { + /** + * Uses Lucene Query Syntax in the format of propertyName:value, propertyName:[num1 TO num2] and date range format: propertyName:[yyyyMMdd TO yyyyMMdd]. In the response please see the 'docs' element which has the list of record objects. Each record structure would consist of all the fields and their corresponding values. + * @default "*:*" + */ + criteria: string; + /** + * Starting record number. Default value is 0. + * @default 0 + */ + start?: number; + /** + * Specify number of rows to be returned. If you run the search with default values, in the response you will see 'numFound' attribute which will tell the number of records available in the dataset. + * @default 100 + */ + rows?: number; + }, + params: RequestParams = {}, + ) => this.request[], void>({ path: `/${dataset}/${version}/records`, method: "POST", + body: data, + type: ContentType.UrlEncoded, format: "json", ...params, }), diff --git a/tests/generated/v3.0/wrong-schema-names.ts b/tests/generated/v3.0/wrong-schema-names.ts index 28e3f743..1454e15f 100644 --- a/tests/generated/v3.0/wrong-schema-names.ts +++ b/tests/generated/v3.0/wrong-schema-names.ts @@ -300,10 +300,10 @@ export class Api extends HttpClient this.request({ path: `/2.0/repositories/${username}/${slug}/pullrequests`, diff --git a/tests/spec/deprecated/schema.ts b/tests/spec/deprecated/schema.ts index 23c66fcd..55ce422e 100644 --- a/tests/spec/deprecated/schema.ts +++ b/tests/spec/deprecated/schema.ts @@ -238,8 +238,7 @@ export class Api extends HttpClient extends HttpClient this.request({ path: `/pets`, diff --git a/tests/spec/partialDefaultTemplate/spec_templates/api.eta b/tests/spec/partialDefaultTemplate/spec_templates/api.eta index b81eea38..e2dfa557 100644 --- a/tests/spec/partialDefaultTemplate/spec_templates/api.eta +++ b/tests/spec/partialDefaultTemplate/spec_templates/api.eta @@ -29,19 +29,23 @@ export class Api<% if (!config.singleHttpClien <% } %> -<% routes.outOfModule && routes.outOfModule.forEach((route) => { %> +<% if (routes.outOfModule) { %> + <% for await (const route of routes.outOfModule) { %> - <%~ includeFile('./procedure-call.ejs', { route, utils, config }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> -<% }) %> + <% } %> +<% } %> -<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> +<% if (routes.combined) { %> + <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> <%~ moduleName %> = { - <% routes.forEach((route) => { %> + <% for await (const route of combinedRoutes) { %> - <%~ includeFile('./procedure-call.ejs', { route, utils, config }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> - <% }) %> + <% } %> } -<% }) %> + <% } %> +<% } %> } diff --git a/tests/spec/templates/spec_templates/api.eta b/tests/spec/templates/spec_templates/api.eta index aa16d5a6..383f22ff 100644 --- a/tests/spec/templates/spec_templates/api.eta +++ b/tests/spec/templates/spec_templates/api.eta @@ -43,21 +43,25 @@ export class Api<% if (!config.singleHttpClien <% } %> -<% routes.outOfModule && routes.outOfModule.forEach((route) => { %> +<% if (routes.outOfModule) { %> + <% for await (const route of routes.outOfModule) { %> - <%~ await includeFile('./procedure-call.eta', { ...it, route }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> -<% }) %> + <% } %> +<% } %> -<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> +<% if (routes.combined) { %> + <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> <%~ moduleName %> = { - <% routes.forEach((route) => { %> + <% for await (const route of combinedRoutes) { %> - <%~ await includeFile('./procedure-call.eta', { ...it, route }) %> + <%~ await includeFile('./procedure-call.ejs', { ...it, route }) %> - <% }) %> + <% } %> } -<% }) %> + <% } %> +<% } %> } /* CUSTOM TEMPLATE */ diff --git a/tests/spec/templates/spec_templates/route-types.eta b/tests/spec/templates/spec_templates/route-types.eta index a8fc388f..c3667c79 100644 --- a/tests/spec/templates/spec_templates/route-types.eta +++ b/tests/spec/templates/spec_templates/route-types.eta @@ -1,23 +1,29 @@ <% -const { utils, config, routes } = it; +const { utils, config, routes, modelTypes } = it; +const { _, pascalCase } = utils; +const dataContracts = config.modular ? _.map(modelTypes, "name") : []; %> <% /* TODO: outOfModule, combined should be attributes of route, which will allow to avoid duplication of code */ %> -<% routes.outOfModule && routes.outOfModule.forEach(({ routes = [] }) => { %> - <% routes.forEach((route) => { %> - <%~ await includeFile('./route-type.eta', { route, utils, config }) %> - <% }) %> -<% }) %> -<% routes.combined && routes.combined.forEach(({ routes = [], moduleName }) => { %> - export namespace <%~ moduleName %> { - <% routes.forEach((route) => { %> - <%~ await includeFile('./route-type.eta', { route, utils, config }) %> - <% }) %> - } +<% if (routes.outOfModule) { %> + <% for await (const route of routes.outOfModule) { %> + + <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> + <% } %> +<% } %> -<% }) %> +<% if (routes.combined) { %> + <% for await (const { routes: combinedRoutes = [], moduleName } of routes.combined) { %> + + export namespace <%~ pascalCase(moduleName) %> { + <% for await (const route of combinedRoutes) { %> + <%~ await includeFile('@base/route-type.ejs', { ...it, route }) %> + <% } %> + } + <% } %> +<% } %> -/* CUSTOM TEMPLATE */ +/* CUSTOM TEMPLATE */ \ No newline at end of file From d700d255829b026042a9605b722a066d35f6b45f Mon Sep 17 00:00:00 2001 From: js2me Date: Sun, 13 Nov 2022 22:11:35 +0600 Subject: [PATCH 4/9] fix: schema parser(tuple) --- src/schema-parser/schema-parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index d3bb7f96..2ff33d8d 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -251,7 +251,7 @@ class SchemaParser { } if (_.isArray(items) && type === SCHEMA_TYPES.ARRAY) { - contentType = this.config.Ts.Tuple(items.map((item) => this.getInlineParseContent(item))); + contentType = this.config.Ts.Tuple(await Promise.all(items.map((item) => this.getInlineParseContent(item)))); } return { From 1926f1ff1175c1de15f0091a206e4d6de412a713 Mon Sep 17 00:00:00 2001 From: js2me Date: Mon, 14 Nov 2022 04:34:32 +0600 Subject: [PATCH 5/9] fix: problem with extracting enums and nested schema path due to async parsing --- README.md | 13 +- index.d.ts | 2 +- src/code-gen-process.js | 12 +- src/configuration.js | 8 +- src/schema-parser/schema-formatters.js | 2 +- src/schema-parser/schema-parser.js | 257 +++++++++++++------ src/schema-parser/schema-processor.js | 187 ++++++++++++++ src/schema-parser/schema-routes.js | 4 +- src/{type-name.js => type-name-formatter.js} | 4 +- tests/helpers/assertGeneratedModule.js | 79 +++++- tests/spec/extract-enums/schema.ts | 16 +- 11 files changed, 466 insertions(+), 118 deletions(-) create mode 100644 src/schema-parser/schema-processor.js rename src/{type-name.js => type-name-formatter.js} (98%) diff --git a/README.md b/README.md index fdd26a8c..d47acb32 100644 --- a/README.md +++ b/README.md @@ -399,16 +399,15 @@ generateApi({ ### `primitiveTypeConstructs` It is type mapper or translator swagger schema objects. `primitiveTypeConstructs` translates `type`/`format` schema fields to typescript structs. -This option has type +This option has type + ```ts type PrimitiveTypeStructValue = - | string - | ((schema: Record, parser: import("./src/schema-parser/schema-parser").SchemaParser) => string); + | string + | ((schema: Record, parser: import("./schema-parser-engine").SchemaProcessor) => string); -type PrimitiveTypeStruct = Record< - "integer" | "number" | "boolean" | "object" | "file" | "string" | "array", - string | ({ $default: PrimitiveTypeStructValue } & Record) -> +type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", + string | ({ $default: PrimitiveTypeStructValue } & Record)> declare const primitiveTypeConstructs: (struct: PrimitiveTypeStruct) => Partial diff --git a/index.d.ts b/index.d.ts index b864c217..5bf9d2b1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -201,7 +201,7 @@ type CodeGenConstruct = { type PrimitiveTypeStructValue = | string - | ((schema: Record, parser: import("./src/schema-parser/schema-parser").SchemaParser) => string); + | ((schema: Record, parser: import("./src/schema-parser/schema-processor").SchemaProcessor) => string); type PrimitiveTypeStruct = Record< "integer" | "number" | "boolean" | "object" | "file" | "string" | "array", diff --git a/src/code-gen-process.js b/src/code-gen-process.js index 4d461ca4..6bce628a 100644 --- a/src/code-gen-process.js +++ b/src/code-gen-process.js @@ -2,9 +2,9 @@ const { SwaggerSchemaResolver } = require("./swagger-schema-resolver.js"); const { SchemaComponentsMap } = require("./schema-components-map.js"); const { NameResolver } = require("./util/name-resolver"); const { Logger } = require("./util/logger.js"); -const { TypeName } = require("./type-name.js"); +const { TypeNameFormatter } = require("./type-name-formatter.js"); const _ = require("lodash"); -const { SchemaParser } = require("./schema-parser/schema-parser.js"); +const { SchemaProcessor } = require("./schema-parser/schema-processor.js"); const { SchemaRoutes } = require("./schema-parser/schema-routes.js"); const { CodeGenConfig } = require("./configuration.js"); const { FileSystem } = require("./util/file-system"); @@ -33,11 +33,11 @@ class CodeGenProcess { */ logger; /** - * @type {TypeName} + * @type {TypeNameFormatter} */ typeName; /** - * @type {SchemaParser} + * @type {SchemaProcessor} */ schemaParser; /** @@ -63,10 +63,10 @@ class CodeGenProcess { this.fileSystem = new FileSystem(); this.swaggerSchemaResolver = new SwaggerSchemaResolver(this.config, this.logger, this.fileSystem); this.schemaComponentMap = new SchemaComponentsMap(this.config); - this.typeName = new TypeName(this.config, this.logger); + this.typeName = new TypeNameFormatter(this.config, this.logger); this.templates = new Templates(this.config, this.logger, this.fileSystem, this.getRenderTemplateData); this.codeFormatter = new CodeFormatter(this.config); - this.schemaParser = new SchemaParser( + this.schemaParser = new SchemaProcessor( this.config, this.logger, this.templates, diff --git a/src/configuration.js b/src/configuration.js index 81042cac..f52be2e9 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -263,7 +263,7 @@ class CodeGenConfig { /** * swagger schema type -> typescript type * https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times - * @type {Record string) | ({ $default: string } & Record string)>)>} + * @type {Record string) | ({ $default: string } & Record string)>)>} */ primitiveTypes = { integer: () => this.Ts.Keyword.Number, @@ -294,9 +294,9 @@ class CodeGenConfig { "relative-json-pointer": () => this.Ts.Keyword.String, regex: () => this.Ts.Keyword.String, }, - array: async ({ items, ...schemaPart }, parser) => { - const content = await parser.getInlineParseContent(items); - return parser.schemaUtils.safeAddNullToType(schemaPart, this.Ts.ArrayType(content)); + array: async ({ items, ...schemaPart }, { createParser, schemaUtils }) => { + const content = await createParser(items).getInlineContent(); + return schemaUtils.safeAddNullToType(schemaPart, this.Ts.ArrayType(content)); }, }; diff --git a/src/schema-parser/schema-formatters.js b/src/schema-parser/schema-formatters.js index 25a36dc8..07346370 100644 --- a/src/schema-parser/schema-formatters.js +++ b/src/schema-parser/schema-formatters.js @@ -11,7 +11,7 @@ class SchemaFormatters { */ logger; /** - * @type {SchemaParser} + * @type {SchemaProcessor} */ schemaParser; /** diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index 2ff33d8d..4274766f 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -1,25 +1,23 @@ -const { SCHEMA_TYPES } = require("../constants.js"); -const _ = require("lodash"); const { SchemaFormatters } = require("./schema-formatters"); -const { internalCase } = require("../util/internal-case"); const { SchemaUtils } = require("./schema-utils"); +const { SCHEMA_TYPES } = require("../constants"); +const _ = require("lodash"); +const { internalCase } = require("../util/internal-case"); const { camelCase } = require("lodash"); -const { pascalCase } = require("../util/pascal-case"); class SchemaParser { /** * @type {CodeGenConfig} */ config; - /** * @type {SchemaComponentsMap} */ schemaComponentsMap; /** - * @type {TypeName} + * @type {TypeNameFormatter} */ - typeName; + typeNameFormatter; /** * @type {SchemaFormatters} */ @@ -30,23 +28,42 @@ class SchemaParser { */ schemaUtils; - $processingSchemaPath = []; + schemaPath = []; - constructor(config, logger, templates, schemaComponentsMap, typeName) { + typeName; + schema; + + constructor( + config, + schemaComponentsMap, + typeNameFormatter, + schemaFormatters, + schemaUtils, + schema, + typeName = null, + schemaPath = [], + ) { this.config = config; this.schemaComponentsMap = schemaComponentsMap; + this.typeNameFormatter = typeNameFormatter; + this.schemaFormatters = schemaFormatters; + this.schemaUtils = schemaUtils; + this.schema = schema; this.typeName = typeName; - this.schemaFormatters = new SchemaFormatters(config, logger, this, templates); - this.schemaUtils = new SchemaUtils(config, schemaComponentsMap); + this.schemaPath = schemaPath; } - complexSchemaParsers = { + _complexSchemaParsers = { // T1 | T2 [SCHEMA_TYPES.COMPLEX_ONE_OF]: async (schema) => { const ignoreTypes = [this.config.Ts.Keyword.Any]; const combined = await Promise.all( _.map(schema.oneOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + this.createParser( + this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema), + undefined, + this.schemaPath, + ).getInlineContent(), ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -60,7 +77,11 @@ class SchemaParser { const ignoreTypes = [...this.config.jsPrimitiveTypes, this.config.Ts.Keyword.Any]; const combined = await Promise.all( _.map(schema.allOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + this.createParser( + this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema), + undefined, + this.schemaPath, + ).getInlineContent(), ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -74,7 +95,11 @@ class SchemaParser { const ignoreTypes = [...this.config.jsPrimitiveTypes, this.config.Ts.Keyword.Any]; const combined = await Promise.all( _.map(schema.anyOf, (childSchema) => - this.getInlineParseContent(this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema)), + this.createParser( + this.schemaUtils.makeAddRequiredToChildSchema(schema, childSchema), + undefined, + this.schemaPath, + ).getInlineContent(), ), ); const filtered = this.schemaUtils.filterSchemaContents(combined, (content) => !ignoreTypes.includes(content)); @@ -95,19 +120,20 @@ class SchemaParser { }, }; - baseSchemaParsers = { + _baseSchemaParsers = { [SCHEMA_TYPES.ENUM]: async (schema, typeName) => { if (this.config.extractEnums && !typeName) { const generatedTypeName = this.config.componentTypeNameResolver.resolve([this.buildTypeNameFromPath()]); const schemaComponent = this.schemaComponentsMap.createComponent("schemas", generatedTypeName, { ...schema }); - return this.parseSchema(schemaComponent, generatedTypeName); + const parser = this.createParser(schemaComponent, generatedTypeName); + return await parser.parse(); } const refType = this.schemaUtils.getSchemaRefType(schema); const $ref = (refType && refType.$ref) || null; if (Array.isArray(schema.enum) && Array.isArray(schema.enum[0])) { - return this.parseSchema( + return await this.createParser( { oneOf: schema.enum.map((enumNames) => ({ type: "array", @@ -115,7 +141,8 @@ class SchemaParser { })), }, typeName, - ); + this.schemaPath, + ).parse(); } const keyType = await this.getSchemaType(schema); @@ -142,10 +169,10 @@ class SchemaParser { const enumValue = _.get(schema.enum, index); const formattedKey = (enumName && - this.typeName.format(enumName, { + this.typeNameFormatter.format(enumName, { type: "enum-key", })) || - this.typeName.format(`${enumValue}`, { + this.typeNameFormatter.format(`${enumValue}`, { type: "enum-key", }); @@ -168,7 +195,7 @@ class SchemaParser { content = await Promise.all( _.map(schema.enum, async (key) => { return { - key: this.typeName.format(`${key}`, { + key: this.typeNameFormatter.format(`${key}`, { type: "enum-key", }), type: keyType, @@ -209,8 +236,8 @@ class SchemaParser { }, [SCHEMA_TYPES.COMPLEX]: async (schema, typeName) => { const complexType = this.getComplexType(schema); - const simpleSchema = _.omit(_.clone(schema), _.keys(this.complexSchemaParsers)); - const complexSchemaContent = await this.complexSchemaParsers[complexType](schema); + const simpleSchema = _.omit(_.clone(schema), _.keys(this._complexSchemaParsers)); + const complexSchemaContent = await this._complexSchemaParsers[complexType](schema); return { ...(_.isObject(schema) ? schema : {}), @@ -227,7 +254,9 @@ class SchemaParser { _.compact([ this.config.Ts.ExpressionGroup(complexSchemaContent), this.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && - this.config.Ts.ExpressionGroup(await this.getInlineParseContent(simpleSchema)), + this.config.Ts.ExpressionGroup( + await this.createParser(simpleSchema, null, this.schemaPath).getInlineContent(), + ), ]), ) || this.config.Ts.Keyword.Any, }; @@ -238,20 +267,22 @@ class SchemaParser { if (type === this.config.Ts.Keyword.Object && additionalProperties) { const fieldType = _.isObject(additionalProperties) - ? await this.getInlineParseContent(additionalProperties) + ? await this.createParser(additionalProperties, null, this.schemaPath).getInlineContent() : this.config.Ts.Keyword.Any; contentType = this.config.Ts.RecordType(this.config.Ts.Keyword.String, fieldType); } if (_.isArray(type) && type.length) { - contentType = await this.complexSchemaParsers.oneOf({ + contentType = await this._complexSchemaParsers.oneOf({ ...(_.isObject(schema) ? schema : {}), oneOf: type.map((type) => ({ type })), }); } if (_.isArray(items) && type === SCHEMA_TYPES.ARRAY) { - contentType = this.config.Ts.Tuple(await Promise.all(items.map((item) => this.getInlineParseContent(item)))); + contentType = this.config.Ts.Tuple( + await Promise.all(items.map((item) => this.createParser(item, null, this.schemaPath).getInlineContent())), + ); } return { @@ -284,7 +315,7 @@ class SchemaParser { if (refTypeInfo) { return this.schemaUtils.checkAndAddRequiredKeys( schema, - this.schemaUtils.safeAddNullToType(schema, this.typeName.format(refTypeInfo.typeName)), + this.schemaUtils.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)), ); } @@ -303,7 +334,10 @@ class SchemaParser { this.config.primitiveTypes[primitiveType]; if (_.isFunction(typeAlias)) { - resultType = await typeAlias(schema, this); + resultType = await typeAlias(schema, { + createParser: (schema, typeName) => this.createParser(schema, typeName, this.schemaPath), + schemaUtils: this.schemaUtils, + }); } else { resultType = typeAlias || primitiveType; } @@ -315,42 +349,43 @@ class SchemaParser { getObjectSchemaContent = async (schema) => { const { properties, additionalProperties } = schema || {}; + const propertiesContent = []; + + const propertyEntries = _.entries(properties); - const propertiesContent = await Promise.all( - _.map(properties, async (property, name) => { - this.$processingSchemaPath.push(name); - const required = this.schemaUtils.isPropertyRequired(name, property, schema); - const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); - const nullable = !!(rawTypeData.nullable || property.nullable); - const fieldName = this.typeName.isValidName(name) ? name : this.config.Ts.StringValue(name); - const fieldValue = await this.getInlineParseContent(property); - const readOnly = property.readOnly; - - this.$processingSchemaPath.pop(); - - return { - ...property, - $$raw: property, - title: property.title, - description: - property.description || - _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || - rawTypeData.description || - _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || - "", - isRequired: required, - isNullable: nullable, - name: fieldName, + for await (const [name, property] of propertyEntries) { + this.schemaPath.push(name); + const required = this.schemaUtils.isPropertyRequired(name, property, schema); + const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); + const nullable = !!(rawTypeData.nullable || property.nullable); + const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name); + const fieldValue = await this.createParser(property, null, this.schemaPath).getInlineContent(); + const readOnly = property.readOnly; + + this.schemaPath.pop(); + + propertiesContent.push({ + ...property, + $$raw: property, + title: property.title, + description: + property.description || + _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || + rawTypeData.description || + _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || + "", + isRequired: required, + isNullable: nullable, + name: fieldName, + value: fieldValue, + field: this.config.Ts.TypeField({ + readonly: readOnly && this.config.addReadonly, + optional: !required, + key: fieldName, value: fieldValue, - field: this.config.Ts.TypeField({ - readonly: readOnly && this.config.addReadonly, - optional: !required, - key: fieldName, - value: fieldValue, - }), - }; - }), - ); + }), + }); + } if (additionalProperties) { propertiesContent.push({ @@ -381,57 +416,109 @@ class SchemaParser { * @param formatter {"inline" | "base"} * @return {Promise>} */ - parseSchema = async (schema, typeName = null) => { - if (!schema) return await this.baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, typeName); + parse = async () => { + if (!this.schema) return await this._baseSchemaParsers[SCHEMA_TYPES.PRIMITIVE](null, this.typeName); let schemaType = null; let parsedSchema = null; - if (typeof schema === "string") { - return schema; + if (typeof this.schema === "string") { + return this.schema; } - if (!schema.$parsed) { - if (!typeName && this.schemaUtils.isRefSchema(schema)) { - typeName = await this.getSchemaType(schema); + if (!this.schema.$parsed) { + if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) { + this.typeName = await this.getSchemaType(this.schema); } - if (schema.items && !Array.isArray(schema.items) && !schema.type) { - schema.type = SCHEMA_TYPES.ARRAY; + if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) { + this.schema.type = SCHEMA_TYPES.ARRAY; } - schemaType = this.getInternalSchemaType(schema); + schemaType = this.getInternalSchemaType(this.schema); - this.$processingSchemaPath.push(typeName); + this.schemaPath.push(this.typeName); - _.merge(schema, this.config.hooks.onPreParseSchema(schema, typeName, schemaType)); - parsedSchema = await this.baseSchemaParsers[schemaType](schema, typeName); - schema.$parsed = this.config.hooks.onParseSchema(schema, parsedSchema) || parsedSchema; + _.merge(this.schema, this.config.hooks.onPreParseSchema(this.schema, this.typeName, schemaType)); + parsedSchema = await this._baseSchemaParsers[schemaType](this.schema, this.typeName); + this.schema.$parsed = this.config.hooks.onParseSchema(this.schema, parsedSchema) || parsedSchema; } - this.$processingSchemaPath.pop(); + this.schemaPath.pop(); - return schema.$parsed; + return this.schema.$parsed; }; - getInlineParseContent = async (rawTypeData, typeName) => { - const parsedSchema = await this.parseSchema(rawTypeData, typeName); + getInlineContent = async () => { + const parsedSchema = await this.parse(); const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "inline" }); return formattedSchema.content; }; - getParseContent = async (rawTypeData, typeName) => { - const parsedSchema = await this.parseSchema(rawTypeData, typeName); + getContent = async () => { + const parsedSchema = await this.parse(); const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "base" }); return formattedSchema.content; }; buildTypeNameFromPath = () => { - const schemaPath = _.uniq(_.compact(this.$processingSchemaPath)); + const schemaPath = _.uniq(_.compact(this.schemaPath)); if (!schemaPath || !schemaPath[0]) return null; return internalCase(camelCase(`${schemaPath[0]}_${schemaPath[schemaPath.length - 1]}`)); }; + + /** + * @param {Record} [schema] + * @param {string | null | undefined} [typeName] + * @param {string[] | undefined} [schemaPath] + * @return {SchemaParser} + */ + createParser = (schema, typeName, schemaPath) => { + return new SchemaParser( + this.config, + this.schemaComponentsMap, + this.typeNameFormatter, + this.schemaFormatters, + this.schemaUtils, + schema, + typeName, + schemaPath, + ); + }; + + /** + * @param config {CodeGenConfig} + * @param schemaComponentsMap {SchemaComponentsMap} + * @param typeNameFormatter {TypeNameFormatter} + * @param schemaFormatters {SchemaFormatters} + * @param schemaUtils {SchemaUtils} + * @param {Record} [schema] + * @param {string | null | undefined} [typeName] + * @param {string[] | undefined} [schemaPath] + * @return {SchemaParser} + */ + static create( + config, + schemaComponentsMap, + typeNameFormatter, + schemaFormatters, + schemaUtils, + schema, + typeName, + schemaPath, + ) { + return new SchemaParser( + config, + schemaComponentsMap, + typeNameFormatter, + schemaFormatters, + schemaUtils, + schema, + typeName, + schemaPath, + ); + } } module.exports = { diff --git a/src/schema-parser/schema-processor.js b/src/schema-parser/schema-processor.js new file mode 100644 index 00000000..0acb7dfd --- /dev/null +++ b/src/schema-parser/schema-processor.js @@ -0,0 +1,187 @@ +const { SCHEMA_TYPES } = require("../constants.js"); +const _ = require("lodash"); +const { SchemaFormatters } = require("./schema-formatters"); +const { internalCase } = require("../util/internal-case"); +const { SchemaUtils } = require("./schema-utils"); +const { camelCase } = require("lodash"); +const { pascalCase } = require("../util/pascal-case"); +const { SchemaParser } = require("./schema-parser"); + +class SchemaProcessor { + /** + * @type {CodeGenConfig} + */ + config; + + /** + * @type {SchemaComponentsMap} + */ + schemaComponentsMap; + /** + * @type {TypeNameFormatter} + */ + typeNameFormatter; + /** + * @type {SchemaFormatters} + */ + schemaFormatters; + + /** + * @type {SchemaUtils} + */ + schemaUtils; + + $processingSchemaPath = []; + + /** + * @type {((schema, typeName) => SchemaParser)} + */ + createSchemaParser; + + constructor(config, logger, templates, schemaComponentsMap, typeNameFormatter) { + this.config = config; + this.schemaComponentsMap = schemaComponentsMap; + this.typeNameFormatter = typeNameFormatter; + this.schemaFormatters = new SchemaFormatters(config, logger, this, templates); + this.schemaUtils = new SchemaUtils(config, schemaComponentsMap); + this.createSchemaParser = SchemaParser.create.bind( + null, + config, + schemaComponentsMap, + typeNameFormatter, + this.schemaFormatters, + this.schemaUtils, + ); + } + + getSchemaType = async (schema) => { + if (!schema) return this.config.Ts.Keyword.Any; + + const refTypeInfo = this.schemaUtils.getSchemaRefType(schema); + + if (refTypeInfo) { + return this.schemaUtils.checkAndAddRequiredKeys( + schema, + this.schemaUtils.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)), + ); + } + + const primitiveType = this.schemaUtils.getSchemaPrimitiveType(schema); + + if (primitiveType == null) return this.config.Ts.Keyword.Any; + + let resultType; + + /** + * @type {string | (() => Promise)} + */ + const typeAlias = + _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || + _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || + this.config.primitiveTypes[primitiveType]; + + if (_.isFunction(typeAlias)) { + resultType = await typeAlias(schema, this); + } else { + resultType = typeAlias || primitiveType; + } + + if (!resultType) return this.config.Ts.Keyword.Any; + + return this.schemaUtils.checkAndAddRequiredKeys(schema, this.schemaUtils.safeAddNullToType(schema, resultType)); + }; + + getObjectSchemaContent = async (schema) => { + const { properties, additionalProperties } = schema || {}; + + const propertiesContent = await Promise.all( + _.map(properties, async (property, name) => { + this.$processingSchemaPath.push(name); + const required = this.schemaUtils.isPropertyRequired(name, property, schema); + const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); + const nullable = !!(rawTypeData.nullable || property.nullable); + const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name); + const fieldValue = await this.getInlineParseContent(property); + const readOnly = property.readOnly; + + this.$processingSchemaPath.pop(); + + return { + ...property, + $$raw: property, + title: property.title, + description: + property.description || + _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || + rawTypeData.description || + _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || + "", + isRequired: required, + isNullable: nullable, + name: fieldName, + value: fieldValue, + field: this.config.Ts.TypeField({ + readonly: readOnly && this.config.addReadonly, + optional: !required, + key: fieldName, + value: fieldValue, + }), + }; + }), + ); + + if (additionalProperties) { + propertiesContent.push({ + $$raw: { additionalProperties }, + description: "", + isRequired: false, + field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any), + }); + } + + return propertiesContent; + }; + + getComplexType = (schema) => { + if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF; + if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF; + if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF; + // TODO :( + if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT; + + return SCHEMA_TYPES.COMPLEX_UNKNOWN; + }; + + /** + * + * @param schema {any} + * @param typeName {null | string} + * @return {Promise>} + */ + parseSchema = async (schema, typeName = null) => { + const schemaParser = this.createSchemaParser(schema, typeName); + return await schemaParser.parse(); + }; + + getInlineParseContent = async (schema, typeName) => { + const parser = this.createSchemaParser(schema, typeName); + return await parser.getInlineContent(); + }; + + getParseContent = async (schema, typeName) => { + const parser = this.createSchemaParser(schema, typeName); + return await parser.getContent(); + }; + + buildTypeNameFromPath = () => { + const schemaPath = _.uniq(_.compact(this.$processingSchemaPath)); + + if (!schemaPath || !schemaPath[0]) return null; + + return internalCase(camelCase(`${schemaPath[0]}_${schemaPath[schemaPath.length - 1]}`)); + }; +} + +module.exports = { + SchemaProcessor, +}; diff --git a/src/schema-parser/schema-routes.js b/src/schema-parser/schema-routes.js index 462322c5..d5068626 100644 --- a/src/schema-parser/schema-routes.js +++ b/src/schema-parser/schema-routes.js @@ -25,7 +25,7 @@ class SchemaRoutes { */ config; /** - * @type {SchemaParser} + * @type {SchemaProcessor} */ schemaParser; /** @@ -33,7 +33,7 @@ class SchemaRoutes { */ schemaUtils; /** - * @type {TypeName} + * @type {TypeNameFormatter} */ typeName; /** diff --git a/src/type-name.js b/src/type-name-formatter.js similarity index 98% rename from src/type-name.js rename to src/type-name-formatter.js index 373e33b4..dbc28c7a 100644 --- a/src/type-name.js +++ b/src/type-name-formatter.js @@ -4,7 +4,7 @@ const _ = require("lodash"); * @typedef {"enum-key" | "type-name"} FormattingSchemaType */ -class TypeName { +class TypeNameFormatter { /** @type {Map} */ formattedModelNamesMap = new Map(); @@ -94,5 +94,5 @@ class TypeName { } module.exports = { - TypeName, + TypeNameFormatter, }; diff --git a/tests/helpers/assertGeneratedModule.js b/tests/helpers/assertGeneratedModule.js index 2ac17389..f94d59a4 100644 --- a/tests/helpers/assertGeneratedModule.js +++ b/tests/helpers/assertGeneratedModule.js @@ -1,5 +1,6 @@ const fs = require("fs"); const gitDiff = require("git-diff"); +const _ = require("lodash"); const assertGeneratedModule = (pathToModule1, pathToModule2) => { if (process.env.UPDATE_SNAPSHOTS) { @@ -9,14 +10,88 @@ const assertGeneratedModule = (pathToModule1, pathToModule2) => { const output = fs.readFileSync(pathToModule1).toString("utf8"); const expected = fs.readFileSync(pathToModule2).toString("utf8"); - const diff = gitDiff(output, expected, { + const diff = gitDiff(expected, output, { color: true, flags: "--diff-algorithm=default --ignore-space-at-eol --ignore-cr-at-eol --ignore-space-change --ignore-all-space", }); if (diff && diff.length) { - console.log("\n" + diff); + const minusLinePrefix1 = "-"; + const minusLinePrefix2 = "-"; + const plusLinePrefix1 = "+"; + const plusLinePrefix2 = "+"; + const plusLinePrefix3 = "+"; + const lines = diff.split("\n"); + const lineStructs = []; + let deletedLines = 0; + let addedLines = 0; + const printPos = (pos) => { + const fills = lines.length.toString().length; + return `${pos + 1}`.padStart(fills, "0") + ": "; + }; + for (let i = 0; i < lines.length; i++) { + const line = lines[i]; + if (line.startsWith(minusLinePrefix1) || line.startsWith(minusLinePrefix2)) { + lineStructs.push({ + pos: i, + id: Math.random().toString() + i, + deleted: true, + line: `${printPos(i + addedLines)}${line}`, + }); + ++deletedLines; + } else if ( + line.startsWith(plusLinePrefix1) || + line.startsWith(plusLinePrefix2) || + line.startsWith(plusLinePrefix3) + ) { + lineStructs.push({ + pos: i, + id: Math.random().toString() + i, + added: true, + line: `${printPos(i - deletedLines)}${line}`, + }); + ++addedLines; + } else { + lineStructs.push({ + pos: i, + id: Math.random().toString() + i, + line: `${printPos(i - deletedLines)}${line}`, + }); + addedLines = 0; + deletedLines = 0; + } + } + + const computedLines = []; + for (let i = 0; i < lineStructs.length; i++) { + const lineStruct = lineStructs[i]; + if (lineStruct.deleted) { + const sliced = lineStructs.slice(i - 1, i + 1); + computedLines.push(...sliced); + } else if (lineStruct.added) { + const sliced = lineStructs.slice(i, i + 1 + 1); + computedLines.push(...sliced); + } + } + + const sortedLines = _.sortBy(_.uniqBy(computedLines, "id"), "pos"); + const maxLine = (sortedLines.map((v) => v.line).sort((a, b) => b.length - a.length)[0] || "").length; + const fixedLines = sortedLines.reduce((acc, computedLine, i, arr) => { + const prev = arr[i - 1]; + if ((prev && computedLine.pos - prev.pos > 10) || !i) { + acc.push("".padEnd(maxLine, "-")); + } + acc.push(computedLine.line); + if (arr.length - 1 === i) { + acc.push("".padEnd(maxLine, "-")); + } + return acc; + }, []); + console.log("\n"); + fixedLines.forEach((line) => { + console.log(line); + }); console.error(new Error("expected another output").stack); process.exit(1); } diff --git a/tests/spec/extract-enums/schema.ts b/tests/spec/extract-enums/schema.ts index f11d6b72..7338168b 100644 --- a/tests/spec/extract-enums/schema.ts +++ b/tests/spec/extract-enums/schema.ts @@ -21,10 +21,10 @@ export enum TypeNamePrefixEnumRootTypeNameSuffix { export interface TypeNamePrefixTreeTypeNameSuffix { tree?: { - mode?: TypeNamePrefixEnumRootModeTypeNameSuffix; - "mode-num"?: TypeNamePrefixEnumRootModeNumTypeNameSuffix; - type?: TypeNamePrefixEnumRootTypeTypeNameSuffix; - bereke?: TypeNamePrefixEnumRootBerekeTypeNameSuffix; + mode?: TypeNamePrefixTreeModeTypeNameSuffix; + "mode-num"?: TypeNamePrefixTreeModeNumTypeNameSuffix; + type?: TypeNamePrefixTreeTypeTypeNameSuffix; + bereke?: TypeNamePrefixTreeBerekeTypeNameSuffix; }[]; } @@ -87,7 +87,7 @@ export enum TypeNamePrefixSomeInterestEnumTypeNameSuffix { EnumKeyPrefix_HSDFDS_EnumKeySuffix = "HSDFDS", } -export enum TypeNamePrefixEnumRootModeTypeNameSuffix { +export enum TypeNamePrefixTreeModeTypeNameSuffix { EnumKeyPrefixInvalidKey100644EnumKeySuffix = "100644", EnumKeyPrefixInvalidKey100755EnumKeySuffix = "100755", EnumKeyPrefixInvalidKey040000EnumKeySuffix = "040000", @@ -95,7 +95,7 @@ export enum TypeNamePrefixEnumRootModeTypeNameSuffix { EnumKeyPrefixInvalidKey120000EnumKeySuffix = "120000", } -export enum TypeNamePrefixEnumRootModeNumTypeNameSuffix { +export enum TypeNamePrefixTreeModeNumTypeNameSuffix { EnumKeyPrefixInvalidKey100644EnumKeySuffix = 100644, EnumKeyPrefixInvalidKey100755EnumKeySuffix = 100755, EnumKeyPrefixInvalidKey40000EnumKeySuffix = 40000, @@ -103,13 +103,13 @@ export enum TypeNamePrefixEnumRootModeNumTypeNameSuffix { EnumKeyPrefixInvalidKey120000EnumKeySuffix = 120000, } -export enum TypeNamePrefixEnumRootTypeTypeNameSuffix { +export enum TypeNamePrefixTreeTypeTypeNameSuffix { EnumKeyPrefixBlobEnumKeySuffix = "blob", EnumKeyPrefixTreeEnumKeySuffix = "tree", EnumKeyPrefixCommitEnumKeySuffix = "commit", } -export enum TypeNamePrefixEnumRootBerekeTypeNameSuffix { +export enum TypeNamePrefixTreeBerekeTypeNameSuffix { EnumKeyPrefixBlaEnumKeySuffix = "Bla", EnumKeyPrefixBlablaEnumKeySuffix = "Blabla", EnumKeyPrefixBoilerEnumKeySuffix = "Boiler", From c534cdef8361fd959342ce00bf606bb9cf8d6a10 Mon Sep 17 00:00:00 2001 From: js2me Date: Mon, 14 Nov 2022 13:30:23 +0600 Subject: [PATCH 6/9] feat: remove type array from primitiveTypes --- src/configuration.js | 4 - src/schema-parser/schema-parser.js | 226 +++++++++++--------------- src/schema-parser/schema-processor.js | 110 +------------ src/schema-parser/schema-routes.js | 6 +- src/schema-parser/schema-utils.js | 63 ++++++- 5 files changed, 163 insertions(+), 246 deletions(-) diff --git a/src/configuration.js b/src/configuration.js index f52be2e9..2591a5b4 100644 --- a/src/configuration.js +++ b/src/configuration.js @@ -294,10 +294,6 @@ class CodeGenConfig { "relative-json-pointer": () => this.Ts.Keyword.String, regex: () => this.Ts.Keyword.String, }, - array: async ({ items, ...schemaPart }, { createParser, schemaUtils }) => { - const content = await createParser(items).getInlineContent(); - return schemaUtils.safeAddNullToType(schemaPart, this.Ts.ArrayType(content)); - }, }; templateInfos = [ diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index 4274766f..4e228523 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -119,7 +119,6 @@ class SchemaParser { return this.config.Ts.Keyword.Any; }, }; - _baseSchemaParsers = { [SCHEMA_TYPES.ENUM]: async (schema, typeName) => { if (this.config.extractEnums && !typeName) { @@ -145,7 +144,7 @@ class SchemaParser { ).parse(); } - const keyType = await this.getSchemaType(schema); + const keyType = await this.schemaUtils.getSchemaType(schema); const enumNames = this.schemaUtils.getEnumNames(schema); let content = null; @@ -153,10 +152,10 @@ class SchemaParser { if (value === null) { return this.config.Ts.NullValue(value); } - if (keyType === (await this.getSchemaType({ type: "number" }))) { + if (keyType === (await this.schemaUtils.getSchemaType({ type: "number" }))) { return this.config.Ts.NumberValue(value); } - if (keyType === (await this.getSchemaType({ type: "boolean" }))) { + if (keyType === (await this.schemaUtils.getSchemaType({ type: "boolean" }))) { return this.config.Ts.BooleanValue(value); } @@ -220,7 +219,53 @@ class SchemaParser { }; }, [SCHEMA_TYPES.OBJECT]: async (schema, typeName) => { - const contentProperties = await this.getObjectSchemaContent(schema); + const { properties, additionalProperties } = schema || {}; + const contentProperties = []; + + const propertyEntries = _.entries(properties); + + for await (const [name, property] of propertyEntries) { + this.schemaPath.push(name); + const required = this.schemaUtils.isPropertyRequired(name, property, schema); + const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); + const nullable = !!(rawTypeData.nullable || property.nullable); + const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name); + const fieldValue = await this.createParser(property, null, this.schemaPath).getInlineContent(); + const readOnly = property.readOnly; + + this.schemaPath.pop(); + + contentProperties.push({ + ...property, + $$raw: property, + title: property.title, + description: + property.description || + _.compact(_.map(property[this.schemaUtils.getComplexType(property)], "description"))[0] || + rawTypeData.description || + _.compact(_.map(rawTypeData[this.schemaUtils.getComplexType(rawTypeData)], "description"))[0] || + "", + isRequired: required, + isNullable: nullable, + name: fieldName, + value: fieldValue, + field: this.config.Ts.TypeField({ + readonly: readOnly && this.config.addReadonly, + optional: !required, + key: fieldName, + value: fieldValue, + }), + }); + } + + if (additionalProperties) { + contentProperties.push({ + $$raw: { additionalProperties }, + description: "", + isRequired: false, + field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any), + }); + } return { ...(_.isObject(schema) ? schema : {}), @@ -235,7 +280,7 @@ class SchemaParser { }; }, [SCHEMA_TYPES.COMPLEX]: async (schema, typeName) => { - const complexType = this.getComplexType(schema); + const complexType = this.schemaUtils.getComplexType(schema); const simpleSchema = _.omit(_.clone(schema), _.keys(this._complexSchemaParsers)); const complexSchemaContent = await this._complexSchemaParsers[complexType](schema); @@ -253,7 +298,7 @@ class SchemaParser { this.config.Ts.IntersectionType( _.compact([ this.config.Ts.ExpressionGroup(complexSchemaContent), - this.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && + this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES.OBJECT && this.config.Ts.ExpressionGroup( await this.createParser(simpleSchema, null, this.schemaPath).getInlineContent(), ), @@ -261,6 +306,31 @@ class SchemaParser { ) || this.config.Ts.Keyword.Any, }; }, + [SCHEMA_TYPES.ARRAY]: async (schema, typeName) => { + let contentType; + const { type, description, items } = schema || {}; + + if (_.isArray(items) && type === SCHEMA_TYPES.ARRAY) { + const tupleContent = await Promise.all( + items.map((item) => this.createParser(item, null, this.schemaPath).getInlineContent()), + ); + contentType = this.config.Ts.Tuple(tupleContent); + } else { + const content = await this.createParser(items, null, this.schemaPath).getInlineContent(); + contentType = this.config.Ts.ArrayType(content); + } + + return { + ...(_.isObject(schema) ? schema : {}), + $parsedSchema: true, + schemaType: SCHEMA_TYPES.PRIMITIVE, + type: SCHEMA_TYPES.PRIMITIVE, + typeIdentifier: this.config.Ts.Keyword.Type, + name: typeName, + description: this.schemaFormatters.formatDescription(description), + content: this.schemaUtils.safeAddNullToType(schema, contentType), + }; + }, [SCHEMA_TYPES.PRIMITIVE]: async (schema, typeName) => { let contentType = null; const { additionalProperties, type, description, items } = schema || {}; @@ -294,119 +364,18 @@ class SchemaParser { name: typeName, description: this.schemaFormatters.formatDescription(description), // TODO: probably it should be refactored. `type === 'null'` is not flexible - content: type === this.config.Ts.Keyword.Null ? type : contentType || (await this.getSchemaType(schema)), + content: + type === this.config.Ts.Keyword.Null ? type : contentType || (await this.schemaUtils.getSchemaType(schema)), }; }, }; - getInternalSchemaType = (schema) => { - if (!_.isEmpty(schema.enum) || !_.isEmpty(this.schemaUtils.getEnumNames(schema))) return SCHEMA_TYPES.ENUM; - if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES.COMPLEX; - if (!_.isEmpty(schema.properties)) return SCHEMA_TYPES.OBJECT; - - return SCHEMA_TYPES.PRIMITIVE; - }; - - getSchemaType = async (schema) => { - if (!schema) return this.config.Ts.Keyword.Any; - - const refTypeInfo = this.schemaUtils.getSchemaRefType(schema); - - if (refTypeInfo) { - return this.schemaUtils.checkAndAddRequiredKeys( - schema, - this.schemaUtils.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)), - ); - } - - const primitiveType = this.schemaUtils.getSchemaPrimitiveType(schema); - - if (primitiveType == null) return this.config.Ts.Keyword.Any; - - let resultType; - - /** - * @type {string | (() => Promise)} - */ - const typeAlias = - _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || - _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || - this.config.primitiveTypes[primitiveType]; - - if (_.isFunction(typeAlias)) { - resultType = await typeAlias(schema, { - createParser: (schema, typeName) => this.createParser(schema, typeName, this.schemaPath), - schemaUtils: this.schemaUtils, - }); - } else { - resultType = typeAlias || primitiveType; - } - - if (!resultType) return this.config.Ts.Keyword.Any; - - return this.schemaUtils.checkAndAddRequiredKeys(schema, this.schemaUtils.safeAddNullToType(schema, resultType)); - }; - - getObjectSchemaContent = async (schema) => { - const { properties, additionalProperties } = schema || {}; - const propertiesContent = []; - - const propertyEntries = _.entries(properties); - - for await (const [name, property] of propertyEntries) { - this.schemaPath.push(name); - const required = this.schemaUtils.isPropertyRequired(name, property, schema); - const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); - const nullable = !!(rawTypeData.nullable || property.nullable); - const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name); - const fieldValue = await this.createParser(property, null, this.schemaPath).getInlineContent(); - const readOnly = property.readOnly; - - this.schemaPath.pop(); - - propertiesContent.push({ - ...property, - $$raw: property, - title: property.title, - description: - property.description || - _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || - rawTypeData.description || - _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || - "", - isRequired: required, - isNullable: nullable, - name: fieldName, - value: fieldValue, - field: this.config.Ts.TypeField({ - readonly: readOnly && this.config.addReadonly, - optional: !required, - key: fieldName, - value: fieldValue, - }), - }); - } - - if (additionalProperties) { - propertiesContent.push({ - $$raw: { additionalProperties }, - description: "", - isRequired: false, - field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any), - }); - } - - return propertiesContent; - }; + buildTypeNameFromPath = () => { + const schemaPath = _.uniq(_.compact(this.schemaPath)); - getComplexType = (schema) => { - if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF; - if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF; - if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF; - // TODO :( - if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT; + if (!schemaPath || !schemaPath[0]) return null; - return SCHEMA_TYPES.COMPLEX_UNKNOWN; + return internalCase(camelCase(`${schemaPath[0]}_${schemaPath[schemaPath.length - 1]}`)); }; /** @@ -428,13 +397,13 @@ class SchemaParser { if (!this.schema.$parsed) { if (!this.typeName && this.schemaUtils.isRefSchema(this.schema)) { - this.typeName = await this.getSchemaType(this.schema); + this.typeName = await this.schemaUtils.getSchemaType(this.schema); } if (this.schema.items && !Array.isArray(this.schema.items) && !this.schema.type) { this.schema.type = SCHEMA_TYPES.ARRAY; } - schemaType = this.getInternalSchemaType(this.schema); + schemaType = this.schemaUtils.getInternalSchemaType(this.schema); this.schemaPath.push(this.typeName); @@ -448,24 +417,23 @@ class SchemaParser { return this.schema.$parsed; }; - getInlineContent = async () => { + /** + * @param cfg {{ formatType?: "base" | "inline", schemaType?: string } } + * @return {Promise>} + */ + format = async (cfg) => { const parsedSchema = await this.parse(); - const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "inline" }); - return formattedSchema.content; + return await this.schemaFormatters.formatSchema(parsedSchema, cfg); }; - getContent = async () => { - const parsedSchema = await this.parse(); - const formattedSchema = await this.schemaFormatters.formatSchema(parsedSchema, { formatType: "base" }); - return formattedSchema.content; + getInlineContent = async () => { + const schema = await this.format({ formatType: "inline" }); + return schema.content; }; - buildTypeNameFromPath = () => { - const schemaPath = _.uniq(_.compact(this.schemaPath)); - - if (!schemaPath || !schemaPath[0]) return null; - - return internalCase(camelCase(`${schemaPath[0]}_${schemaPath[schemaPath.length - 1]}`)); + getContent = async () => { + const schema = await this.format({ formatType: "base" }); + return schema.content; }; /** diff --git a/src/schema-parser/schema-processor.js b/src/schema-parser/schema-processor.js index 0acb7dfd..23a95937 100644 --- a/src/schema-parser/schema-processor.js +++ b/src/schema-parser/schema-processor.js @@ -31,8 +31,6 @@ class SchemaProcessor { */ schemaUtils; - $processingSchemaPath = []; - /** * @type {((schema, typeName) => SchemaParser)} */ @@ -43,7 +41,7 @@ class SchemaProcessor { this.schemaComponentsMap = schemaComponentsMap; this.typeNameFormatter = typeNameFormatter; this.schemaFormatters = new SchemaFormatters(config, logger, this, templates); - this.schemaUtils = new SchemaUtils(config, schemaComponentsMap); + this.schemaUtils = new SchemaUtils(config, schemaComponentsMap, typeNameFormatter); this.createSchemaParser = SchemaParser.create.bind( null, config, @@ -54,104 +52,6 @@ class SchemaProcessor { ); } - getSchemaType = async (schema) => { - if (!schema) return this.config.Ts.Keyword.Any; - - const refTypeInfo = this.schemaUtils.getSchemaRefType(schema); - - if (refTypeInfo) { - return this.schemaUtils.checkAndAddRequiredKeys( - schema, - this.schemaUtils.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)), - ); - } - - const primitiveType = this.schemaUtils.getSchemaPrimitiveType(schema); - - if (primitiveType == null) return this.config.Ts.Keyword.Any; - - let resultType; - - /** - * @type {string | (() => Promise)} - */ - const typeAlias = - _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || - _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || - this.config.primitiveTypes[primitiveType]; - - if (_.isFunction(typeAlias)) { - resultType = await typeAlias(schema, this); - } else { - resultType = typeAlias || primitiveType; - } - - if (!resultType) return this.config.Ts.Keyword.Any; - - return this.schemaUtils.checkAndAddRequiredKeys(schema, this.schemaUtils.safeAddNullToType(schema, resultType)); - }; - - getObjectSchemaContent = async (schema) => { - const { properties, additionalProperties } = schema || {}; - - const propertiesContent = await Promise.all( - _.map(properties, async (property, name) => { - this.$processingSchemaPath.push(name); - const required = this.schemaUtils.isPropertyRequired(name, property, schema); - const rawTypeData = _.get(this.schemaUtils.getSchemaRefType(property), "rawTypeData", {}); - const nullable = !!(rawTypeData.nullable || property.nullable); - const fieldName = this.typeNameFormatter.isValidName(name) ? name : this.config.Ts.StringValue(name); - const fieldValue = await this.getInlineParseContent(property); - const readOnly = property.readOnly; - - this.$processingSchemaPath.pop(); - - return { - ...property, - $$raw: property, - title: property.title, - description: - property.description || - _.compact(_.map(property[this.getComplexType(property)], "description"))[0] || - rawTypeData.description || - _.compact(_.map(rawTypeData[this.getComplexType(rawTypeData)], "description"))[0] || - "", - isRequired: required, - isNullable: nullable, - name: fieldName, - value: fieldValue, - field: this.config.Ts.TypeField({ - readonly: readOnly && this.config.addReadonly, - optional: !required, - key: fieldName, - value: fieldValue, - }), - }; - }), - ); - - if (additionalProperties) { - propertiesContent.push({ - $$raw: { additionalProperties }, - description: "", - isRequired: false, - field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any), - }); - } - - return propertiesContent; - }; - - getComplexType = (schema) => { - if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF; - if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF; - if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF; - // TODO :( - if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT; - - return SCHEMA_TYPES.COMPLEX_UNKNOWN; - }; - /** * * @param schema {any} @@ -172,14 +72,6 @@ class SchemaProcessor { const parser = this.createSchemaParser(schema, typeName); return await parser.getContent(); }; - - buildTypeNameFromPath = () => { - const schemaPath = _.uniq(_.compact(this.$processingSchemaPath)); - - if (!schemaPath || !schemaPath[0]) return null; - - return internalCase(camelCase(`${schemaPath[0]}_${schemaPath[schemaPath.length - 1]}`)); - }; } module.exports = { diff --git a/src/schema-parser/schema-routes.js b/src/schema-parser/schema-routes.js index d5068626..d91e1aca 100644 --- a/src/schema-parser/schema-routes.js +++ b/src/schema-parser/schema-routes.js @@ -68,8 +68,8 @@ class SchemaRoutes { async init() { this.FORM_DATA_TYPES = _.uniq([ - await this.schemaParser.getSchemaType({ type: "string", format: "file" }), - await this.schemaParser.getSchemaType({ type: "string", format: "binary" }), + await this.schemaUtils.getSchemaType({ type: "string", format: "file" }), + await this.schemaUtils.getSchemaType({ type: "string", format: "binary" }), ]); } @@ -411,7 +411,7 @@ class SchemaRoutes { const headerTypes = Object.fromEntries( await Promise.all( Object.entries(src).map(async ([k, v]) => { - return [k, await this.schemaParser.getSchemaType(v)]; + return [k, await this.schemaUtils.getSchemaType(v)]; }), ), ); diff --git a/src/schema-parser/schema-utils.js b/src/schema-parser/schema-utils.js index 97bdd1a7..787cc63a 100644 --- a/src/schema-parser/schema-utils.js +++ b/src/schema-parser/schema-utils.js @@ -12,10 +12,15 @@ class SchemaUtils { * @type {SchemaComponentsMap} */ schemaComponentsMap; + /** + * @type {TypeNameFormatter} + */ + typeNameFormatter; - constructor(config, schemaComponentsMap) { + constructor(config, schemaComponentsMap, typeNameFormatter) { this.config = config; this.schemaComponentsMap = schemaComponentsMap; + this.typeNameFormatter = typeNameFormatter; } getRequiredProperties = (schema) => { @@ -141,6 +146,62 @@ class SchemaUtils { return childSchema; }; + getComplexType = (schema) => { + if (schema.oneOf) return SCHEMA_TYPES.COMPLEX_ONE_OF; + if (schema.allOf) return SCHEMA_TYPES.COMPLEX_ALL_OF; + if (schema.anyOf) return SCHEMA_TYPES.COMPLEX_ANY_OF; + // TODO :( + if (schema.not) return SCHEMA_TYPES.COMPLEX_NOT; + + return SCHEMA_TYPES.COMPLEX_UNKNOWN; + }; + + getInternalSchemaType = (schema) => { + if (!_.isEmpty(schema.enum) || !_.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES.ENUM; + if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES.COMPLEX; + if (!_.isEmpty(schema.properties)) return SCHEMA_TYPES.OBJECT; + if (schema.type === SCHEMA_TYPES.ARRAY) return SCHEMA_TYPES.ARRAY; + + return SCHEMA_TYPES.PRIMITIVE; + }; + + getSchemaType = async (schema) => { + if (!schema) return this.config.Ts.Keyword.Any; + + const refTypeInfo = this.getSchemaRefType(schema); + + if (refTypeInfo) { + return this.checkAndAddRequiredKeys( + schema, + this.safeAddNullToType(schema, this.typeNameFormatter.format(refTypeInfo.typeName)), + ); + } + + const primitiveType = this.getSchemaPrimitiveType(schema); + + if (primitiveType == null) return this.config.Ts.Keyword.Any; + + let resultType; + + /** + * @type {string | (() => Promise)} + */ + const typeAlias = + _.get(this.config.primitiveTypes, [primitiveType, schema.format]) || + _.get(this.config.primitiveTypes, [primitiveType, "$default"]) || + this.config.primitiveTypes[primitiveType]; + + if (_.isFunction(typeAlias)) { + resultType = await typeAlias(schema, this); + } else { + resultType = typeAlias || primitiveType; + } + + if (!resultType) return this.config.Ts.Keyword.Any; + + return this.checkAndAddRequiredKeys(schema, this.safeAddNullToType(schema, resultType)); + }; + filterSchemaContents = (contents, filterFn) => { return _.uniq(_.filter(contents, (type) => filterFn(type))); }; From 1721daa1b4e4f0105476aca7fd7c458e5e6f97f5 Mon Sep 17 00:00:00 2001 From: js2me Date: Mon, 14 Nov 2022 16:15:09 +0600 Subject: [PATCH 7/9] chore: experimental version --- package.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/package.json b/package.json index 8d935e29..e4d1b6e8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "swagger-typescript-api", - "version": "12.0.1", + "version": "13.0.0-experimental-1", "description": "Generate typescript/javascript api from swagger schema", "scripts": { "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts", @@ -14,7 +14,6 @@ "test-all-extended": "node --unhandled-rejections=strict ./scriptsRunner.js generate-extended validate generate validate test:*", "test-specific": "node ./scriptsRunner.js generate validate test:*", "test-specific-only": "node ./scriptsRunner.js test:*", - "prepare": "npm run test-all-extended", "generate": "node tests/generate.js", "generate-extended": "node tests/generate-extended.js", "generate:debug": "node --nolazy tests/generate.js", From 13c9c4b88bffab9539a001020912fb9f733f0716 Mon Sep 17 00:00:00 2001 From: js2me Date: Tue, 15 Nov 2022 18:23:36 +0600 Subject: [PATCH 8/9] fix: merge conflicts; fix: try to fix problem with discriminator --- src/schema-parser/schema-parser.js | 89 +++++++++++---------- src/schema-parser/schema-processor.js | 12 +-- src/schema-parser/schema-utils.js | 1 + tests/spec/discriminator/schema.ts | 8 +- tests/spec/extract-enums/expected.ts | 110 +++++++++++++------------- tests/spec/extract-enums/schema.ts | 110 +++++++++++++------------- tests/spec/extract-enums/test.js | 1 + 7 files changed, 171 insertions(+), 160 deletions(-) diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index bcacac38..c6da19fc 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -2,7 +2,7 @@ const { SchemaFormatters } = require("./schema-formatters"); const { SchemaUtils } = require("./schema-utils"); const { SCHEMA_TYPES } = require("../constants"); const _ = require("lodash"); -const { internalCase } = require("../util/internal-case"); +const { pascalCase } = require("../util/pascal-case"); const { camelCase } = require("lodash"); class SchemaParser { @@ -372,14 +372,16 @@ class SchemaParser { type === this.config.Ts.Keyword.Null ? type : contentType || (await this.schemaUtils.getSchemaType(schema)), }; }, - [SCHEMA_TYPES.DISCRIMINATOR]: (schema, typeName) => { + [SCHEMA_TYPES.DISCRIMINATOR]: async (schema, typeName) => { const { discriminator, ...noDiscriminatorSchema } = schema; - if (typeName == null || !discriminator.mapping) return this.parseSchema(noDiscriminatorSchema, typeName); + if (typeName == null || !discriminator.mapping) + return await this.createParser(noDiscriminatorSchema, typeName).parse(); const refPath = this.schemaComponentsMap.createRef("schemas", typeName); - const complexSchemaKeys = _.keys(this.complexSchemaParsers); + const complexSchemaKeys = _.keys(this._complexSchemaParsers); const abstractSchema = _.omit(_.clone(noDiscriminatorSchema), complexSchemaKeys); + const discMappingEntries = _.entries(discriminator.mapping); const discTypeName = this.config.componentTypeNameResolver.resolve([ pascalCase(`Abstract ${typeName}`), pascalCase(`Discriminator ${typeName}`), @@ -393,48 +395,51 @@ class SchemaParser { ...abstractSchema, internal: true, }); - const complexType = this.getComplexType(schema); + const complexType = this.schemaUtils.getComplexType(schema); + + const discMappingStructs = []; - const abstractSchemaContent = !abstractSchemaIsEmpty && this.getInlineParseContent(abstractComponent); + const abstractSchemaContent = + !abstractSchemaIsEmpty && (await this.createParser(abstractComponent).getInlineContent()); const complexSchemaContent = complexType !== SCHEMA_TYPES.COMPLEX_UNKNOWN - ? this.config.Ts.ExpressionGroup(this.complexSchemaParsers[complexType](schema)) + ? this.config.Ts.ExpressionGroup(await this._complexSchemaParsers[complexType](schema)) : null; - const discriminatorSchemaContent = - discriminator.mapping && - this.config.Ts.ExpressionGroup( - this.config.Ts.UnionType( - _.map(discriminator.mapping, (schema, key) => { - const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema; - if (mappingSchema.$ref) { - const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData; - if (mappingRefSchema) { - complexSchemaKeys.forEach((schemaKey) => { - if (_.isArray(mappingRefSchema[schemaKey])) { - mappingRefSchema[schemaKey] = mappingRefSchema[schemaKey].map((schema) => { - if (schema.$ref === refPath) { - return { ...schema, $ref: abstractComponent.$ref }; - } - return schema; - }); - } - }); - } + + for await (const [key, schema] of discMappingEntries) { + const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema; + if (mappingSchema.$ref) { + const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData; + if (mappingRefSchema) { + complexSchemaKeys.forEach((schemaKey) => { + if (_.isArray(mappingRefSchema[schemaKey])) { + mappingRefSchema[schemaKey] = mappingRefSchema[schemaKey].map((schema) => { + if (schema.$ref === refPath) { + return { ...schema, ...abstractComponent, $ref: abstractComponent.$ref }; + } + return schema; + }); } - return this.config.Ts.ExpressionGroup( - this.config.Ts.IntersectionType([ - this.config.Ts.ObjectWrapper( - this.config.Ts.TypeField({ - key: discriminator.propertyName, - value: this.config.Ts.StringValue(key), - }), - ), - this.getInlineParseContent(mappingSchema), - ]), - ); - }), + }); + } + } + + const mappingSchemaContent = await this.createParser(mappingSchema).getInlineContent(); + + discMappingStructs.push( + this.config.Ts.ExpressionGroup( + this.config.Ts.IntersectionType([ + this.config.Ts.ObjectWrapper( + this.config.Ts.TypeField({ + key: discriminator.propertyName, + value: this.config.Ts.StringValue(key), + }), + ), + mappingSchemaContent, + ]), ), ); + } return { ...(_.isObject(schema) ? schema : {}), @@ -445,7 +450,11 @@ class SchemaParser { name: typeName, description: this.schemaFormatters.formatDescription(schema.description), content: this.config.Ts.UnionType( - [abstractSchemaContent, complexSchemaContent, discriminatorSchemaContent].filter(Boolean), + [ + abstractSchemaContent, + complexSchemaContent, + this.config.Ts.ExpressionGroup(this.config.Ts.UnionType(discMappingStructs)), + ].filter(Boolean), ), }; }, diff --git a/src/schema-parser/schema-processor.js b/src/schema-parser/schema-processor.js index 23a95937..4c3f8397 100644 --- a/src/schema-parser/schema-processor.js +++ b/src/schema-parser/schema-processor.js @@ -58,18 +58,18 @@ class SchemaProcessor { * @param typeName {null | string} * @return {Promise>} */ - parseSchema = async (schema, typeName = null) => { - const schemaParser = this.createSchemaParser(schema, typeName); + parseSchema = async (schema, typeName = null, schemaPath = []) => { + const schemaParser = this.createSchemaParser(schema, typeName, schemaPath); return await schemaParser.parse(); }; - getInlineParseContent = async (schema, typeName) => { - const parser = this.createSchemaParser(schema, typeName); + getInlineParseContent = async (schema, typeName, schemaPath) => { + const parser = this.createSchemaParser(schema, typeName, schemaPath); return await parser.getInlineContent(); }; - getParseContent = async (schema, typeName) => { - const parser = this.createSchemaParser(schema, typeName); + getParseContent = async (schema, typeName, schemaPath) => { + const parser = this.createSchemaParser(schema, typeName, schemaPath); return await parser.getContent(); }; } diff --git a/src/schema-parser/schema-utils.js b/src/schema-parser/schema-utils.js index 787cc63a..7274240c 100644 --- a/src/schema-parser/schema-utils.js +++ b/src/schema-parser/schema-utils.js @@ -158,6 +158,7 @@ class SchemaUtils { getInternalSchemaType = (schema) => { if (!_.isEmpty(schema.enum) || !_.isEmpty(this.getEnumNames(schema))) return SCHEMA_TYPES.ENUM; + if (schema.discriminator) return SCHEMA_TYPES.DISCRIMINATOR; if (schema.allOf || schema.oneOf || schema.anyOf || schema.not) return SCHEMA_TYPES.COMPLEX; if (!_.isEmpty(schema.properties)) return SCHEMA_TYPES.OBJECT; if (schema.type === SCHEMA_TYPES.ARRAY) return SCHEMA_TYPES.ARRAY; diff --git a/tests/spec/discriminator/schema.ts b/tests/spec/discriminator/schema.ts index 6dd16d1d..8ba07aaa 100644 --- a/tests/spec/discriminator/schema.ts +++ b/tests/spec/discriminator/schema.ts @@ -31,13 +31,13 @@ export type BlockDTO = } & FileBlockDTO) ); -export type CsvBlockDTO = AbstractBlockDto & { +export type CsvBlockDTO = BlockDTO & { /** @default "csv" */ type: "csv"; text: string; }; -export type FileBlockDTO = AbstractBlockDto & { +export type FileBlockDTO = BlockDTO & { /** @default "file" */ type: "file"; fileId: string; @@ -54,11 +54,11 @@ export type Pet = } & Cat) ); -export type Cat = AbstractPet & { +export type Cat = Pet & { name?: string; }; -export type Dog = AbstractPet & { +export type Dog = Pet & { bark?: string; }; diff --git a/tests/spec/extract-enums/expected.ts b/tests/spec/extract-enums/expected.ts index 77b9b329..c7fda85f 100644 --- a/tests/spec/extract-enums/expected.ts +++ b/tests/spec/extract-enums/expected.ts @@ -9,63 +9,32 @@ * --------------------------------------------------------------- */ -export enum TNPEnumRootTNS { - EKPInvalidKey100644EKS = "100644", - EKPInvalidKey100755EKS = "100755", - EKPInvalidKey040000EKS = "040000", - EKPInvalidKey160000EKS = "160000", - EKPInvalidKey120000EKS = "120000", - EKPTest1EKS = "test1", - EKPTest2EKS = "test2", -} - -export interface TNPTreeTNS { - tree?: { - mode?: TNPTreeModeTNS; - "mode-num"?: TNPTreeModeNumTNS; - type?: TNPTreeTypeTNS; - bereke?: TNPTreeBerekeTNS; - }[]; -} - -export enum TNPOnlyEnumNamesTNS { +/** @format int32 */ +export enum TNPEmptyEnumTNS { EKPBlaEKS = "Bla", EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -export enum TNPStringOnlyEnumNamesTNS { - EKPBlaEKS = "Bla", +/** @format int32 */ +export enum TNPEnumWithMoreNamesTNS { + EKPBlaEKS = 1, EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -export enum TNPStringEnumsTNS { - EKPBlaEKS = "foo", - EKPBlablaEKS = "bar", - EKPBoilerEKS = "Boiler", -} - -export enum TNPStringCompleteEnumsTNS { - EKPBlaEKS = "foo", - EKPBlablaEKS = "bar", - EKPBoilerEKS = "baz", +/** @example "APPROVED" */ +export enum TNPNameSpaceAddSuperDuperTNS { + EKP_NEW_EKS = "NEW", + EKP_PENDING_EKS = "PENDING", } -/** @format int32 */ -export enum TNPEmptyEnumTNS { +export enum TNPOnlyEnumNamesTNS { EKPBlaEKS = "Bla", EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -/** @format int32 */ -export enum TNPEnumWithMoreNamesTNS { - EKPBlaEKS = 1, - EKPBlablaEKS = "Blabla", - EKPBoilerEKS = "Boiler", -} - /** @format int32 */ export enum TNPSomeInterestEnumTNS { EKPBlaEKS = 6, @@ -87,6 +56,24 @@ export enum TNPSomeInterestEnumTNS { EKP_HSDFDS_EKS = "HSDFDS", } +export enum TNPStringCompleteEnumsTNS { + EKPBlaEKS = "foo", + EKPBlablaEKS = "bar", + EKPBoilerEKS = "baz", +} + +export enum TNPStringEnumsTNS { + EKPBlaEKS = "foo", + EKPBlablaEKS = "bar", + EKPBoilerEKS = "Boiler", +} + +export enum TNPStringOnlyEnumNamesTNS { + EKPBlaEKS = "Bla", + EKPBlablaEKS = "Blabla", + EKPBoilerEKS = "Boiler", +} + export interface TNPSuperDuperStructDTOTNS { /** @example "100" */ id: number; @@ -94,6 +81,18 @@ export interface TNPSuperDuperStructDTOTNS { state: TNPSuperDuperStructDtoStateTNS; } +/** @example "APPROVED" */ +export enum TNPSuperDuperStructDtoStateTNS { + EKP_NEW_EKS = "NEW", + EKP_PENDING_EKS = "PENDING", +} + +export enum TNPTreeBerekeTNS { + EKPBlaEKS = "Bla", + EKPBlablaEKS = "Blabla", + EKPBoilerEKS = "Boiler", +} + export enum TNPTreeModeTNS { EKPInvalidKey100644EKS = "100644", EKPInvalidKey100755EKS = "100755", @@ -116,20 +115,21 @@ export enum TNPTreeTypeTNS { EKPCommitEKS = "commit", } -export enum TNPTreeBerekeTNS { - EKPBlaEKS = "Bla", - EKPBlablaEKS = "Blabla", - EKPBoilerEKS = "Boiler", -} - -/** @example "APPROVED" */ -export enum TNPSuperDuperStructDtoStateTNS { - EKP_NEW_EKS = "NEW", - EKP_PENDING_EKS = "PENDING", +export enum TNPEnumRootTNS { + EKPInvalidKey100644EKS = "100644", + EKPInvalidKey100755EKS = "100755", + EKPInvalidKey040000EKS = "040000", + EKPInvalidKey160000EKS = "160000", + EKPInvalidKey120000EKS = "120000", + EKPTest1EKS = "test1", + EKPTest2EKS = "test2", } -/** @example "APPROVED" */ -export enum TNPNameSpaceAddSuperDuperTNS { - EKP_NEW_EKS = "NEW", - EKP_PENDING_EKS = "PENDING", +export interface TNPTreeTNS { + tree?: { + mode?: TNPTreeModeTNS; + "mode-num"?: TNPTreeModeNumTNS; + type?: TNPTreeTypeTNS; + bereke?: TNPTreeBerekeTNS; + }[]; } diff --git a/tests/spec/extract-enums/schema.ts b/tests/spec/extract-enums/schema.ts index 77b9b329..c7fda85f 100644 --- a/tests/spec/extract-enums/schema.ts +++ b/tests/spec/extract-enums/schema.ts @@ -9,63 +9,32 @@ * --------------------------------------------------------------- */ -export enum TNPEnumRootTNS { - EKPInvalidKey100644EKS = "100644", - EKPInvalidKey100755EKS = "100755", - EKPInvalidKey040000EKS = "040000", - EKPInvalidKey160000EKS = "160000", - EKPInvalidKey120000EKS = "120000", - EKPTest1EKS = "test1", - EKPTest2EKS = "test2", -} - -export interface TNPTreeTNS { - tree?: { - mode?: TNPTreeModeTNS; - "mode-num"?: TNPTreeModeNumTNS; - type?: TNPTreeTypeTNS; - bereke?: TNPTreeBerekeTNS; - }[]; -} - -export enum TNPOnlyEnumNamesTNS { +/** @format int32 */ +export enum TNPEmptyEnumTNS { EKPBlaEKS = "Bla", EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -export enum TNPStringOnlyEnumNamesTNS { - EKPBlaEKS = "Bla", +/** @format int32 */ +export enum TNPEnumWithMoreNamesTNS { + EKPBlaEKS = 1, EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -export enum TNPStringEnumsTNS { - EKPBlaEKS = "foo", - EKPBlablaEKS = "bar", - EKPBoilerEKS = "Boiler", -} - -export enum TNPStringCompleteEnumsTNS { - EKPBlaEKS = "foo", - EKPBlablaEKS = "bar", - EKPBoilerEKS = "baz", +/** @example "APPROVED" */ +export enum TNPNameSpaceAddSuperDuperTNS { + EKP_NEW_EKS = "NEW", + EKP_PENDING_EKS = "PENDING", } -/** @format int32 */ -export enum TNPEmptyEnumTNS { +export enum TNPOnlyEnumNamesTNS { EKPBlaEKS = "Bla", EKPBlablaEKS = "Blabla", EKPBoilerEKS = "Boiler", } -/** @format int32 */ -export enum TNPEnumWithMoreNamesTNS { - EKPBlaEKS = 1, - EKPBlablaEKS = "Blabla", - EKPBoilerEKS = "Boiler", -} - /** @format int32 */ export enum TNPSomeInterestEnumTNS { EKPBlaEKS = 6, @@ -87,6 +56,24 @@ export enum TNPSomeInterestEnumTNS { EKP_HSDFDS_EKS = "HSDFDS", } +export enum TNPStringCompleteEnumsTNS { + EKPBlaEKS = "foo", + EKPBlablaEKS = "bar", + EKPBoilerEKS = "baz", +} + +export enum TNPStringEnumsTNS { + EKPBlaEKS = "foo", + EKPBlablaEKS = "bar", + EKPBoilerEKS = "Boiler", +} + +export enum TNPStringOnlyEnumNamesTNS { + EKPBlaEKS = "Bla", + EKPBlablaEKS = "Blabla", + EKPBoilerEKS = "Boiler", +} + export interface TNPSuperDuperStructDTOTNS { /** @example "100" */ id: number; @@ -94,6 +81,18 @@ export interface TNPSuperDuperStructDTOTNS { state: TNPSuperDuperStructDtoStateTNS; } +/** @example "APPROVED" */ +export enum TNPSuperDuperStructDtoStateTNS { + EKP_NEW_EKS = "NEW", + EKP_PENDING_EKS = "PENDING", +} + +export enum TNPTreeBerekeTNS { + EKPBlaEKS = "Bla", + EKPBlablaEKS = "Blabla", + EKPBoilerEKS = "Boiler", +} + export enum TNPTreeModeTNS { EKPInvalidKey100644EKS = "100644", EKPInvalidKey100755EKS = "100755", @@ -116,20 +115,21 @@ export enum TNPTreeTypeTNS { EKPCommitEKS = "commit", } -export enum TNPTreeBerekeTNS { - EKPBlaEKS = "Bla", - EKPBlablaEKS = "Blabla", - EKPBoilerEKS = "Boiler", -} - -/** @example "APPROVED" */ -export enum TNPSuperDuperStructDtoStateTNS { - EKP_NEW_EKS = "NEW", - EKP_PENDING_EKS = "PENDING", +export enum TNPEnumRootTNS { + EKPInvalidKey100644EKS = "100644", + EKPInvalidKey100755EKS = "100755", + EKPInvalidKey040000EKS = "040000", + EKPInvalidKey160000EKS = "160000", + EKPInvalidKey120000EKS = "120000", + EKPTest1EKS = "test1", + EKPTest2EKS = "test2", } -/** @example "APPROVED" */ -export enum TNPNameSpaceAddSuperDuperTNS { - EKP_NEW_EKS = "NEW", - EKP_PENDING_EKS = "PENDING", +export interface TNPTreeTNS { + tree?: { + mode?: TNPTreeModeTNS; + "mode-num"?: TNPTreeModeNumTNS; + type?: TNPTreeTypeTNS; + bereke?: TNPTreeBerekeTNS; + }[]; } diff --git a/tests/spec/extract-enums/test.js b/tests/spec/extract-enums/test.js index 134178b6..82675ddb 100644 --- a/tests/spec/extract-enums/test.js +++ b/tests/spec/extract-enums/test.js @@ -20,6 +20,7 @@ schemas.forEach(({ absolutePath, apiFileName }) => { enumKeySuffix: "EKS", typePrefix: "TNP", typeSuffix: "TNS", + sortTypes: true, }).then(() => { validateGeneratedModule(resolve(__dirname, `./${apiFileName}`)); assertGeneratedModule(resolve(__dirname, `./${apiFileName}`), resolve(__dirname, `./expected.ts`)); From 5718d7236efda69a1e9370f4777864d8a021e318 Mon Sep 17 00:00:00 2001 From: js2me Date: Wed, 16 Nov 2022 17:30:54 +0600 Subject: [PATCH 9/9] fix: merge conflicts --- src/code-gen-process.js | 52 +++++++++++- src/schema-parser/schema-parser.js | 81 ------------------- .../schema-parsers/discriminator.js | 62 +++++++------- 3 files changed, 82 insertions(+), 113 deletions(-) diff --git a/src/code-gen-process.js b/src/code-gen-process.js index dbaca25c..38bb74fd 100644 --- a/src/code-gen-process.js +++ b/src/code-gen-process.js @@ -153,9 +153,7 @@ class CodeGenProcess { return schemas; }; - const modelTypes = (await Promise.all(_.map(sortSchemas(usageComponentSchemas), this.prepareModelType))).filter( - Boolean, - ); + const modelTypes = await this.collectModelTypes(usageComponentSchemas); const rawConfiguration = { apiConfig: this.createApiConfig(swagger.usageSchema), @@ -231,6 +229,54 @@ class CodeGenProcess { }; } + collectModelTypes = async (componentSchemas) => { + const modelTypes = []; + + const sortByProperty = (propertyName) => (o1, o2) => { + if (o1[propertyName] > o2[propertyName]) { + return 1; + } + if (o1[propertyName] < o2[propertyName]) { + return -1; + } + return 0; + }; + + const sortSchemas = (schemas) => { + if (this.config.sortTypes) { + return schemas.sort(sortByProperty("typeName")).map((schema) => { + if (schema.rawTypeData?.properties) { + return { + ...schema, + rawTypeData: { + ...schema.rawTypeData, + $parsed: schema.rawTypeData.$parsed && { + ...schema.rawTypeData.$parsed, + content: Array.isArray(schema.rawTypeData.$parsed.content) + ? schema.rawTypeData.$parsed.content.sort(sortByProperty("name")) + : schema.rawTypeData.$parsed.content, + }, + }, + }; + } + return schema; + }); + } + return schemas; + }; + + const sortedComponentSchemas = sortSchemas(componentSchemas); + + for await (const componentSchema of sortedComponentSchemas) { + const modelType = await this.prepareModelType(componentSchema); + if (modelType) { + modelTypes.push(modelType); + } + } + + return modelTypes; + }; + getRenderTemplateData = () => { return { utils: { diff --git a/src/schema-parser/schema-parser.js b/src/schema-parser/schema-parser.js index d114ce09..cd28a03e 100644 --- a/src/schema-parser/schema-parser.js +++ b/src/schema-parser/schema-parser.js @@ -375,88 +375,7 @@ class SchemaParser { }, [SCHEMA_TYPES.DISCRIMINATOR]: async (schema, typeName) => { const schemaParser = new DiscriminatorSchemaParser(this, schema, typeName, this.schemaPath); - return await schemaParser.parse(); - const { discriminator, ...noDiscriminatorSchema } = schema; - - if (typeName == null || !discriminator.mapping) - return await this.createParser(noDiscriminatorSchema, typeName).parse(); - - const refPath = this.schemaComponentsMap.createRef("schemas", typeName); - const complexSchemaKeys = _.keys(this._complexSchemaParsers); - const abstractSchema = _.omit(_.clone(noDiscriminatorSchema), complexSchemaKeys); - const discMappingEntries = _.entries(discriminator.mapping); - const discTypeName = this.config.componentTypeNameResolver.resolve([ - pascalCase(`Abstract ${typeName}`), - pascalCase(`Discriminator ${typeName}`), - pascalCase(`Internal ${typeName}`), - pascalCase(`Polymorph ${typeName}`), - ]); - const abstractSchemaIsEmpty = !_.keys(abstractSchema).length; - const abstractComponent = - !abstractSchemaIsEmpty && - this.schemaComponentsMap.createComponent("schemas", discTypeName, { - ...abstractSchema, - internal: true, - }); - const complexType = this.schemaUtils.getComplexType(schema); - - const discMappingStructs = []; - - const abstractSchemaContent = - !abstractSchemaIsEmpty && (await this.createParser(abstractComponent).getInlineContent()); - const complexSchemaContent = - complexType !== SCHEMA_TYPES.COMPLEX_UNKNOWN - ? this.config.Ts.ExpressionGroup(await this._complexSchemaParsers[complexType](schema)) - : null; - const discriminatorSchemaContent = - discriminator.mapping && - this.config.Ts.ExpressionGroup( - this.config.Ts.UnionType( - _.map(discriminator.mapping, (schema, key) => { - const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema; - if (mappingSchema.$ref) { - const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData; - if (mappingRefSchema) { - complexSchemaKeys.forEach((schemaKey) => { - if (_.isArray(mappingRefSchema[schemaKey])) { - mappingRefSchema[schemaKey] = mappingRefSchema[schemaKey].map((schema) => { - if (schema.$ref === refPath) { - return { ...schema, $ref: abstractComponent.$ref }; - } - return schema; - }); - } - }); - } - } - return this.config.Ts.ExpressionGroup( - this.config.Ts.IntersectionType([ - this.config.Ts.ObjectWrapper( - this.config.Ts.TypeField({ - key: discriminator.propertyName, - value: this.config.Ts.StringValue(key), - }), - ), - this.getInlineParseContent(mappingSchema), - ]), - ); - }), - ), - ); - - return { - ...(_.isObject(schema) ? schema : {}), - $parsedSchema: true, - schemaType: SCHEMA_TYPES.COMPLEX, - type: SCHEMA_TYPES.PRIMITIVE, - typeIdentifier: this.config.Ts.Keyword.Type, - name: typeName, - description: this.schemaFormatters.formatDescription(schema.description), - content: this.config.Ts.UnionType( - [abstractSchemaContent, complexSchemaContent, discriminatorSchemaContent].filter(Boolean), - ), - }; }, }; diff --git a/src/schema-parser/schema-parsers/discriminator.js b/src/schema-parser/schema-parsers/discriminator.js index bb8608f9..7f30973f 100644 --- a/src/schema-parser/schema-parsers/discriminator.js +++ b/src/schema-parser/schema-parsers/discriminator.js @@ -46,15 +46,15 @@ class DiscriminatorSchemaParser { this.refPath = this.schemaComponentsMap.createRef("schemas", typeName); } - parse() { + async parse() { const { discriminator, ...noDiscriminatorSchema } = this.schema; if (this.typeName == null || !discriminator.mapping) - return this.schemaParser.parseSchema(noDiscriminatorSchema, this.typeName, this.schemaPath); + return await this.schemaParser.createParser(noDiscriminatorSchema, this.typeName, this.schemaPath).parse(); - const abstractSchemaStruct = this.createAbstractSchemaStruct(); - const complexSchemaStruct = this.createComplexSchemaStruct(); - const discriminatorSchemaStruct = this.createDiscriminatorSchema({ abstractSchemaStruct }); + const abstractSchemaStruct = await this.createAbstractSchemaStruct(); + const complexSchemaStruct = await this.createComplexSchemaStruct(); + const discriminatorSchemaStruct = await this.createDiscriminatorSchema({ abstractSchemaStruct }); const schemaContent = this.config.Ts.IntersectionType( [ @@ -77,11 +77,11 @@ class DiscriminatorSchemaParser { }; } - createDiscriminatorSchema = ({ abstractSchemaStruct }) => { + createDiscriminatorSchema = async ({ abstractSchemaStruct }) => { const { discriminator } = this.schema; const { mapping, propertyName } = discriminator; const mappingEntries = _.entries(mapping); - const complexSchemaKeys = _.keys(this.schemaParser.complexSchemaParsers); + const complexSchemaKeys = _.keys(this.schemaParser._complexSchemaParsers); const ableToCreateMappingType = !!(abstractSchemaStruct?.typeName && mappingEntries.length); const mappingContents = []; let mappingTypeName; @@ -97,7 +97,7 @@ class DiscriminatorSchemaParser { const component = this.schemaComponentsMap.createComponent("schemas", mappingTypeName, { internal: true, }); - const schema = this.schemaParser.parseSchema(component); + const schema = await this.schemaParser.createParser(component).parse(); schema.genericArgs = [{ name: "Key" }, { name: "Type" }]; schema.internal = true; schema.content = this.config.Ts.IntersectionType([ @@ -107,8 +107,8 @@ class DiscriminatorSchemaParser { component.typeData = schema; } - const createMappingContent = (mappingSchema, mappingKey) => { - const content = this.schemaParser.getInlineParseContent(mappingSchema); + const createMappingContent = async (mappingSchema, mappingKey) => { + const content = await this.schemaParser.createParser(mappingSchema).getInlineContent(); if (ableToCreateMappingType) { return this.config.Ts.TypeWithGeneric(mappingTypeName, [this.config.Ts.StringValue(mappingKey), content]); @@ -127,27 +127,31 @@ class DiscriminatorSchemaParser { } }; - for (const [mappingKey, schema] of mappingEntries) { + for await (const [mappingKey, schema] of mappingEntries) { const mappingSchema = typeof schema === "string" ? { $ref: schema } : schema; // override parent dependencies if (mappingSchema.$ref && abstractSchemaStruct?.component?.$ref) { - const mappingRefSchema = this.schemaUtils.getSchemaRefType(mappingSchema)?.rawTypeData; - if (mappingRefSchema) { - complexSchemaKeys.forEach((schemaKey) => { - if (_.isArray(mappingRefSchema[schemaKey])) { - mappingRefSchema[schemaKey] = mappingRefSchema[schemaKey].map((schema) => { - if (schema.$ref === this.refPath) { - return { ...schema, $ref: abstractSchemaStruct.component.$ref }; - } - return schema; - }); + const mappingSchemaRefType = this.schemaUtils.getSchemaRefType(mappingSchema); + if (mappingSchemaRefType?.rawTypeData) { + for await (const schemaKey of complexSchemaKeys) { + if (_.isArray(mappingSchemaRefType.rawTypeData[schemaKey])) { + mappingSchemaRefType.rawTypeData[schemaKey] = mappingSchemaRefType.rawTypeData[schemaKey].map( + (schema) => { + if (schema.$ref === this.refPath) { + schema.$parsed = abstractSchemaStruct.component.$parsed; + return { ...schema, $ref: abstractSchemaStruct.component.$ref }; + } + return schema; + }, + ); } - }); + } } } - mappingContents.push(createMappingContent(mappingSchema, mappingKey)); + const mappingContent = await createMappingContent(mappingSchema, mappingKey); + mappingContents.push(mappingContent); } const content = this.config.Ts.ExpressionGroup(this.config.Ts.UnionType(mappingContents)); @@ -157,9 +161,9 @@ class DiscriminatorSchemaParser { }; }; - createAbstractSchemaStruct = () => { + createAbstractSchemaStruct = async () => { const { discriminator, ...noDiscriminatorSchema } = this.schema; - const complexSchemaKeys = _.keys(this.schemaParser.complexSchemaParsers); + const complexSchemaKeys = _.keys(this.schemaParser._complexSchemaParsers); const schema = _.omit(_.clone(noDiscriminatorSchema), complexSchemaKeys); const schemaIsEmpty = !_.keys(schema).length; @@ -175,7 +179,7 @@ class DiscriminatorSchemaParser { ...schema, internal: true, }); - const content = this.schemaParser.getInlineParseContent(component); + const content = await this.schemaParser.createParser(component).getInlineContent(); return { typeName, @@ -184,13 +188,13 @@ class DiscriminatorSchemaParser { }; }; - createComplexSchemaStruct = () => { - const complexType = this.schemaParser.getComplexType(this.schema); + createComplexSchemaStruct = async () => { + const complexType = this.schemaParser.schemaUtils.getComplexType(this.schema); if (complexType === SCHEMA_TYPES.COMPLEX_UNKNOWN) return null; return { - content: this.config.Ts.ExpressionGroup(this.schemaParser.complexSchemaParsers[complexType](this.schema)), + content: this.config.Ts.ExpressionGroup(await this.schemaParser._complexSchemaParsers[complexType](this.schema)), }; };