openapi-ts-generator 4.192.6 → 5.52.3
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/README.md +1 -1
- package/generators/{barrel-generator.d.ts → barrel.generator.d.ts} +1 -1
- package/generators/{barrel-generator.js → barrel.generator.js} +2 -2
- package/generators/{base-generator.d.ts → base.generator.d.ts} +1 -1
- package/generators/{base-generator.js → base.generator.js} +13 -10
- package/generators/{endpoints-generator.d.ts → endpoints.generator.d.ts} +1 -1
- package/generators/{endpoints-generator.js → endpoints.generator.js} +1 -1
- package/generators/{enum-generator.d.ts → enum.generator.d.ts} +3 -2
- package/generators/{enum-generator.js → enum.generator.js} +1 -1
- package/generators/{form-group-generator.d.ts → form-group-factory.generator.d.ts} +6 -4
- package/generators/{form-group-generator.js → form-group-factory.generator.js} +24 -22
- package/generators/form.generator.d.ts +9 -0
- package/generators/form.generator.js +39 -0
- package/generators/index.d.ts +8 -5
- package/generators/index.js +8 -5
- package/generators/{model-properties-generator.d.ts → model-properties.generator.d.ts} +3 -2
- package/generators/{model-properties-generator.js → model-properties.generator.js} +1 -1
- package/generators/{model-generator.d.ts → model.generator.d.ts} +3 -2
- package/generators/{model-generator.js → model.generator.js} +5 -4
- package/generators/test-object-factory.generator.d.ts +9 -0
- package/generators/test-object-factory.generator.js +39 -0
- package/index.js +7 -4
- package/models/entity.d.ts +16 -0
- package/models/entity.js +2 -0
- package/models/enum-value.d.ts +6 -0
- package/models/enum-value.js +2 -0
- package/models/generator-options.d.ts +10 -2
- package/models/generator-options.js +3 -3
- package/models/helper-context.d.ts +1 -1
- package/models/nrsrx-filters.d.ts +2 -1
- package/models/reference-property.d.ts +20 -0
- package/models/reference-property.js +2 -0
- package/models/schema-info.d.ts +4 -6
- package/models/template-data.d.ts +4 -36
- package/models/value-property.d.ts +21 -0
- package/models/value-property.js +2 -0
- package/openapidoc-converter.d.ts +13 -7
- package/openapidoc-converter.js +169 -39
- package/package.json +7 -6
- package/templates/entity.ts.hbs +30 -0
- package/templates/enum.ts.hbs +17 -2
- package/templates/form-group-factory.ts.hbs +24 -11
- package/templates/form.ts.hbs +30 -0
- package/templates/index.ts.hbs +1 -1
- package/templates/model.ts.hbs +8 -4
- package/templates/test-object-factory.ts.hbs +17 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IEntity } from './entity';
|
|
1
2
|
export interface ITemplateData {
|
|
2
3
|
entities?: IEntity[];
|
|
3
4
|
paths: IPath[];
|
|
@@ -6,44 +7,11 @@ export interface IPath {
|
|
|
6
7
|
tag: string;
|
|
7
8
|
endpoint: string;
|
|
8
9
|
}
|
|
9
|
-
export interface IEntity {
|
|
10
|
-
isEnum?: boolean;
|
|
11
|
-
enumValues: (string | {
|
|
12
|
-
key?: number;
|
|
13
|
-
name: string;
|
|
14
|
-
titleName: string;
|
|
15
|
-
})[];
|
|
16
|
-
name: string;
|
|
17
|
-
camelSingularName: string;
|
|
18
|
-
description?: string;
|
|
19
|
-
importTypes: IImportType[];
|
|
20
|
-
valueProperties: IValueProperty[];
|
|
21
|
-
referenceProperties: IReferenceProperty[];
|
|
22
|
-
}
|
|
23
10
|
export interface IImportType {
|
|
24
11
|
kebabCasedTypeName: string;
|
|
25
12
|
name: string;
|
|
26
13
|
isEnum: boolean;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
snakeCaseName: string;
|
|
31
|
-
typeScriptType?: string;
|
|
32
|
-
isArray: boolean;
|
|
33
|
-
hasMultipleValidators: boolean;
|
|
34
|
-
required: boolean;
|
|
35
|
-
maxLength?: number;
|
|
36
|
-
minLength?: number;
|
|
37
|
-
maximum?: number;
|
|
38
|
-
minimum?: number;
|
|
39
|
-
description?: string;
|
|
40
|
-
pattern?: string;
|
|
41
|
-
}
|
|
42
|
-
export interface IReferenceProperty {
|
|
43
|
-
name: string;
|
|
44
|
-
snakeCaseName: string;
|
|
45
|
-
referenceTypeName: string;
|
|
46
|
-
isArray: boolean;
|
|
47
|
-
required: boolean;
|
|
48
|
-
isEnum?: boolean;
|
|
14
|
+
areAllArrays: boolean;
|
|
15
|
+
hasArrays: boolean;
|
|
16
|
+
isSelfReferencing: boolean;
|
|
49
17
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface IValueProperty {
|
|
2
|
+
name: string;
|
|
3
|
+
snakeCaseName: string;
|
|
4
|
+
typeScriptType: string;
|
|
5
|
+
isArray: boolean;
|
|
6
|
+
hasValidators: boolean;
|
|
7
|
+
hasMultipleValidators: boolean;
|
|
8
|
+
required: boolean;
|
|
9
|
+
maxLength?: number;
|
|
10
|
+
minLength?: number;
|
|
11
|
+
maximum?: number;
|
|
12
|
+
minimum?: number;
|
|
13
|
+
maxItems?: number;
|
|
14
|
+
minItems?: number;
|
|
15
|
+
email: boolean;
|
|
16
|
+
uri: boolean;
|
|
17
|
+
description?: string;
|
|
18
|
+
pattern?: string;
|
|
19
|
+
initialValue: string;
|
|
20
|
+
initialTestValue: string;
|
|
21
|
+
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { OpenAPIObject } from 'openapi3-ts';
|
|
2
2
|
import { IGeneratorOptions } from './models/generator-options';
|
|
3
3
|
import { SchemaWrapperInfo } from './models/schema-info';
|
|
4
|
-
import {
|
|
4
|
+
import { IImportType, IPath, ITemplateData } from './models/template-data';
|
|
5
|
+
import { IEntity } from './models/entity';
|
|
6
|
+
import { IReferenceProperty } from './models/reference-property';
|
|
7
|
+
import { IValueProperty } from './models/value-property';
|
|
5
8
|
export declare class OpenApiDocConverter {
|
|
6
9
|
private readonly options;
|
|
7
10
|
private readonly apiDocument;
|
|
@@ -12,13 +15,16 @@ export declare class OpenApiDocConverter {
|
|
|
12
15
|
convertPaths(): IPath[];
|
|
13
16
|
convertEntities(): IEntity[];
|
|
14
17
|
buildSchemaWrapperInfoForEnum(schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
15
|
-
buildSchemaWrapperInfo(schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
16
|
-
convertArray(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
17
|
-
convertSchemaObjectToPropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
18
|
+
buildSchemaWrapperInfo(parentTypeName: string, schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
19
|
+
convertArray(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
20
|
+
convertSchemaObjectToPropertyType(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
18
21
|
private convertValidator;
|
|
19
|
-
convertArrayObjectToValuePropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
+
convertArrayObjectToValuePropertyType(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
23
|
+
getInitialValue(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
24
|
+
getInitialTestValue(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
25
|
+
convertArrayObjectToReferencePropertyType(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IReferenceProperty;
|
|
26
|
+
convertReferenceObjectToPropertyType(parentTypeName: string, propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IReferenceProperty;
|
|
27
|
+
getValidatorCount(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): number;
|
|
22
28
|
getPropertyTypeScriptType(schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
23
29
|
parseRef(schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
24
30
|
getImportTypes(entityName: string, schemaWrapperInfo: SchemaWrapperInfo): IImportType[];
|
package/openapidoc-converter.js
CHANGED
|
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.OpenApiDocConverter = void 0;
|
|
15
15
|
var generator_options_1 = require("./models/generator-options");
|
|
16
16
|
var schema_info_1 = require("./models/schema-info");
|
|
17
|
-
var _ = require("lodash");
|
|
18
17
|
var pluralize_1 = require("pluralize");
|
|
19
18
|
var lodash_1 = require("lodash");
|
|
20
19
|
var OpenApiDocConverter = /** @class */ (function () {
|
|
@@ -37,7 +36,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
37
36
|
tagLookup = tagLookup || path.delete || path.patch;
|
|
38
37
|
var tag = ((tagLookup === null || tagLookup === void 0 ? void 0 : tagLookup.tags) || ['unknown_endpoint'])[0];
|
|
39
38
|
paths.push({
|
|
40
|
-
tag:
|
|
39
|
+
tag: (0, lodash_1.snakeCase)(tag),
|
|
41
40
|
endpoint: this.options.pathUrlFormattingCallBack ? this.options.pathUrlFormattingCallBack(key) : key,
|
|
42
41
|
});
|
|
43
42
|
}
|
|
@@ -53,15 +52,19 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
53
52
|
this.buildSchemaWrapperInfoForEnum(schemaWrapperInfo);
|
|
54
53
|
}
|
|
55
54
|
else {
|
|
56
|
-
this.buildSchemaWrapperInfo(schemaWrapperInfo);
|
|
55
|
+
this.buildSchemaWrapperInfo(schemaName, schemaWrapperInfo);
|
|
57
56
|
}
|
|
58
57
|
schemaWrapperInfo.updateReferenceProperties(this.options);
|
|
59
58
|
var entity = {
|
|
60
59
|
isEnum: schemaWrapperInfo.isEnum,
|
|
61
60
|
enumValues: schemaWrapperInfo.enumValues.map(function (t) {
|
|
62
|
-
return typeof t === 'string' || t instanceof String
|
|
61
|
+
return typeof t === 'string' || t instanceof String
|
|
62
|
+
? t
|
|
63
|
+
: __assign(__assign({}, t), { key: t.key || 0 });
|
|
63
64
|
}),
|
|
64
65
|
name: schemaName,
|
|
66
|
+
kebabCasedName: (0, lodash_1.kebabCase)(schemaName),
|
|
67
|
+
singularName: (0, pluralize_1.singular)(schemaName),
|
|
65
68
|
camelSingularName: (0, lodash_1.camelCase)((0, pluralize_1.singular)(schemaName)),
|
|
66
69
|
description: schemaWrapperInfo.description,
|
|
67
70
|
referenceProperties: schemaWrapperInfo.referenceProperties,
|
|
@@ -81,89 +84,212 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
81
84
|
var _a, _b;
|
|
82
85
|
var key = (_a = _this.startNumberregex.exec(x)) === null || _a === void 0 ? void 0 : _a.at(0);
|
|
83
86
|
var name = ((_b = _this.endAlphaNumRegex.exec(x)) === null || _b === void 0 ? void 0 : _b.at(0)) || '';
|
|
84
|
-
return {
|
|
87
|
+
return {
|
|
88
|
+
key: key ? +key : 0,
|
|
89
|
+
name: name,
|
|
90
|
+
titleName: (0, lodash_1.startCase)(name),
|
|
91
|
+
snakeCaseName: (0, lodash_1.snakeCase)(name).toUpperCase(),
|
|
92
|
+
};
|
|
85
93
|
}));
|
|
86
94
|
};
|
|
87
|
-
OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (schemaWrapperInfo) {
|
|
95
|
+
OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (parentTypeName, schemaWrapperInfo) {
|
|
88
96
|
for (var propertyName in schemaWrapperInfo.componentSchemaObject.properties) {
|
|
89
97
|
if ((schemaWrapperInfo.propertySchemaObject = schemaWrapperInfo.componentSchemaObject.properties[propertyName]).type && // NOSONAR
|
|
90
98
|
schemaWrapperInfo.propertySchemaObject.type !== 'array') {
|
|
91
|
-
schemaWrapperInfo.valueProperties.push(this.convertSchemaObjectToPropertyType(propertyName, schemaWrapperInfo));
|
|
99
|
+
schemaWrapperInfo.valueProperties.push(this.convertSchemaObjectToPropertyType(parentTypeName, propertyName, schemaWrapperInfo));
|
|
92
100
|
}
|
|
93
101
|
else {
|
|
94
102
|
schemaWrapperInfo.propertyReferenceObject = schemaWrapperInfo.componentSchemaObject.properties[propertyName];
|
|
95
103
|
if (schemaWrapperInfo.propertyReferenceObject.$ref) {
|
|
96
|
-
schemaWrapperInfo.referenceProperties.push(this.convertReferenceObjectToPropertyType(propertyName, schemaWrapperInfo));
|
|
104
|
+
schemaWrapperInfo.referenceProperties.push(this.convertReferenceObjectToPropertyType(parentTypeName, propertyName, schemaWrapperInfo));
|
|
97
105
|
}
|
|
98
106
|
else if (schemaWrapperInfo.propertySchemaObject.type === 'array' && schemaWrapperInfo.propertySchemaObject.items) {
|
|
99
|
-
this.convertArray(propertyName, schemaWrapperInfo);
|
|
107
|
+
this.convertArray(parentTypeName, propertyName, schemaWrapperInfo);
|
|
100
108
|
}
|
|
101
109
|
}
|
|
102
110
|
}
|
|
103
111
|
};
|
|
104
|
-
OpenApiDocConverter.prototype.convertArray = function (propertyName, schemaWrapperInfo) {
|
|
112
|
+
OpenApiDocConverter.prototype.convertArray = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
105
113
|
var arraySchemaObject = schemaWrapperInfo.propertySchemaObject.items;
|
|
106
114
|
if (arraySchemaObject.type) {
|
|
107
|
-
schemaWrapperInfo.valueProperties.push(this.convertArrayObjectToValuePropertyType(propertyName, schemaWrapperInfo));
|
|
115
|
+
schemaWrapperInfo.valueProperties.push(this.convertArrayObjectToValuePropertyType(parentTypeName, propertyName, schemaWrapperInfo));
|
|
108
116
|
}
|
|
109
117
|
else {
|
|
110
118
|
schemaWrapperInfo.propertyReferenceObject = schemaWrapperInfo.propertySchemaObject.items;
|
|
111
|
-
schemaWrapperInfo.referenceProperties.push(this.convertArrayObjectToReferencePropertyType(propertyName, schemaWrapperInfo));
|
|
119
|
+
schemaWrapperInfo.referenceProperties.push(this.convertArrayObjectToReferencePropertyType(parentTypeName, propertyName, schemaWrapperInfo));
|
|
112
120
|
}
|
|
113
121
|
};
|
|
114
|
-
OpenApiDocConverter.prototype.convertSchemaObjectToPropertyType = function (propertyName, schemaWrapperInfo) {
|
|
122
|
+
OpenApiDocConverter.prototype.convertSchemaObjectToPropertyType = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
123
|
+
var _a, _b;
|
|
115
124
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
125
|
+
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
126
|
+
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
127
|
+
var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
|
|
116
128
|
return {
|
|
117
129
|
required: required,
|
|
118
130
|
name: propertyName,
|
|
131
|
+
initialValue: initialValue,
|
|
132
|
+
initialTestValue: initialTestValue,
|
|
119
133
|
isArray: false,
|
|
120
|
-
snakeCaseName:
|
|
134
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
121
135
|
typeScriptType: this.getPropertyTypeScriptType(schemaWrapperInfo),
|
|
122
136
|
maxLength: schemaWrapperInfo.propertySchemaObject.maxLength,
|
|
123
137
|
minLength: schemaWrapperInfo.propertySchemaObject.minLength,
|
|
124
138
|
maximum: schemaWrapperInfo.propertySchemaObject.maximum,
|
|
125
139
|
minimum: schemaWrapperInfo.propertySchemaObject.minimum,
|
|
140
|
+
email: ((_a = schemaWrapperInfo.propertySchemaObject.format) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'email',
|
|
141
|
+
uri: ((_b = schemaWrapperInfo.propertySchemaObject.format) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'uri',
|
|
142
|
+
minItems: schemaWrapperInfo.propertySchemaObject.minItems,
|
|
143
|
+
maxItems: schemaWrapperInfo.propertySchemaObject.maxItems,
|
|
126
144
|
description: schemaWrapperInfo.propertySchemaObject.description,
|
|
127
145
|
pattern: schemaWrapperInfo.propertySchemaObject.pattern,
|
|
128
|
-
hasMultipleValidators:
|
|
129
|
-
|
|
130
|
-
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minLength) +
|
|
131
|
-
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maximum) +
|
|
132
|
-
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minimum) +
|
|
133
|
-
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.pattern) >
|
|
134
|
-
1,
|
|
146
|
+
hasMultipleValidators: validatorCount > 1,
|
|
147
|
+
hasValidators: validatorCount > 0,
|
|
135
148
|
};
|
|
136
149
|
};
|
|
137
150
|
OpenApiDocConverter.prototype.convertValidator = function (validationValue) {
|
|
138
151
|
var exists = validationValue !== null && validationValue !== undefined;
|
|
139
152
|
return +exists;
|
|
140
153
|
};
|
|
141
|
-
OpenApiDocConverter.prototype.convertArrayObjectToValuePropertyType = function (propertyName, schemaWrapperInfo) {
|
|
154
|
+
OpenApiDocConverter.prototype.convertArrayObjectToValuePropertyType = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
142
155
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
156
|
+
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
157
|
+
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
158
|
+
var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
|
|
143
159
|
return {
|
|
144
160
|
required: required,
|
|
161
|
+
typeScriptType: this.getPropertyTypeScriptType(schemaWrapperInfo),
|
|
162
|
+
initialValue: initialValue,
|
|
163
|
+
initialTestValue: initialTestValue,
|
|
145
164
|
name: propertyName,
|
|
165
|
+
email: false,
|
|
166
|
+
uri: false,
|
|
146
167
|
isArray: true,
|
|
147
|
-
snakeCaseName:
|
|
148
|
-
typeScriptType: this.getPropertyTypeScriptType(schemaWrapperInfo),
|
|
168
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
149
169
|
hasMultipleValidators: false,
|
|
170
|
+
hasValidators: validatorCount > 0,
|
|
150
171
|
};
|
|
151
172
|
};
|
|
152
|
-
OpenApiDocConverter.prototype.
|
|
153
|
-
|
|
173
|
+
OpenApiDocConverter.prototype.getInitialValue = function (propertyName, schemaWrapperInfo) {
|
|
174
|
+
var _a, _b;
|
|
175
|
+
var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
|
|
176
|
+
var isRequired = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
177
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
178
|
+
var refName = (((_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) || {})[propertyName].$ref;
|
|
179
|
+
var refObject = (((_b = this.apiDocument.components) === null || _b === void 0 ? void 0 : _b.schemas) || {})[refName];
|
|
180
|
+
var defaultValue = (schemaWrapperInfo.componentSchemaObject.default || (refObject === null || refObject === void 0 ? void 0 : refObject.default) || ((refObject === null || refObject === void 0 ? void 0 : refObject.enum) || [])[0]);
|
|
181
|
+
if (!isRequired) {
|
|
182
|
+
return 'null';
|
|
183
|
+
}
|
|
184
|
+
else if (defaultValue && refObject.enum) {
|
|
185
|
+
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
186
|
+
}
|
|
187
|
+
else if (defaultValue) {
|
|
188
|
+
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
189
|
+
}
|
|
190
|
+
else if (typescriptType === 'Date') {
|
|
191
|
+
return 'new Date()';
|
|
192
|
+
}
|
|
193
|
+
else if (typescriptType === 'boolean') {
|
|
194
|
+
return 'false';
|
|
195
|
+
}
|
|
196
|
+
else if (typescriptType === 'number') {
|
|
197
|
+
return '0';
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
return "''";
|
|
201
|
+
}
|
|
154
202
|
};
|
|
155
|
-
OpenApiDocConverter.prototype.
|
|
156
|
-
var _a;
|
|
203
|
+
OpenApiDocConverter.prototype.getInitialTestValue = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
204
|
+
var _a, _b, _c, _d;
|
|
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];
|
|
207
|
+
var maxLength = schemaWrapperInfo.propertySchemaObject.maxLength;
|
|
208
|
+
var minLength = schemaWrapperInfo.propertySchemaObject.minLength;
|
|
209
|
+
var minValue = schemaWrapperInfo.propertySchemaObject.minimum;
|
|
210
|
+
var email = ((_b = schemaWrapperInfo.propertySchemaObject.format) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'email';
|
|
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];
|
|
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
|
+
if (defaultValue && refObject.enum) {
|
|
216
|
+
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
217
|
+
}
|
|
218
|
+
else if (refObject) {
|
|
219
|
+
return schemaObject.type === 'array' ? "[]" : "undefined";
|
|
220
|
+
}
|
|
221
|
+
else if (defaultValue) {
|
|
222
|
+
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
223
|
+
}
|
|
224
|
+
else if (email) {
|
|
225
|
+
return "'".concat((0, lodash_1.kebabCase)(parentTypeName), "@email.org'");
|
|
226
|
+
}
|
|
227
|
+
else if (typescriptType === 'Date') {
|
|
228
|
+
return 'new Date()';
|
|
229
|
+
}
|
|
230
|
+
else if (typescriptType === 'boolean') {
|
|
231
|
+
return 'false';
|
|
232
|
+
}
|
|
233
|
+
else if (typescriptType === 'number') {
|
|
234
|
+
return minValue ? "".concat(minValue) : '0';
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
var retValue = (0, lodash_1.snakeCase)(propertyName).toUpperCase();
|
|
238
|
+
while (minLength && retValue.length < minLength) {
|
|
239
|
+
retValue = "".concat(retValue, "_").concat(retValue);
|
|
240
|
+
}
|
|
241
|
+
return "'".concat(maxLength ? retValue.substring(0, maxLength) : retValue, "'");
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
OpenApiDocConverter.prototype.convertArrayObjectToReferencePropertyType = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
245
|
+
return __assign(__assign({}, this.convertReferenceObjectToPropertyType(parentTypeName, propertyName, schemaWrapperInfo)), { isArray: true });
|
|
246
|
+
};
|
|
247
|
+
OpenApiDocConverter.prototype.convertReferenceObjectToPropertyType = function (parentTypeName, propertyName, schemaWrapperInfo) {
|
|
248
|
+
var _a, _b;
|
|
157
249
|
var propertySchema = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[this.parseRef(schemaWrapperInfo)];
|
|
250
|
+
var refSchema = (((_b = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _b === void 0 ? void 0 : _b.properties) || {})[propertyName];
|
|
251
|
+
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
252
|
+
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
253
|
+
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
254
|
+
var initialTestValue = this.getInitialTestValue(parentTypeName, propertyName, schemaWrapperInfo);
|
|
255
|
+
var typeName = this.parseRef(schemaWrapperInfo);
|
|
158
256
|
return {
|
|
257
|
+
required: required,
|
|
159
258
|
name: propertyName,
|
|
160
|
-
|
|
161
|
-
|
|
259
|
+
isSameAsParentTypescriptType: parentTypeName.toLowerCase() === typeName.toLowerCase(),
|
|
260
|
+
initialValue: initialValue,
|
|
261
|
+
initialTestValue: initialTestValue,
|
|
262
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
263
|
+
referenceTypeName: typeName,
|
|
264
|
+
typeScriptType: typeName,
|
|
162
265
|
isArray: false,
|
|
163
|
-
required: (schemaWrapperInfo.componentSchemaObject.required || []).indexOf(propertyName) > -1,
|
|
164
266
|
isEnum: (propertySchema.enum || []).length > 0,
|
|
267
|
+
hasValidators: validatorCount > 0,
|
|
268
|
+
hasMultipleValidators: validatorCount > 1,
|
|
269
|
+
maxLength: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maxLength,
|
|
270
|
+
minLength: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minLength,
|
|
271
|
+
maximum: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maximum,
|
|
272
|
+
minimum: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minimum,
|
|
273
|
+
minItems: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minItems,
|
|
274
|
+
maxItems: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maxItems,
|
|
165
275
|
};
|
|
166
276
|
};
|
|
277
|
+
OpenApiDocConverter.prototype.getValidatorCount = function (propertyName, schemaWrapperInfo) {
|
|
278
|
+
var _a, _b;
|
|
279
|
+
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
280
|
+
var email = ((_a = schemaWrapperInfo.propertySchemaObject.format) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === 'email' || false;
|
|
281
|
+
var uri = ((_b = schemaWrapperInfo.propertySchemaObject.format) === null || _b === void 0 ? void 0 : _b.toLowerCase()) === 'uri' || false;
|
|
282
|
+
return (+required +
|
|
283
|
+
+email +
|
|
284
|
+
+uri +
|
|
285
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maxLength) +
|
|
286
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minLength) +
|
|
287
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maximum) +
|
|
288
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minimum) +
|
|
289
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maxItems) +
|
|
290
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minItems) +
|
|
291
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.pattern));
|
|
292
|
+
};
|
|
167
293
|
OpenApiDocConverter.prototype.getPropertyTypeScriptType = function (schemaWrapperInfo) {
|
|
168
294
|
if (schemaWrapperInfo.propertySchemaObject.type === 'array' && schemaWrapperInfo.propertySchemaObject.items) {
|
|
169
295
|
return schemaWrapperInfo.propertySchemaObject.items.type;
|
|
@@ -177,10 +303,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
177
303
|
else if (schemaWrapperInfo.propertySchemaObject.format === 'date-time') {
|
|
178
304
|
return 'Date';
|
|
179
305
|
}
|
|
180
|
-
|
|
181
|
-
throw new Error('Invalid Property Type');
|
|
182
|
-
}
|
|
183
|
-
return schemaWrapperInfo.propertySchemaObject.type;
|
|
306
|
+
return schemaWrapperInfo.propertySchemaObject.type || 'string';
|
|
184
307
|
};
|
|
185
308
|
OpenApiDocConverter.prototype.parseRef = function (schemaWrapperInfo) {
|
|
186
309
|
var regexResult;
|
|
@@ -196,17 +319,24 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
196
319
|
};
|
|
197
320
|
OpenApiDocConverter.prototype.getImportTypes = function (entityName, schemaWrapperInfo) {
|
|
198
321
|
var _this = this;
|
|
322
|
+
var _a;
|
|
323
|
+
var schemaProperties = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || { properties: {} })[entityName].properties || {};
|
|
324
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
325
|
+
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 })); });
|
|
199
326
|
return schemaWrapperInfo.referenceProperties
|
|
200
327
|
.map(function (t) { return t.referenceTypeName; })
|
|
201
|
-
.filter(function (t) { return t !== entityName; })
|
|
202
328
|
.filter(function (value, index, array) { return array.indexOf(value) === index; })
|
|
203
329
|
.map(function (value) {
|
|
204
330
|
var _a;
|
|
205
|
-
var
|
|
331
|
+
var refSchema = (((_a = _this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[value];
|
|
332
|
+
var props = properties.filter(function (t) { return t.items.$ref === value || t.$ref === value; });
|
|
206
333
|
return {
|
|
207
334
|
name: value,
|
|
208
|
-
kebabCasedTypeName:
|
|
209
|
-
isEnum: (
|
|
335
|
+
kebabCasedTypeName: (0, lodash_1.kebabCase)(value),
|
|
336
|
+
isEnum: (refSchema.enum || []).length > 0,
|
|
337
|
+
areAllArrays: props.every(function (val) { return val.type === 'array'; }),
|
|
338
|
+
hasArrays: props.some(function (val) { return val.type === 'array'; }),
|
|
339
|
+
isSelfReferencing: entityName === value,
|
|
210
340
|
};
|
|
211
341
|
});
|
|
212
342
|
};
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.52.3",
|
|
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",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "npm run format && npm run lint && tsc && cp -rfv ./src/templates ./lib",
|
|
9
9
|
"format": "prettier --write \"src/**/*.ts\"",
|
|
10
|
-
"lint": "eslint . --ext .ts --output-file ./eslint-report.json --format json",
|
|
10
|
+
"lint": "eslint . --ext .ts --output-file ./eslint-report.json --format json && eslint . --ext .ts --output-file ./eslint-report.html --format html ",
|
|
11
|
+
"link": "npm run build && cd lib && npm link && cd ..",
|
|
11
12
|
"test": "npm run build && jest --collect-coverage",
|
|
12
13
|
"prep:lib": "rm -rv ./lib/*.spec.* && rm -rv ./lib/**/*.spec.* && cp -v ./package.json ./lib/ && cp -v ./LICENSE ./lib/ && cp -v ./README.md ./lib/",
|
|
13
14
|
"debug": "npm run build && node --inspect-brk ./lib/app.js"
|
|
@@ -40,9 +41,9 @@
|
|
|
40
41
|
"@types/lodash": "^4.14.182",
|
|
41
42
|
"@types/node": "^16.11.27",
|
|
42
43
|
"@types/pluralize": "^0.0.29",
|
|
43
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
|
44
|
-
"@typescript-eslint/parser": "^5.
|
|
45
|
-
"eslint": "^8.
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^5.32.0",
|
|
45
|
+
"@typescript-eslint/parser": "^5.32.0",
|
|
46
|
+
"eslint": "^8.21.0",
|
|
46
47
|
"eslint-config-prettier": "^8.5.0",
|
|
47
48
|
"eslint-config-standard": "^17.0.0",
|
|
48
49
|
"eslint-plugin-import": "^2.26.0",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"jest-junit": "^13.2.0",
|
|
53
54
|
"openapi3-ts": "^2.0.2",
|
|
54
55
|
"prettier": "^2.7.1",
|
|
55
|
-
"rxjs": "^7.5.
|
|
56
|
+
"rxjs": "^7.5.7",
|
|
56
57
|
"ts-jest": "^27.1.3",
|
|
57
58
|
"typescript": "^4.6.3"
|
|
58
59
|
},
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/* istanbul ignore file */
|
|
2
|
+
/**
|
|
3
|
+
* This file is generated by the openapi-ts-generator
|
|
4
|
+
* #entity.ts.hbs
|
|
5
|
+
* For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
|
|
6
|
+
* Do not edit.
|
|
7
|
+
*/
|
|
8
|
+
{{#if importTypes}}{{#importTypes}}{{#unless isSelfReferencing}}{{#if isEnum}}
|
|
9
|
+
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{else}}
|
|
10
|
+
import { {{name}} } from './{{kebabCasedTypeName}}.entity';{{/if}}{{/unless}}{{/importTypes}}
|
|
11
|
+
|
|
12
|
+
{{/if}}{{#if description}}/**
|
|
13
|
+
* {{description}}
|
|
14
|
+
*/
|
|
15
|
+
{{/if}}// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
16
|
+
export class {{{name}}} {
|
|
17
|
+
{{#valueProperties}}{{#if description}}/**
|
|
18
|
+
* {{description}}
|
|
19
|
+
*/
|
|
20
|
+
{{/if}}
|
|
21
|
+
{{name}}?: {{typeScriptType}}{{#if isArray}}[]{{/if}}{{#unless required}} | null{{/unless}};
|
|
22
|
+
{{/valueProperties}}
|
|
23
|
+
{{#referenceProperties}}
|
|
24
|
+
{{#if isEnum}}
|
|
25
|
+
{{name}}?: {{referenceTypeName}}{{#if isArray}}[]{{/if}} | string{{#if isArray}}[]{{/if}};
|
|
26
|
+
{{else}}
|
|
27
|
+
{{name}}?: Partial<{{referenceTypeName}}{{#if isArray}}[]{{/if}}>;
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{/referenceProperties}}
|
|
30
|
+
}
|
package/templates/enum.ts.hbs
CHANGED
|
@@ -10,13 +10,28 @@
|
|
|
10
10
|
* {{description}}
|
|
11
11
|
*/
|
|
12
12
|
{{/if}}export enum {{{name}}} {
|
|
13
|
-
{{#enumValues}}
|
|
13
|
+
{{#enumValues}}{{#if description}}/**
|
|
14
|
+
* {{description}}
|
|
15
|
+
*/
|
|
16
|
+
{{/if}}
|
|
14
17
|
{{name}} = {{key}},
|
|
15
18
|
{{/enumValues}}
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
{{#if description}}/**
|
|
22
|
+
* {{description}}
|
|
23
|
+
*/
|
|
24
|
+
{{/if}}export enum {{singularName}}Names {
|
|
25
|
+
{{#enumValues}}
|
|
26
|
+
{{#if description}}/**
|
|
27
|
+
* {{description}}
|
|
28
|
+
*/
|
|
29
|
+
{{/if}} {{snakeCaseName}} = '{{name}}',
|
|
30
|
+
{{/enumValues}}
|
|
31
|
+
}
|
|
32
|
+
|
|
18
33
|
export const {{{camelSingularName}}}Values = [
|
|
19
34
|
{{#enumValues}}
|
|
20
|
-
{ key: {{key}}, name: '{{titleName}}'},
|
|
35
|
+
{ key: {{key}}, name: '{{name}}', displayText: '{{titleName}}'},
|
|
21
36
|
{{/enumValues}}
|
|
22
37
|
];
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* eslint-disable no-useless-escape */
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
1
3
|
/* istanbul ignore file */
|
|
2
4
|
/**
|
|
3
5
|
* This file is generated by the openapi-ts-generator
|
|
@@ -5,39 +7,50 @@
|
|
|
5
7
|
* For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
|
|
6
8
|
* Do not edit.
|
|
7
9
|
*/
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
9
10
|
import { FormControl, FormArray, FormGroup, Validators } from '@angular/forms'; //NOSONAR
|
|
11
|
+
import { I{{name}}Form } from './{{kebabCasedName}}.form';{{#if importTypes}}{{#importTypes}}{{#unless isSelfReferencing}}{{#if isEnum}}
|
|
12
|
+
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{else}}
|
|
13
|
+
import { I{{name}}Form } from './{{kebabCasedTypeName}}.form';{{#unless areAllArrays}}
|
|
14
|
+
import { {{name}}FormGroupFac } from './{{kebabCasedTypeName}}.form-group-fac';{{/unless}}{{/if}}{{/unless}}{{/importTypes}}{{/if}}
|
|
10
15
|
|
|
11
|
-
export function {{name}}FormGroupFac(): FormGroup {
|
|
12
|
-
return new FormGroup({
|
|
16
|
+
export function {{name}}FormGroupFac(): FormGroup<I{{name}}Form> {
|
|
17
|
+
return new FormGroup<I{{name}}Form>({
|
|
13
18
|
{{#valueProperties}}
|
|
14
19
|
{{#if isArray}}
|
|
15
20
|
{{#if hasMultipleValidators}}
|
|
16
|
-
{{name}}: new FormControl([], Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}])),
|
|
21
|
+
{{name}}: new FormArray<FormControl<{{typeScriptType}}>>([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]) })),
|
|
17
22
|
{{else}}
|
|
18
|
-
{{name}}: new FormControl([]{{#if
|
|
23
|
+
{{name}}: new FormArray<FormControl<{{typeScriptType}}>>([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}} }{{/if}}),
|
|
19
24
|
{{/if}}
|
|
20
25
|
{{else}}
|
|
21
26
|
{{#if hasMultipleValidators}}
|
|
22
|
-
{{name}}: new FormControl(
|
|
27
|
+
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null | undefined{{/unless}}>({{{initialValue}}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{#if email}}Validators.email, {{/if}}{{#if uri}}Validators.pattern('(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?'), {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
|
|
23
28
|
{{else}}
|
|
24
|
-
{{name}}: new FormControl(
|
|
29
|
+
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null | undefined{{/unless}}>({{{initialValue}}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{#if email}}Validators.email {{/if}}{{#if uri}}Validators.pattern('(https?://)?([\\da-z.-]+)\\.([a-z.]{2,6})[/\\w .-]*/?') {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
|
|
25
30
|
{{/if}}
|
|
26
31
|
{{/if}}
|
|
27
32
|
{{/valueProperties}}
|
|
28
33
|
{{#referenceProperties}}
|
|
29
34
|
{{#if isArray}}
|
|
30
35
|
{{#if hasMultipleValidators}}
|
|
31
|
-
{{name}}: new FormArray([], Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}])),
|
|
36
|
+
{{name}}: new FormArray<FormGroup<I{{typeScriptType}}Form>>([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]) }),
|
|
32
37
|
{{else}}
|
|
33
|
-
{{name}}: new FormArray([]{{#if
|
|
38
|
+
{{name}}: new FormArray<FormGroup<I{{typeScriptType}}Form>>([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}} } {{/if}}),
|
|
39
|
+
{{/if}}
|
|
40
|
+
{{else if isEnum}}
|
|
41
|
+
{{#if hasMultipleValidators}}
|
|
42
|
+
{{name}}: new FormControl<{{typeScriptType}} | string{{#unless required}} | null | undefined{{/unless}}>({{{initialValue}}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
|
|
43
|
+
{{else}}
|
|
44
|
+
{{name}}: new FormControl<{{typeScriptType}} | string{{#unless required}} | null | undefined{{/unless}}>({{{initialValue}}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
|
|
34
45
|
{{/if}}
|
|
35
46
|
{{else}}
|
|
47
|
+
{{#unless isSameAsParentTypescriptType}}
|
|
36
48
|
{{#if hasMultipleValidators}}
|
|
37
|
-
{{name}}: new
|
|
49
|
+
{{name}}: new FormGroup<I{{typeScriptType}}Form>({{#if isSameAsParentTypescriptType}}null{{else}}{{typeScriptType}}FormGroupFac().controls{{/if}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]) }),
|
|
38
50
|
{{else}}
|
|
39
|
-
{{name}}: new
|
|
51
|
+
{{name}}: new FormGroup<I{{typeScriptType}}Form>({{#if isSameAsParentTypescriptType}}null{{else}}{{typeScriptType}}FormGroupFac().controls{{/if}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}} } {{/if}}),
|
|
40
52
|
{{/if}}
|
|
53
|
+
{{/unless}}
|
|
41
54
|
{{/if}}
|
|
42
55
|
{{/referenceProperties}}
|
|
43
56
|
});
|