openapi-ts-generator 5.222.2 → 5.223.7
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.
|
@@ -7,5 +7,6 @@ export declare class FormGroupGenerator extends BaseGenerator<IEntity> {
|
|
|
7
7
|
constructor(options: IGeneratorOptions);
|
|
8
8
|
generate(templateData: ITemplateData): void;
|
|
9
9
|
registerHelpers(): void;
|
|
10
|
+
registerValidatorHelper(validatorName: string, angularValidatorName?: string): void;
|
|
10
11
|
validatorFactory(propertyCollection: PropertyType, propertyContext: IHelperContext, validationName: string, angularValidatorFunctionName: string): string;
|
|
11
12
|
}
|
|
@@ -37,17 +37,19 @@ var FormGroupGenerator = /** @class */ (function (_super) {
|
|
|
37
37
|
});
|
|
38
38
|
};
|
|
39
39
|
FormGroupGenerator.prototype.registerHelpers = function () {
|
|
40
|
+
this.registerValidatorHelper('minimum', 'min');
|
|
41
|
+
this.registerValidatorHelper('maximum', 'max');
|
|
42
|
+
this.registerValidatorHelper('minLength');
|
|
43
|
+
this.registerValidatorHelper('maxLength');
|
|
44
|
+
this.registerValidatorHelper('maxItems', 'maxLength');
|
|
45
|
+
this.registerValidatorHelper('minItems', 'minLength');
|
|
46
|
+
this.registerValidatorHelper('pattern');
|
|
47
|
+
};
|
|
48
|
+
FormGroupGenerator.prototype.registerValidatorHelper = function (validatorName, angularValidatorName) {
|
|
40
49
|
var _this = this;
|
|
41
|
-
|
|
42
|
-
HandleBars.registerHelper(
|
|
43
|
-
|
|
44
|
-
return _this.validatorFactory(x, y, 'minLength', 'minLength');
|
|
45
|
-
});
|
|
46
|
-
HandleBars.registerHelper('maxLengthValidator', function (x, y) {
|
|
47
|
-
return _this.validatorFactory(x, y, 'maxLength', 'maxLength');
|
|
48
|
-
});
|
|
49
|
-
HandleBars.registerHelper('patternValidator', function (x, y) {
|
|
50
|
-
return _this.validatorFactory(x, y, 'pattern', 'pattern');
|
|
50
|
+
if (angularValidatorName === void 0) { angularValidatorName = validatorName; }
|
|
51
|
+
HandleBars.registerHelper("".concat(validatorName, "Validator"), function (x, y) {
|
|
52
|
+
return _this.validatorFactory(x, y, validatorName, angularValidatorName);
|
|
51
53
|
});
|
|
52
54
|
};
|
|
53
55
|
FormGroupGenerator.prototype.validatorFactory = function (propertyCollection, propertyContext, validationName, angularValidatorFunctionName) {
|
|
@@ -24,6 +24,8 @@ export interface IImportType {
|
|
|
24
24
|
kebabCasedTypeName: string;
|
|
25
25
|
name: string;
|
|
26
26
|
isEnum: boolean;
|
|
27
|
+
areAllArrays: boolean;
|
|
28
|
+
isSelfReferencing: boolean;
|
|
27
29
|
}
|
|
28
30
|
export interface IValueProperty {
|
|
29
31
|
name: string;
|
|
@@ -37,6 +39,8 @@ export interface IValueProperty {
|
|
|
37
39
|
minLength?: number;
|
|
38
40
|
maximum?: number;
|
|
39
41
|
minimum?: number;
|
|
42
|
+
maxItems?: number;
|
|
43
|
+
minItems?: number;
|
|
40
44
|
description?: string;
|
|
41
45
|
pattern?: string;
|
|
42
46
|
initialValue: string;
|
|
@@ -46,8 +50,14 @@ export interface IReferenceProperty {
|
|
|
46
50
|
snakeCaseName: string;
|
|
47
51
|
referenceTypeName: string;
|
|
48
52
|
typeScriptType: string;
|
|
49
|
-
kebabCasedTypeScriptType: string;
|
|
50
53
|
hasValidators: boolean;
|
|
54
|
+
hasMultipleValidators: boolean;
|
|
55
|
+
maxItems?: number;
|
|
56
|
+
minItems?: number;
|
|
57
|
+
maxLength?: number;
|
|
58
|
+
minLength?: number;
|
|
59
|
+
maximum?: number;
|
|
60
|
+
minimum?: number;
|
|
51
61
|
isArray: boolean;
|
|
52
62
|
required: boolean;
|
|
53
63
|
isEnum?: boolean;
|
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
|
}
|
|
@@ -81,7 +80,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
81
80
|
var _a, _b;
|
|
82
81
|
var key = (_a = _this.startNumberregex.exec(x)) === null || _a === void 0 ? void 0 : _a.at(0);
|
|
83
82
|
var name = ((_b = _this.endAlphaNumRegex.exec(x)) === null || _b === void 0 ? void 0 : _b.at(0)) || '';
|
|
84
|
-
return { key: key ? +key : 0, name: name, titleName:
|
|
83
|
+
return { key: key ? +key : 0, name: name, titleName: (0, lodash_1.startCase)(name) };
|
|
85
84
|
}));
|
|
86
85
|
};
|
|
87
86
|
OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (schemaWrapperInfo) {
|
|
@@ -120,12 +119,14 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
120
119
|
name: propertyName,
|
|
121
120
|
initialValue: initialValue,
|
|
122
121
|
isArray: false,
|
|
123
|
-
snakeCaseName:
|
|
122
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
124
123
|
typeScriptType: this.getPropertyTypeScriptType(schemaWrapperInfo),
|
|
125
124
|
maxLength: schemaWrapperInfo.propertySchemaObject.maxLength,
|
|
126
125
|
minLength: schemaWrapperInfo.propertySchemaObject.minLength,
|
|
127
126
|
maximum: schemaWrapperInfo.propertySchemaObject.maximum,
|
|
128
127
|
minimum: schemaWrapperInfo.propertySchemaObject.minimum,
|
|
128
|
+
minItems: schemaWrapperInfo.propertySchemaObject.minItems,
|
|
129
|
+
maxItems: schemaWrapperInfo.propertySchemaObject.maxItems,
|
|
129
130
|
description: schemaWrapperInfo.propertySchemaObject.description,
|
|
130
131
|
pattern: schemaWrapperInfo.propertySchemaObject.pattern,
|
|
131
132
|
hasMultipleValidators: validatorCount > 1,
|
|
@@ -146,26 +147,28 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
146
147
|
initialValue: initialValue,
|
|
147
148
|
name: propertyName,
|
|
148
149
|
isArray: true,
|
|
149
|
-
snakeCaseName:
|
|
150
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
150
151
|
hasMultipleValidators: false,
|
|
151
152
|
hasValidators: validatorCount > 0,
|
|
152
153
|
};
|
|
153
154
|
};
|
|
154
155
|
OpenApiDocConverter.prototype.getInitialValue = function (propertyName, schemaWrapperInfo) {
|
|
155
|
-
var _a;
|
|
156
|
+
var _a, _b;
|
|
156
157
|
var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
|
|
157
158
|
var isRequired = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
158
|
-
|
|
159
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
160
|
+
var refName = (((_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) || {})[propertyName].$ref;
|
|
161
|
+
var refObject = (((_b = this.apiDocument.components) === null || _b === void 0 ? void 0 : _b.schemas) || {})[refName];
|
|
159
162
|
var defaultValue = (schemaWrapperInfo.componentSchemaObject.default || (refObject === null || refObject === void 0 ? void 0 : refObject.default) || ((refObject === null || refObject === void 0 ? void 0 : refObject.enum) || [])[0]);
|
|
160
|
-
if (
|
|
163
|
+
if (!isRequired) {
|
|
164
|
+
return 'null';
|
|
165
|
+
}
|
|
166
|
+
else if (defaultValue && refObject.enum) {
|
|
161
167
|
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
162
168
|
}
|
|
163
169
|
else if (defaultValue) {
|
|
164
170
|
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
165
171
|
}
|
|
166
|
-
else if (!isRequired) {
|
|
167
|
-
return 'null';
|
|
168
|
-
}
|
|
169
172
|
else if (typescriptType === 'Date') {
|
|
170
173
|
return 'new Date()';
|
|
171
174
|
}
|
|
@@ -183,8 +186,9 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
183
186
|
return __assign(__assign({}, this.convertReferenceObjectToPropertyType(propertyName, schemaWrapperInfo)), { isArray: true });
|
|
184
187
|
};
|
|
185
188
|
OpenApiDocConverter.prototype.convertReferenceObjectToPropertyType = function (propertyName, schemaWrapperInfo) {
|
|
186
|
-
var _a;
|
|
189
|
+
var _a, _b;
|
|
187
190
|
var propertySchema = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[this.parseRef(schemaWrapperInfo)];
|
|
191
|
+
var refSchema = (((_b = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _b === void 0 ? void 0 : _b.properties) || {})[propertyName];
|
|
188
192
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
189
193
|
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
190
194
|
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
@@ -193,13 +197,19 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
193
197
|
required: required,
|
|
194
198
|
name: propertyName,
|
|
195
199
|
initialValue: initialValue,
|
|
196
|
-
snakeCaseName:
|
|
200
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
197
201
|
referenceTypeName: typeName,
|
|
198
202
|
typeScriptType: typeName,
|
|
199
|
-
kebabCasedTypeScriptType: (0, lodash_1.kebabCase)(typeName),
|
|
200
203
|
isArray: false,
|
|
201
204
|
isEnum: (propertySchema.enum || []).length > 0,
|
|
202
205
|
hasValidators: validatorCount > 0,
|
|
206
|
+
hasMultipleValidators: validatorCount > 1,
|
|
207
|
+
maxLength: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maxLength,
|
|
208
|
+
minLength: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minLength,
|
|
209
|
+
maximum: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maximum,
|
|
210
|
+
minimum: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minimum,
|
|
211
|
+
minItems: refSchema === null || refSchema === void 0 ? void 0 : refSchema.minItems,
|
|
212
|
+
maxItems: refSchema === null || refSchema === void 0 ? void 0 : refSchema.maxItems,
|
|
203
213
|
};
|
|
204
214
|
};
|
|
205
215
|
OpenApiDocConverter.prototype.getValidatorCount = function (propertyName, schemaWrapperInfo) {
|
|
@@ -209,6 +219,8 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
209
219
|
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minLength) +
|
|
210
220
|
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maximum) +
|
|
211
221
|
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minimum) +
|
|
222
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.maxItems) +
|
|
223
|
+
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.minItems) +
|
|
212
224
|
+this.convertValidator(schemaWrapperInfo.propertySchemaObject.pattern));
|
|
213
225
|
};
|
|
214
226
|
OpenApiDocConverter.prototype.getPropertyTypeScriptType = function (schemaWrapperInfo) {
|
|
@@ -240,17 +252,23 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
240
252
|
};
|
|
241
253
|
OpenApiDocConverter.prototype.getImportTypes = function (entityName, schemaWrapperInfo) {
|
|
242
254
|
var _this = this;
|
|
255
|
+
var _a;
|
|
256
|
+
var schemaProperties = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || { properties: {} })[entityName].properties || {};
|
|
257
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
258
|
+
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 })); });
|
|
243
259
|
return schemaWrapperInfo.referenceProperties
|
|
244
260
|
.map(function (t) { return t.referenceTypeName; })
|
|
245
|
-
.filter(function (t) { return t !== entityName; })
|
|
246
261
|
.filter(function (value, index, array) { return array.indexOf(value) === index; })
|
|
247
262
|
.map(function (value) {
|
|
248
263
|
var _a;
|
|
249
|
-
var
|
|
264
|
+
var refSchema = (((_a = _this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[value];
|
|
265
|
+
var props = properties.filter(function (t) { return t.items.$ref === value || t.$ref === value; });
|
|
250
266
|
return {
|
|
251
267
|
name: value,
|
|
252
|
-
kebabCasedTypeName:
|
|
253
|
-
isEnum: (
|
|
268
|
+
kebabCasedTypeName: (0, lodash_1.kebabCase)(value),
|
|
269
|
+
isEnum: (refSchema.enum || []).length > 0,
|
|
270
|
+
areAllArrays: props.every(function (val) { return val.type === 'array'; }),
|
|
271
|
+
isSelfReferencing: entityName === value,
|
|
254
272
|
};
|
|
255
273
|
});
|
|
256
274
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.223.7",
|
|
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",
|
|
@@ -6,39 +6,39 @@
|
|
|
6
6
|
* For issues or feature request, visit the repo: https://github.com/ikemtz/openapi-ts-generator
|
|
7
7
|
* Do not edit.
|
|
8
8
|
*/
|
|
9
|
-
import { FormControl, FormArray, FormGroup, Validators } from '@angular/forms'; //NOSONAR{{#
|
|
10
|
-
import { {{
|
|
11
|
-
import { I{{
|
|
9
|
+
import { FormControl, FormArray, FormGroup, Validators } from '@angular/forms'; //NOSONAR{{#if importTypes}}{{#importTypes}}{{#unless areAllArrays}}{{#if isEnum}}
|
|
10
|
+
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{else}}
|
|
11
|
+
import { I{{name}} } from './{{kebabCasedTypeName}}.model';{{/if}}{{/unless}}{{/importTypes}}{{/if}}
|
|
12
12
|
|
|
13
13
|
export function {{name}}FormGroupFac(): FormGroup {
|
|
14
14
|
return new FormGroup({
|
|
15
15
|
{{#valueProperties}}
|
|
16
16
|
{{#if isArray}}
|
|
17
17
|
{{#if hasMultipleValidators}}
|
|
18
|
-
{{name}}: new FormControl([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]) })),
|
|
18
|
+
{{name}}: new FormControl([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]) })),
|
|
19
19
|
{{else}}
|
|
20
|
-
{{name}}: new FormControl([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}} }{{/if}}),
|
|
20
|
+
{{name}}: new FormControl([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}} }{{/if}}),
|
|
21
21
|
{{/if}}
|
|
22
22
|
{{else}}
|
|
23
23
|
{{#if hasMultipleValidators}}
|
|
24
|
-
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
|
|
24
|
+
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
|
|
25
25
|
{{else}}
|
|
26
|
-
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
|
|
26
|
+
{{name}}: new FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "valueProperties"}}{{maxLengthValidator "valueProperties"}}{{minimumValidator "valueProperties"}}{{maximumValidator "valueProperties"}}{{minItemsValidator "valueProperties"}}{{maxItemsValidator "valueProperties"}}{{{patternValidator "valueProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
|
|
27
27
|
{{/if}}
|
|
28
28
|
{{/if}}
|
|
29
29
|
{{/valueProperties}}
|
|
30
30
|
{{#referenceProperties}}
|
|
31
31
|
{{#if isArray}}
|
|
32
32
|
{{#if hasMultipleValidators}}
|
|
33
|
-
{{name}}: new FormArray([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]) }),
|
|
33
|
+
{{name}}: new FormArray([], { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]) }),
|
|
34
34
|
{{else}}
|
|
35
|
-
{{name}}: new FormArray([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}} } {{/if}}),
|
|
35
|
+
{{name}}: new FormArray([]{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{minItemsValidator "referenceProperties"}}{{maxItemsValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}} } {{/if}}),
|
|
36
36
|
{{/if}}
|
|
37
37
|
{{else}}
|
|
38
38
|
{{#if hasMultipleValidators}}
|
|
39
|
-
{{name}}: new FormControl<{{#unless isEnum}}I{{/unless}}{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}, { validators: Validators.compose([{{#if required}}Validators.required, {{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}]){{#if required}}, nonNullable: true{{/if}} }),
|
|
39
|
+
{{name}}: new FormControl<{{#unless isEnum}}I{{/unless}}{{typeScriptType}}{{#unless required}} | null{{/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}} }),
|
|
40
40
|
{{else}}
|
|
41
|
-
{{name}}: new FormControl<{{#unless isEnum}}I{{/unless}}{{typeScriptType}}{{#unless required}} | null{{/unless}}>({{{initialValue}}}{{#if hasValidators}}, { validators: {{#if required}}Validators.required{{/if}}{{minLengthValidator "referenceProperties"}}{{maxLengthValidator "referenceProperties"}}{{minimumValidator "referenceProperties"}}{{maximumValidator "referenceProperties"}}{{{patternValidator "referenceProperties"}}}{{#if required}}, nonNullable: true{{/if}} } {{/if}}),
|
|
41
|
+
{{name}}: new FormControl<{{#unless isEnum}}I{{/unless}}{{typeScriptType}}{{#unless required}} | null{{/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}}),
|
|
42
42
|
{{/if}}
|
|
43
43
|
{{/if}}
|
|
44
44
|
{{/referenceProperties}}
|
package/templates/model.ts.hbs
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
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
|
-
{{#if importTypes}}{{#importTypes}}{{#if isEnum}}
|
|
8
|
+
{{#if importTypes}}{{#importTypes}}{{#unless isSelfReferencing}}{{#if isEnum}}
|
|
9
9
|
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{else}}
|
|
10
|
-
import { I{{name}} } from './{{kebabCasedTypeName}}.model';{{/if}}{{/importTypes}}
|
|
10
|
+
import { I{{name}} } from './{{kebabCasedTypeName}}.model';{{/if}}{{/unless}}{{/importTypes}}
|
|
11
11
|
|
|
12
12
|
{{/if}}{{#if description}}/**
|
|
13
13
|
* {{description}}
|