openapi-ts-generator 5.225.9 → 5.225.11
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.
|
@@ -12,15 +12,15 @@ export declare class OpenApiDocConverter {
|
|
|
12
12
|
convertPaths(): IPath[];
|
|
13
13
|
convertEntities(): IEntity[];
|
|
14
14
|
buildSchemaWrapperInfoForEnum(schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
15
|
-
buildSchemaWrapperInfo(
|
|
16
|
-
convertArray(
|
|
17
|
-
convertSchemaObjectToPropertyType(
|
|
15
|
+
buildSchemaWrapperInfo(schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
16
|
+
convertArray(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): void;
|
|
17
|
+
convertSchemaObjectToPropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
18
18
|
private convertValidator;
|
|
19
|
-
convertArrayObjectToValuePropertyType(
|
|
19
|
+
convertArrayObjectToValuePropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IValueProperty;
|
|
20
20
|
getInitialValue(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
21
|
-
getInitialTestValue(
|
|
22
|
-
convertArrayObjectToReferencePropertyType(
|
|
23
|
-
convertReferenceObjectToPropertyType(
|
|
21
|
+
getInitialTestValue(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
22
|
+
convertArrayObjectToReferencePropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IReferenceProperty;
|
|
23
|
+
convertReferenceObjectToPropertyType(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): IReferenceProperty;
|
|
24
24
|
getValidatorCount(propertyName: string, schemaWrapperInfo: SchemaWrapperInfo): number;
|
|
25
25
|
getPropertyTypeScriptType(schemaWrapperInfo: SchemaWrapperInfo): string;
|
|
26
26
|
parseRef(schemaWrapperInfo: SchemaWrapperInfo): string;
|
package/openapidoc-converter.js
CHANGED
|
@@ -52,7 +52,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
52
52
|
this.buildSchemaWrapperInfoForEnum(schemaWrapperInfo);
|
|
53
53
|
}
|
|
54
54
|
else {
|
|
55
|
-
this.buildSchemaWrapperInfo(
|
|
55
|
+
this.buildSchemaWrapperInfo(schemaWrapperInfo);
|
|
56
56
|
}
|
|
57
57
|
schemaWrapperInfo.updateReferenceProperties(this.options);
|
|
58
58
|
var entity = {
|
|
@@ -84,38 +84,38 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
84
84
|
return { key: key ? +key : 0, name: name, titleName: (0, lodash_1.startCase)(name) };
|
|
85
85
|
}));
|
|
86
86
|
};
|
|
87
|
-
OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (
|
|
87
|
+
OpenApiDocConverter.prototype.buildSchemaWrapperInfo = function (schemaWrapperInfo) {
|
|
88
88
|
for (var propertyName in schemaWrapperInfo.componentSchemaObject.properties) {
|
|
89
89
|
if ((schemaWrapperInfo.propertySchemaObject = schemaWrapperInfo.componentSchemaObject.properties[propertyName]).type && // NOSONAR
|
|
90
90
|
schemaWrapperInfo.propertySchemaObject.type !== 'array') {
|
|
91
|
-
schemaWrapperInfo.valueProperties.push(this.convertSchemaObjectToPropertyType(
|
|
91
|
+
schemaWrapperInfo.valueProperties.push(this.convertSchemaObjectToPropertyType(propertyName, schemaWrapperInfo));
|
|
92
92
|
}
|
|
93
93
|
else {
|
|
94
94
|
schemaWrapperInfo.propertyReferenceObject = schemaWrapperInfo.componentSchemaObject.properties[propertyName];
|
|
95
95
|
if (schemaWrapperInfo.propertyReferenceObject.$ref) {
|
|
96
|
-
schemaWrapperInfo.referenceProperties.push(this.convertReferenceObjectToPropertyType(
|
|
96
|
+
schemaWrapperInfo.referenceProperties.push(this.convertReferenceObjectToPropertyType(propertyName, schemaWrapperInfo));
|
|
97
97
|
}
|
|
98
98
|
else if (schemaWrapperInfo.propertySchemaObject.type === 'array' && schemaWrapperInfo.propertySchemaObject.items) {
|
|
99
|
-
this.convertArray(
|
|
99
|
+
this.convertArray(propertyName, schemaWrapperInfo);
|
|
100
100
|
}
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
-
OpenApiDocConverter.prototype.convertArray = function (
|
|
104
|
+
OpenApiDocConverter.prototype.convertArray = function (propertyName, schemaWrapperInfo) {
|
|
105
105
|
var arraySchemaObject = schemaWrapperInfo.propertySchemaObject.items;
|
|
106
106
|
if (arraySchemaObject.type) {
|
|
107
|
-
schemaWrapperInfo.valueProperties.push(this.convertArrayObjectToValuePropertyType(
|
|
107
|
+
schemaWrapperInfo.valueProperties.push(this.convertArrayObjectToValuePropertyType(propertyName, schemaWrapperInfo));
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
110
|
schemaWrapperInfo.propertyReferenceObject = schemaWrapperInfo.propertySchemaObject.items;
|
|
111
|
-
schemaWrapperInfo.referenceProperties.push(this.convertArrayObjectToReferencePropertyType(
|
|
111
|
+
schemaWrapperInfo.referenceProperties.push(this.convertArrayObjectToReferencePropertyType(propertyName, schemaWrapperInfo));
|
|
112
112
|
}
|
|
113
113
|
};
|
|
114
|
-
OpenApiDocConverter.prototype.convertSchemaObjectToPropertyType = function (
|
|
114
|
+
OpenApiDocConverter.prototype.convertSchemaObjectToPropertyType = function (propertyName, schemaWrapperInfo) {
|
|
115
115
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
116
116
|
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
117
117
|
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
118
|
-
var initialTestValue = this.getInitialTestValue(
|
|
118
|
+
var initialTestValue = this.getInitialTestValue(propertyName, schemaWrapperInfo);
|
|
119
119
|
return {
|
|
120
120
|
required: required,
|
|
121
121
|
name: propertyName,
|
|
@@ -140,11 +140,11 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
140
140
|
var exists = validationValue !== null && validationValue !== undefined;
|
|
141
141
|
return +exists;
|
|
142
142
|
};
|
|
143
|
-
OpenApiDocConverter.prototype.convertArrayObjectToValuePropertyType = function (
|
|
143
|
+
OpenApiDocConverter.prototype.convertArrayObjectToValuePropertyType = function (propertyName, schemaWrapperInfo) {
|
|
144
144
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
145
145
|
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
146
146
|
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
147
|
-
var initialTestValue = this.getInitialTestValue(
|
|
147
|
+
var initialTestValue = this.getInitialTestValue(propertyName, schemaWrapperInfo);
|
|
148
148
|
return {
|
|
149
149
|
required: required,
|
|
150
150
|
typeScriptType: this.getPropertyTypeScriptType(schemaWrapperInfo),
|
|
@@ -187,7 +187,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
187
187
|
return "''";
|
|
188
188
|
}
|
|
189
189
|
};
|
|
190
|
-
OpenApiDocConverter.prototype.getInitialTestValue = function (
|
|
190
|
+
OpenApiDocConverter.prototype.getInitialTestValue = function (propertyName, schemaWrapperInfo) {
|
|
191
191
|
var _a, _b, _c;
|
|
192
192
|
var typescriptType = this.getPropertyTypeScriptType(schemaWrapperInfo);
|
|
193
193
|
var schemaObject = (((_a = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _a === void 0 ? void 0 : _a.properties) || {})[propertyName];
|
|
@@ -200,11 +200,8 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
200
200
|
if (defaultValue && refObject.enum) {
|
|
201
201
|
return "".concat(schemaWrapperInfo.propertyReferenceObject['$ref'], ".").concat(defaultValue.split(' ').pop());
|
|
202
202
|
}
|
|
203
|
-
else if (refObject
|
|
204
|
-
return schemaObject.type === 'array' ? "[
|
|
205
|
-
}
|
|
206
|
-
else if (refObject && parentTypeName == refName) {
|
|
207
|
-
return schemaObject.type === 'array' ? "[]" : "null";
|
|
203
|
+
else if (refObject) {
|
|
204
|
+
return schemaObject.type === 'array' ? "[]" : "undefined";
|
|
208
205
|
}
|
|
209
206
|
else if (defaultValue) {
|
|
210
207
|
return "'".concat(defaultValue.split(' ').pop(), "'");
|
|
@@ -221,22 +218,22 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
221
218
|
else {
|
|
222
219
|
var retValue = (0, lodash_1.snakeCase)(propertyName).toUpperCase();
|
|
223
220
|
while (minLength && retValue.length < minLength) {
|
|
224
|
-
retValue
|
|
221
|
+
retValue = "".concat(retValue, "_").concat(retValue);
|
|
225
222
|
}
|
|
226
|
-
return "'".concat(maxLength ?
|
|
223
|
+
return "'".concat(maxLength ? retValue.substring(0, maxLength) : retValue, "'");
|
|
227
224
|
}
|
|
228
225
|
};
|
|
229
|
-
OpenApiDocConverter.prototype.convertArrayObjectToReferencePropertyType = function (
|
|
230
|
-
return __assign(__assign({}, this.convertReferenceObjectToPropertyType(
|
|
226
|
+
OpenApiDocConverter.prototype.convertArrayObjectToReferencePropertyType = function (propertyName, schemaWrapperInfo) {
|
|
227
|
+
return __assign(__assign({}, this.convertReferenceObjectToPropertyType(propertyName, schemaWrapperInfo)), { isArray: true });
|
|
231
228
|
};
|
|
232
|
-
OpenApiDocConverter.prototype.convertReferenceObjectToPropertyType = function (
|
|
229
|
+
OpenApiDocConverter.prototype.convertReferenceObjectToPropertyType = function (propertyName, schemaWrapperInfo) {
|
|
233
230
|
var _a, _b;
|
|
234
231
|
var propertySchema = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[this.parseRef(schemaWrapperInfo)];
|
|
235
232
|
var refSchema = (((_b = schemaWrapperInfo === null || schemaWrapperInfo === void 0 ? void 0 : schemaWrapperInfo.componentSchemaObject) === null || _b === void 0 ? void 0 : _b.properties) || {})[propertyName];
|
|
236
233
|
var required = this.getIsRequired(propertyName, schemaWrapperInfo);
|
|
237
234
|
var validatorCount = this.getValidatorCount(propertyName, schemaWrapperInfo);
|
|
238
235
|
var initialValue = this.getInitialValue(propertyName, schemaWrapperInfo);
|
|
239
|
-
var initialTestValue = this.getInitialTestValue(
|
|
236
|
+
var initialTestValue = this.getInitialTestValue(propertyName, schemaWrapperInfo);
|
|
240
237
|
var typeName = this.parseRef(schemaWrapperInfo);
|
|
241
238
|
return {
|
|
242
239
|
required: required,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "5.225.
|
|
3
|
+
"version": "5.225.11",
|
|
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",
|
|
@@ -44,9 +44,9 @@ export function {{name}}FormGroupFac(): FormGroup<I{{name}}Form> {
|
|
|
44
44
|
{{/if}}
|
|
45
45
|
{{else}}
|
|
46
46
|
{{#if hasMultipleValidators}}
|
|
47
|
-
{{name}}: new FormGroup<I{{typeScriptType}}Form
|
|
47
|
+
{{name}}: new FormGroup<I{{typeScriptType}}Form>({{typeScriptType}}FormGroupFac().controls, { 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}} }),
|
|
48
48
|
{{else}}
|
|
49
|
-
{{name}}: new FormGroup<I{{typeScriptType}}Form
|
|
49
|
+
{{name}}: new FormGroup<I{{typeScriptType}}Form>({{typeScriptType}}FormGroupFac().controls{{#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}}),
|
|
50
50
|
{{/if}}
|
|
51
51
|
{{/if}}
|
|
52
52
|
{{/referenceProperties}}
|
package/templates/form.ts.hbs
CHANGED
|
@@ -13,18 +13,18 @@ import { I{{name}}Form } from './{{kebabCasedTypeName}}.form';{{/if}}{{/unless}}
|
|
|
13
13
|
export interface I{{name}}Form {
|
|
14
14
|
{{#valueProperties}}
|
|
15
15
|
{{#if isArray}}
|
|
16
|
-
{{name}}
|
|
16
|
+
{{name}}?: FormArray<FormControl<{{typeScriptType}}>>;
|
|
17
17
|
{{else}}
|
|
18
|
-
{{name}}
|
|
18
|
+
{{name}}?: FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}} | undefined>;
|
|
19
19
|
{{/if}}
|
|
20
20
|
{{/valueProperties}}
|
|
21
21
|
{{#referenceProperties}}
|
|
22
22
|
{{#if isArray}}
|
|
23
|
-
{{name}}
|
|
23
|
+
{{name}}?: FormArray<FormGroup<I{{typeScriptType}}Form>>;
|
|
24
24
|
{{else if isEnum}}
|
|
25
|
-
{{name}}
|
|
25
|
+
{{name}}?: FormControl<{{typeScriptType}}{{#unless required}} | null{{/unless}} | undefined>;
|
|
26
26
|
{{else}}
|
|
27
|
-
{{name}}
|
|
27
|
+
{{name}}?: FormGroup<I{{typeScriptType}}Form>;
|
|
28
28
|
{{/if}}
|
|
29
29
|
{{/referenceProperties}}
|
|
30
30
|
}
|
package/templates/model.ts.hbs
CHANGED
|
@@ -22,9 +22,9 @@ export interface I{{{name}}} {
|
|
|
22
22
|
{{/valueProperties}}
|
|
23
23
|
{{#referenceProperties}}
|
|
24
24
|
{{#if isEnum}}
|
|
25
|
-
{{name}}?: {{referenceTypeName}}{{#if isArray}}[]{{/if}}
|
|
25
|
+
{{name}}?: {{referenceTypeName}}{{#if isArray}}[]{{/if}};
|
|
26
26
|
{{else}}
|
|
27
|
-
{{name}}?: Partial<I{{referenceTypeName}}{{#if isArray}}[]{{/if}}
|
|
27
|
+
{{name}}?: Partial<I{{referenceTypeName}}{{#if isArray}}[]{{/if}}>;
|
|
28
28
|
{{/if}}
|
|
29
29
|
{{/referenceProperties}}
|
|
30
30
|
}
|
|
@@ -6,12 +6,10 @@
|
|
|
6
6
|
* Do not edit.
|
|
7
7
|
*/
|
|
8
8
|
{{#if importTypes}}{{#importTypes}}{{#unless isSelfReferencing}}{{#if isEnum}}
|
|
9
|
-
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{
|
|
10
|
-
import { createTest{{name}} } from './{{kebabCasedTypeName}}.test-obj-fac';{{/if}}{{/unless}}{{/importTypes}}{{/if}}
|
|
11
|
-
import { I{{name}} } from './{{kebabCasedName}}.model';
|
|
9
|
+
import { {{name}} } from './{{kebabCasedTypeName}}.enum';{{/if}}{{/unless}}{{/importTypes}}{{/if}}
|
|
12
10
|
import { {{name}}Properties } from './{{kebabCasedName}}.properties';
|
|
13
11
|
|
|
14
|
-
export function createTest{{name}}()
|
|
12
|
+
export function createTest{{name}}() {
|
|
15
13
|
return { {{#valueProperties}}
|
|
16
14
|
[{{../name}}Properties.{{snakeCaseName}}]: {{{initialTestValue}}},{{/valueProperties}} {{#referenceProperties}}
|
|
17
15
|
[{{../name}}Properties.{{snakeCaseName}}]: {{{initialTestValue}}},{{/referenceProperties}}
|