openapi-ts-generator 7.284.4 → 7.339.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.
@@ -0,0 +1,4 @@
1
+ import { IEnumValue } from './enum-value';
2
+ export declare function getEnumKey(data: IEnumValue[], lookupValue: number | string): number | undefined;
3
+ export declare function getEnumDisplayText(data: IEnumValue[], lookupValue: number | string): string | undefined;
4
+ export declare function getEnum(data: IEnumValue[], looupValue: number | string): IEnumValue | undefined;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getEnum = exports.getEnumDisplayText = exports.getEnumKey = void 0;
4
+ function getEnumKey(data, lookupValue) {
5
+ var _a;
6
+ return (_a = getEnum(data, lookupValue)) === null || _a === void 0 ? void 0 : _a.key;
7
+ }
8
+ exports.getEnumKey = getEnumKey;
9
+ function getEnumDisplayText(data, lookupValue) {
10
+ var _a;
11
+ return (_a = getEnum(data, lookupValue)) === null || _a === void 0 ? void 0 : _a.displayText;
12
+ }
13
+ exports.getEnumDisplayText = getEnumDisplayText;
14
+ function getEnum(data, looupValue) {
15
+ return data.find(function (f) { return f.name === looupValue || f.key === looupValue; });
16
+ }
17
+ exports.getEnum = getEnum;
@@ -1,2 +1,3 @@
1
1
  export * from './enum-value';
2
2
  export * from './enum-properties';
3
+ export * from './enum-helpers';
@@ -16,3 +16,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./enum-value"), exports);
18
18
  __exportStar(require("./enum-properties"), exports);
19
+ __exportStar(require("./enum-helpers"), exports);
@@ -9,6 +9,7 @@ export interface IGeneratorOptions {
9
9
  openApiJsonUrl?: string;
10
10
  openApiJsonFileName?: string;
11
11
  genAngularFormGroups?: boolean;
12
+ genAngularFormGroupsWithDefaultValues?: boolean;
12
13
  genClasses?: boolean;
13
14
  typeFilterCallBack?: (entity: IEntity, index: number, array: IEntity[]) => boolean;
14
15
  valuePropertyTypeFilterCallBack?: (valueProperty: IValueProperty, index: number, array: IValueProperty[]) => boolean;
@@ -58,9 +58,10 @@ var OpenApiDocConverter = /** @class */ (function () {
58
58
  var entity = {
59
59
  isEnum: schemaWrapperInfo.isEnum,
60
60
  enumValues: schemaWrapperInfo.enumValues.map(function (t) {
61
+ var _a;
61
62
  return typeof t === 'string' || t instanceof String
62
63
  ? t
63
- : __assign(__assign({}, t), { key: t.key || 0 });
64
+ : __assign(__assign({}, t), { key: (_a = t.key) !== null && _a !== void 0 ? _a : 0 });
64
65
  }),
65
66
  name: schemaName,
66
67
  kebabCasedName: (0, lodash_1.kebabCase)(schemaName),
@@ -123,7 +124,9 @@ var OpenApiDocConverter = /** @class */ (function () {
123
124
  var _a, _b;
124
125
  var required = this.getIsRequired(propertyName, schemaWrapperInfo);
125
126
  var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
126
- var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
127
+ var initialValue = this.options.genAngularFormGroupsWithDefaultValues
128
+ ? this.getInitialValue(propertyName, schemaWrapperInfo)
129
+ : 'undefined';
127
130
  var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
128
131
  return {
129
132
  required: required,
@@ -154,7 +157,9 @@ var OpenApiDocConverter = /** @class */ (function () {
154
157
  OpenApiDocConverter.prototype.convertArrayObjectToValuePropertyType = function (parentTypeName, propertyName, schemaWrapperInfo) {
155
158
  var required = this.getIsRequired(propertyName, schemaWrapperInfo);
156
159
  var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
157
- var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
160
+ var initialValue = this.options.genAngularFormGroupsWithDefaultValues
161
+ ? this.getInitialValue(propertyName, schemaWrapperInfo)
162
+ : 'undefined';
158
163
  var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
159
164
  return {
160
165
  required: required,
@@ -230,6 +235,12 @@ var OpenApiDocConverter = /** @class */ (function () {
230
235
  else if (typescriptType === 'boolean') {
231
236
  return 'false';
232
237
  }
238
+ else if (typescriptType === 'number' && schemaObject.type === 'array') {
239
+ return minValue ? "[".concat(minValue, "]") : '[0]';
240
+ }
241
+ else if (schemaObject.type === 'array') {
242
+ return defaultValue ? "[".concat(defaultValue, "]") : '[]';
243
+ }
233
244
  else if (typescriptType === 'number') {
234
245
  return minValue ? "".concat(minValue) : '0';
235
246
  }
@@ -250,7 +261,9 @@ var OpenApiDocConverter = /** @class */ (function () {
250
261
  var refSchema = (((_b = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _b === void 0 ? void 0 : _b.properties) || {})[propertyName];
251
262
  var required = this.getIsRequired(propertyName, schemaWrapperInfo);
252
263
  var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
253
- var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
264
+ var initialValue = this.options.genAngularFormGroupsWithDefaultValues
265
+ ? this.getInitialValue(propertyName, schemaWrapperInfo)
266
+ : 'undefined';
254
267
  var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
255
268
  var typeName = this.parseRef(schemaWrapperInfo);
256
269
  return {
@@ -293,7 +306,8 @@ var OpenApiDocConverter = /** @class */ (function () {
293
306
  OpenApiDocConverter.prototype.getPropertyTypeScriptType = function (schemaWrapperInfo) {
294
307
  var _a;
295
308
  if (schemaWrapperInfo.propertySchemaObject.type === 'array' && schemaWrapperInfo.propertySchemaObject.items) {
296
- return schemaWrapperInfo.propertySchemaObject.items.type;
309
+ var type = schemaWrapperInfo.propertySchemaObject.items.type;
310
+ return type === 'integer' ? 'number' : type;
297
311
  }
298
312
  else if (schemaWrapperInfo.propertySchemaObject.type === 'integer' && schemaWrapperInfo.propertySchemaObject.enum) {
299
313
  return 'string | number';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-ts-generator",
3
- "version": "7.284.4",
3
+ "version": "7.339.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",
@@ -10,10 +10,10 @@
10
10
  "require": "./index.js",
11
11
  "types": "./index.d.ts"
12
12
  },
13
- "./interfaces": {
14
- "import": "./interfaces/index.js",
15
- "require": "./interfaces/index.js",
16
- "types": "./interfaces/index.d.ts"
13
+ "./enums": {
14
+ "import": "./enums/index.js",
15
+ "require": "./enums/index.js",
16
+ "types": "./enums/index.d.ts"
17
17
  }
18
18
  },
19
19
  "scripts": {
@@ -5,7 +5,7 @@
5
5
  * For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
6
6
  * Do not edit.
7
7
  */
8
- /* tslint:disable */
8
+ /* eslint-disable */
9
9
  export enum Endpoints {
10
10
  {{#paths}}
11
11
  {{tag}} = '{{endpoint}}',
@@ -5,7 +5,7 @@
5
5
  * For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
6
6
  * Do not edit.
7
7
  */
8
- import { IEnumValue } from 'openapi-ts-generator/interfaces';
8
+ import { IEnumValue } from 'openapi-ts-generator/enums';
9
9
 
10
10
  {{#if description}}/**
11
11
  * {{description}}
@@ -5,7 +5,7 @@
5
5
  * For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
6
6
  * Do not edit.
7
7
  */
8
- /* tslint:disable */
8
+ /* eslint-disable */
9
9
  {{#fileNames}}
10
10
  export * from './{{this}}';
11
11
  {{/fileNames}}
@@ -5,7 +5,7 @@
5
5
  * For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
6
6
  * Do not edit.
7
7
  */
8
- /* tslint:disable */
8
+ /* eslint-disable */
9
9
  {{#if description}}/**
10
10
  * {{description}}
11
11
  */
File without changes
File without changes
File without changes
File without changes