openapi-client-axios-typegen
Advanced tools
Comparing version 7.6.0 to 7.6.1
{ | ||
"name": "openapi-client-axios-typegen", | ||
"description": "Typescript type generator for openapi-client-axios", | ||
"version": "7.6.0", | ||
"version": "7.6.1", | ||
"author": "Viljami Kuosmanen <viljami@viljami.io>", | ||
@@ -45,7 +45,7 @@ "funding": "https://github.com/sponsors/anttiviljami", | ||
"@anttiviljami/dtsgenerator": "^3.19.3", | ||
"@apidevtools/json-schema-ref-parser": "^10.1.0", | ||
"@apidevtools/json-schema-ref-parser": "^11.2.0", | ||
"axios": ">=0.25.0", | ||
"indent-string": "^4.0.0", | ||
"lodash": "^4.17.21", | ||
"openapi-client-axios": "^7.5.4", | ||
"openapi-client-axios": "^7.5.5", | ||
"openapi-types": "^12.1.0", | ||
@@ -72,3 +72,3 @@ "yargs": "^17.3.0" | ||
}, | ||
"gitHead": "3e3f84cd7feaa4b182dff0fc1327b72aa6bb6dce" | ||
"gitHead": "2b98df08291fa736ca1eff0a9bb6d6edb7877240" | ||
} |
@@ -5,2 +5,3 @@ import OpenAPIClientAxios, { Document } from 'openapi-client-axios'; | ||
disableOptionalPathParameters?: boolean; | ||
banner?: string; | ||
} | ||
@@ -7,0 +8,0 @@ interface ExportedType { |
"use strict"; | ||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { | ||
if (k2 === undefined) k2 = k; | ||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); | ||
var desc = Object.getOwnPropertyDescriptor(m, k); | ||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { | ||
desc = { enumerable: true, get: function() { return m[k]; } }; | ||
} | ||
Object.defineProperty(o, k2, desc); | ||
}) : (function(o, m, k, k2) { | ||
@@ -36,3 +40,3 @@ if (k2 === undefined) k2 = k; | ||
if (f) throw new TypeError("Generator is already executing."); | ||
while (_) try { | ||
while (g && (g = 0, op[0] && (_ = 0)), _) try { | ||
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; | ||
@@ -93,4 +97,5 @@ if (y = 0, t) op = [op[0] & 2, t.value]; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var argv, opts, _b, modulePath, func, module_1, _c, imports, schemaTypes, operationTypings; | ||
var argv, opts, _b, modulePath, func, module_1, _c, imports, schemaTypes, operationTypings, banner; | ||
return __generator(this, function (_d) { | ||
var _e; | ||
switch (_d.label) { | ||
@@ -102,4 +107,9 @@ case 0: return [4 /*yield*/, yargs_1.default | ||
}) | ||
.option('banner', { | ||
alias: 'b', | ||
type: 'string', | ||
description: 'Add banner to generated file', | ||
}) | ||
.option('disableOptionalPathParameters', { | ||
type: 'string', | ||
type: 'boolean', | ||
description: 'Force all path parameters to be required', | ||
@@ -116,2 +126,3 @@ default: true, | ||
transformOperationName: function (operation) { return operation; }, | ||
banner: argv.banner, | ||
}; | ||
@@ -123,3 +134,3 @@ if (!argv.transformOperationName) return [3 /*break*/, 3]; | ||
} | ||
return [4 /*yield*/, Promise.resolve().then(function () { return __importStar(require(modulePath)); })]; | ||
return [4 /*yield*/, (_e = modulePath, Promise.resolve().then(function () { return __importStar(require(_e)); }))]; | ||
case 2: | ||
@@ -136,3 +147,6 @@ module_1 = _d.sent(); | ||
case 4: | ||
_c = _d.sent(), imports = _c[0], schemaTypes = _c[1], operationTypings = _c[2]; | ||
_c = _d.sent(), imports = _c[0], schemaTypes = _c[1], operationTypings = _c[2], banner = _c[3]; | ||
if (banner === null || banner === void 0 ? void 0 : banner.length) { | ||
console.log(banner, '\n'); | ||
} | ||
console.log(imports, '\n'); | ||
@@ -149,9 +163,10 @@ console.log(schemaTypes); | ||
function generateTypesForDocument(definition, opts) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var rootSchema, normalizedSchema, schema, generator, schemaTypes, exportedTypes, api, operationTypings, imports; | ||
return __generator(this, function (_a) { | ||
switch (_a.label) { | ||
var rootSchema, normalizedSchema, schema, generator, schemaTypes, exportedTypes, api, operationTypings, banner, imports; | ||
return __generator(this, function (_b) { | ||
switch (_b.label) { | ||
case 0: return [4 /*yield*/, json_schema_ref_parser_1.default.bundle(definition, schemaParserOptions)]; | ||
case 1: | ||
rootSchema = _a.sent(); | ||
rootSchema = _b.sent(); | ||
normalizedSchema = normalizeSchema(rootSchema); | ||
@@ -162,3 +177,3 @@ schema = (0, dtsgenerator_1.parseSchema)(normalizedSchema); | ||
case 2: | ||
schemaTypes = _a.sent(); | ||
schemaTypes = _b.sent(); | ||
exportedTypes = generator.getExports(); | ||
@@ -168,4 +183,5 @@ api = new openapi_client_axios_1.default({ definition: normalizedSchema }); | ||
case 3: | ||
_a.sent(); | ||
_b.sent(); | ||
operationTypings = generateOperationMethodTypings(api, exportedTypes, opts); | ||
banner = (_a = opts.banner) !== null && _a !== void 0 ? _a : ''; | ||
imports = [ | ||
@@ -180,3 +196,3 @@ 'import type {', | ||
].join('\n'); | ||
return [2 /*return*/, [imports, schemaTypes, operationTypings]]; | ||
return [2 /*return*/, [imports, schemaTypes, operationTypings, banner]]; | ||
} | ||
@@ -183,0 +199,0 @@ }); |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
22264
330
+ Added@apidevtools/json-schema-ref-parser@11.9.3(transitive)
- Removed@apidevtools/json-schema-ref-parser@10.1.0(transitive)
- Removed@types/lodash@4.17.16(transitive)
- Removed@types/lodash.clonedeep@4.5.9(transitive)
- Removedlodash.clonedeep@4.5.0(transitive)
Updatedopenapi-client-axios@^7.5.5