openapi-ts-generator 5.223.2 → 5.223.4
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.
|
@@ -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;
|
|
@@ -46,7 +48,6 @@ export interface IReferenceProperty {
|
|
|
46
48
|
snakeCaseName: string;
|
|
47
49
|
referenceTypeName: string;
|
|
48
50
|
typeScriptType: string;
|
|
49
|
-
kebabCasedTypeScriptType: string;
|
|
50
51
|
hasValidators: boolean;
|
|
51
52
|
isArray: boolean;
|
|
52
53
|
required: 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,7 +119,7 @@ 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,
|
|
@@ -146,7 +145,7 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
146
145
|
initialValue: initialValue,
|
|
147
146
|
name: propertyName,
|
|
148
147
|
isArray: true,
|
|
149
|
-
snakeCaseName:
|
|
148
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
150
149
|
hasMultipleValidators: false,
|
|
151
150
|
hasValidators: validatorCount > 0,
|
|
152
151
|
};
|
|
@@ -195,10 +194,9 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
195
194
|
required: required,
|
|
196
195
|
name: propertyName,
|
|
197
196
|
initialValue: initialValue,
|
|
198
|
-
snakeCaseName:
|
|
197
|
+
snakeCaseName: (0, lodash_1.snakeCase)(propertyName).toUpperCase(),
|
|
199
198
|
referenceTypeName: typeName,
|
|
200
199
|
typeScriptType: typeName,
|
|
201
|
-
kebabCasedTypeScriptType: (0, lodash_1.kebabCase)(typeName),
|
|
202
200
|
isArray: false,
|
|
203
201
|
isEnum: (propertySchema.enum || []).length > 0,
|
|
204
202
|
hasValidators: validatorCount > 0,
|
|
@@ -242,17 +240,23 @@ var OpenApiDocConverter = /** @class */ (function () {
|
|
|
242
240
|
};
|
|
243
241
|
OpenApiDocConverter.prototype.getImportTypes = function (entityName, schemaWrapperInfo) {
|
|
244
242
|
var _this = this;
|
|
243
|
+
var _a;
|
|
244
|
+
var schemaProperties = (((_a = this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || { properties: {} })[entityName].properties || {};
|
|
245
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
246
|
+
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 })); });
|
|
245
247
|
return schemaWrapperInfo.referenceProperties
|
|
246
248
|
.map(function (t) { return t.referenceTypeName; })
|
|
247
|
-
.filter(function (t) { return t !== entityName; })
|
|
248
249
|
.filter(function (value, index, array) { return array.indexOf(value) === index; })
|
|
249
250
|
.map(function (value) {
|
|
250
251
|
var _a;
|
|
251
|
-
var
|
|
252
|
+
var refSchema = (((_a = _this.apiDocument.components) === null || _a === void 0 ? void 0 : _a.schemas) || {})[value];
|
|
253
|
+
var props = properties.filter(function (t) { return t.items.$ref === value || t.$ref === value; });
|
|
252
254
|
return {
|
|
253
255
|
name: value,
|
|
254
|
-
kebabCasedTypeName:
|
|
255
|
-
isEnum: (
|
|
256
|
+
kebabCasedTypeName: (0, lodash_1.kebabCase)(value),
|
|
257
|
+
isEnum: (refSchema.enum || []).length > 0,
|
|
258
|
+
areAllArrays: props.every(function (val) { return val.type === 'array'; }),
|
|
259
|
+
isSelfReferencing: entityName === value,
|
|
256
260
|
};
|
|
257
261
|
});
|
|
258
262
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "5.223.
|
|
3
|
+
"version": "5.223.4",
|
|
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,9 +6,9 @@
|
|
|
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({
|
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}}
|