openapi-ts-generator 6.176.3 → 7.59.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -14,7 +14,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
14
14
  function verb(n) { return function (v) { return step([n, v]); }; }
15
15
  function step(op) {
16
16
  if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
18
  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;
19
19
  if (y = 0, t) op = [op[0] & 2, t.value];
20
20
  switch (op[0]) {
@@ -15,7 +15,7 @@ export interface IGeneratorOptions {
15
15
  referencePropertyTypeFilterCallBack?: (referenceProperty: IReferenceProperty, index: number, array: IReferenceProperty[]) => boolean;
16
16
  pathUrlFormattingCallBack?: (url: string) => string;
17
17
  templates?: ITemplates | null;
18
- axiosConfig?: AxiosRequestConfig<any>;
18
+ axiosConfig?: AxiosRequestConfig<unknown>;
19
19
  }
20
20
  export interface ITemplates {
21
21
  model?: string;
@@ -8,4 +8,4 @@ export interface IHelperContext {
8
8
  };
9
9
  name: string;
10
10
  }
11
- export declare type PropertyType = 'valueProperties' | 'referenceProperties';
11
+ export type PropertyType = 'valueProperties' | 'referenceProperties';
@@ -1,4 +1,4 @@
1
- import { ReferenceObject, SchemaObject } from 'openapi3-ts';
1
+ import { ReferenceObject, SchemaObject } from 'openapi3-ts/dist/oas30';
2
2
  import { IEnumValue } from './enum-value';
3
3
  import { IGeneratorOptions } from './generator-options';
4
4
  import { IReferenceProperty } from './reference-property';
@@ -13,7 +13,8 @@ var SchemaWrapperInfo = /** @class */ (function () {
13
13
  this.enumValues = [];
14
14
  }
15
15
  SchemaWrapperInfo.prototype.updateReferenceProperties = function (options) {
16
- this.referenceProperties = this.referenceProperties.filter(options.referencePropertyTypeFilterCallBack || generator_options_1.defaultFilter);
16
+ var _a;
17
+ this.referenceProperties = this.referenceProperties.filter((_a = options.referencePropertyTypeFilterCallBack) !== null && _a !== void 0 ? _a : generator_options_1.defaultFilter);
17
18
  };
18
19
  return SchemaWrapperInfo;
19
20
  }());
@@ -1,10 +1,10 @@
1
- import { OpenAPIObject } from 'openapi3-ts';
2
1
  import { IGeneratorOptions } from './models/generator-options';
3
2
  import { SchemaWrapperInfo } from './models/schema-info';
4
3
  import { IImportType, IPath, ITemplateData } from './models/template-data';
5
4
  import { IEntity } from './models/entity';
6
5
  import { IReferenceProperty } from './models/reference-property';
7
6
  import { IValueProperty } from './models/value-property';
7
+ import { OpenAPIObject } from 'openapi3-ts/dist/oas30';
8
8
  export declare class OpenApiDocConverter {
9
9
  private readonly options;
10
10
  private readonly apiDocument;
@@ -81,9 +81,9 @@ var OpenApiDocConverter = /** @class */ (function () {
81
81
  var _this = this;
82
82
  schemaWrapperInfo.isEnum = true;
83
83
  (_a = schemaWrapperInfo.enumValues).push.apply(_a, (schemaWrapperInfo.componentSchemaObject.enum || []).map(function (x) {
84
- var _a, _b;
84
+ var _a, _b, _c;
85
85
  var key = (_a = _this.startNumberregex.exec(x)) === null || _a === void 0 ? void 0 : _a.at(0);
86
- var name = ((_b = _this.endAlphaNumRegex.exec(x)) === null || _b === void 0 ? void 0 : _b.at(0)) || '';
86
+ var name = (_c = (_b = _this.endAlphaNumRegex.exec(x)) === null || _b === void 0 ? void 0 : _b.at(0)) !== null && _c !== void 0 ? _c : '';
87
87
  return {
88
88
  key: key ? +key : 0,
89
89
  name: name,
@@ -201,16 +201,16 @@ var OpenApiDocConverter = /** @class */ (function () {
201
201
  }
202
202
  };
203
203
  OpenApiDocConverter.prototype.getInitialTestValue = function (parentTypeName, propertyName, schemaWrapperInfo) {
204
- var _a, _b, _c, _d;
204
+ var _a, _b, _c, _d, _e, _f;
205
205
  var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
206
- var schemaObject = (((_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) || {})[propertyName];
206
+ var schemaObject = ((_b = (_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) !== null && _b !== void 0 ? _b : {})[propertyName];
207
207
  var maxLength = schemaWrapperInfo.propertySchemaObject.maxLength;
208
208
  var minLength = schemaWrapperInfo.propertySchemaObject.minLength;
209
209
  var minValue = schemaWrapperInfo.propertySchemaObject.minimum;
210
- var email = ((_b = schemaWrapperInfo.propertySchemaObject.format) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'email';
210
+ var email = ((_c = schemaWrapperInfo.propertySchemaObject.format) === null || _c === void 0 ? void 0 : _c.toLowerCase()) === 'email';
211
211
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
212
- var refName = schemaObject.$ref || ((_c = schemaObject.items) === null || _c === void 0 ? void 0 : _c.$ref);
213
- var refObject = (((_d = this.apiDocument.components) === null || _d === void 0 ? void 0 : _d.schemas) || {})[refName];
212
+ var refName = (schemaObject === null || schemaObject === void 0 ? void 0 : schemaObject.$ref) || ((_d = schemaObject.items) === null || _d === void 0 ? void 0 : _d.$ref);
213
+ var refObject = ((_f = (_e = this.apiDocument.components) === null || _e === void 0 ? void 0 : _e.schemas) !== null && _f !== void 0 ? _f : {})[refName];
214
214
  var defaultValue = (schemaWrapperInfo.componentSchemaObject.default || (refObject === null || refObject === void 0 ? void 0 : refObject.default) || ((refObject === null || refObject === void 0 ? void 0 : refObject.enum) || [])[0]);
215
215
  if (defaultValue && refObject.enum) {
216
216
  return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
@@ -291,6 +291,7 @@ var OpenApiDocConverter = /** @class */ (function () {
291
291
  +this.convertValidator(schemaWrapperInfo.propertySchemaObject.pattern));
292
292
  };
293
293
  OpenApiDocConverter.prototype.getPropertyTypeScriptType = function (schemaWrapperInfo) {
294
+ var _a;
294
295
  if (schemaWrapperInfo.propertySchemaObject.type === 'array' && schemaWrapperInfo.propertySchemaObject.items) {
295
296
  return schemaWrapperInfo.propertySchemaObject.items.type;
296
297
  }
@@ -303,7 +304,7 @@ var OpenApiDocConverter = /** @class */ (function () {
303
304
  else if (schemaWrapperInfo.propertySchemaObject.format === 'date' || schemaWrapperInfo.propertySchemaObject.format === 'date-time') {
304
305
  return 'Date';
305
306
  }
306
- return schemaWrapperInfo.propertySchemaObject.type || 'string';
307
+ return (_a = schemaWrapperInfo.propertySchemaObject.type) !== null && _a !== void 0 ? _a : 'string';
307
308
  };
308
309
  OpenApiDocConverter.prototype.parseRef = function (schemaWrapperInfo) {
309
310
  var regexResult;
@@ -318,9 +319,10 @@ var OpenApiDocConverter = /** @class */ (function () {
318
319
  return result || 'unknown';
319
320
  };
320
321
  OpenApiDocConverter.prototype.getImportTypes = function (entityName, schemaWrapperInfo) {
321
- var _this = this;
322
322
  var _a;
323
- var schemaProperties = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || { properties: {} })[entityName].properties || {};
323
+ var _this = this;
324
+ var _b, _c, _d;
325
+ var schemaProperties = (_d = ((_c = (_b = this.apiDocument.components) === null || _b === void 0 ? void 0 : _b.schemas) !== null && _c !== void 0 ? _c : (_a = {}, _a[entityName] = { properties: {} }, _a))[entityName].properties) !== null && _d !== void 0 ? _d : {};
324
326
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
325
327
  var properties = Object.keys(schemaProperties).map(function (key) { return (__assign(__assign({ key: key }, schemaProperties[key]), { $ref: schemaProperties[key].$ref, items: schemaProperties[key].items || {}, type: schemaProperties[key].type })); });
326
328
  return schemaWrapperInfo.referenceProperties
@@ -341,7 +343,8 @@ var OpenApiDocConverter = /** @class */ (function () {
341
343
  });
342
344
  };
343
345
  OpenApiDocConverter.prototype.getIsRequired = function (propertyName, schemaWrapperInfo) {
344
- return (((schemaWrapperInfo.componentSchemaObject.required || []).indexOf(propertyName) > -1 ||
346
+ var _a;
347
+ return ((((_a = schemaWrapperInfo.componentSchemaObject.required) !== null && _a !== void 0 ? _a : []).indexOf(propertyName) > -1 ||
345
348
  (schemaWrapperInfo.propertySchemaObject.nullable === undefined ? false : !schemaWrapperInfo.propertySchemaObject.nullable)) &&
346
349
  propertyName !== 'id');
347
350
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-generator",
3
- "version": "6.176.3",
3
+ "version": "7.59.2",
4
4
  "description": "Based on swagger-ts-generator, this is a type script model generator specifically for services with OpenApi spec documentation.",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -37,36 +37,36 @@
37
37
  ],
38
38
  "homepage": "https://github.com/ikemtz/OpenApi-TS-Generator#readme",
39
39
  "devDependencies": {
40
- "@types/jest": "^27.4.1",
41
- "@types/lodash": "^4.14.182",
42
- "@types/node": "^16.11.27",
43
- "@types/pluralize": "^0.0.29",
44
- "@typescript-eslint/eslint-plugin": "^5.32.0",
45
- "@typescript-eslint/parser": "^5.32.0",
46
- "eslint": "^8.21.0",
47
- "eslint-config-prettier": "^8.5.0",
48
- "eslint-config-standard": "^17.0.0",
49
- "eslint-plugin-import": "^2.26.0",
40
+ "@types/jest": "^27.5.2",
41
+ "@types/lodash": "^4.14.202",
42
+ "@types/node": "^20.11.21",
43
+ "@types/pluralize": "^0.0.33",
44
+ "@typescript-eslint/eslint-plugin": "^7.1.0",
45
+ "@typescript-eslint/parser": "^7.1.0",
46
+ "eslint": "^8.57.0",
47
+ "eslint-config-prettier": "^9.1.0",
48
+ "eslint-config-standard": "^17.1.0",
49
+ "eslint-plugin-import": "^2.29.1",
50
50
  "eslint-plugin-node": "^11.1.0",
51
- "eslint-plugin-promise": "^6.0.0",
51
+ "eslint-plugin-promise": "^6.1.1",
52
52
  "jest": "^27.5.1",
53
53
  "jest-junit": "^13.2.0",
54
- "openapi3-ts": "^2.0.2",
55
- "prettier": "^2.7.1",
56
- "rxjs": "^7.5.7",
54
+ "openapi3-ts": "^4.2.2",
55
+ "prettier": "^3.2.5",
56
+ "rxjs": "^7.6.0",
57
57
  "ts-jest": "^27.1.3",
58
- "typescript": "^4.6.3"
58
+ "typescript": "^4.9.5"
59
59
  },
60
60
  "dependencies": {
61
- "axios": ">=0.x",
61
+ "axios": ">=1.x",
62
62
  "handlebars": ">=4.x",
63
63
  "lodash": ">=4.x",
64
64
  "pluralize": "^8.0.0"
65
65
  },
66
66
  "peerDependencies": {
67
- "axios": ">=0.x",
67
+ "axios": ">=1.x",
68
68
  "handlebars": ">=4.x",
69
69
  "lodash": ">=4.x",
70
- "rxjs": ">=6.x"
70
+ "rxjs": "*"
71
71
  }
72
72
  }