openapi-ts-generator 5.278.2 → 5.287.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.
|
@@ -22,16 +22,17 @@ var ModelGenerator = /** @class */ (function (_super) {
|
|
|
22
22
|
__extends(ModelGenerator, _super);
|
|
23
23
|
function ModelGenerator(options) {
|
|
24
24
|
var _this = this;
|
|
25
|
-
var _a;
|
|
26
|
-
_this = _super.call(this, options, (_a = options.templates) === null || _a === void 0 ? void 0 : _a.model) || this;
|
|
25
|
+
var _a, _b;
|
|
26
|
+
_this = _super.call(this, options, options.genClasses ? (_a = options.templates) === null || _a === void 0 ? void 0 : _a.entity : (_b = options.templates) === null || _b === void 0 ? void 0 : _b.model) || this;
|
|
27
27
|
_this.GeneratorName = 'ModelGenerator';
|
|
28
28
|
return _this;
|
|
29
29
|
}
|
|
30
30
|
ModelGenerator.prototype.generate = function (templateData) {
|
|
31
31
|
var _this = this;
|
|
32
32
|
var _a;
|
|
33
|
+
var fileSuffix = this.generatorOptions.genClasses ? '.entity.ts' : '.model.ts';
|
|
33
34
|
(_a = templateData.entities) === null || _a === void 0 ? void 0 : _a.filter(function (entity) { return !entity.isEnum; }).forEach(function (entity) {
|
|
34
|
-
_super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name)
|
|
35
|
+
_super.prototype.generateFile.call(_this, "".concat(_this.generatorOptions.outputPath, "/").concat(_.kebabCase(entity.name)).concat(fileSuffix), entity);
|
|
35
36
|
});
|
|
36
37
|
};
|
|
37
38
|
return ModelGenerator;
|
|
@@ -9,6 +9,7 @@ export interface IGeneratorOptions {
|
|
|
9
9
|
openApiJsonUrl?: string;
|
|
10
10
|
openApiJsonFileName?: string;
|
|
11
11
|
genAngularFormGroups?: boolean;
|
|
12
|
+
genClasses?: boolean;
|
|
12
13
|
typeFilterCallBack?: (entity: IEntity, index: number, array: IEntity[]) => boolean;
|
|
13
14
|
valuePropertyTypeFilterCallBack?: (valueProperty: IValueProperty, index: number, array: IValueProperty[]) => boolean;
|
|
14
15
|
referencePropertyTypeFilterCallBack?: (referenceProperty: IReferenceProperty, index: number, array: IReferenceProperty[]) => boolean;
|
|
@@ -18,6 +19,7 @@ export interface IGeneratorOptions {
|
|
|
18
19
|
}
|
|
19
20
|
export interface ITemplates {
|
|
20
21
|
model?: string;
|
|
22
|
+
entity?: string;
|
|
21
23
|
testObjectFactory?: string;
|
|
22
24
|
form?: string;
|
|
23
25
|
formGroupFactory?: string;
|
|
@@ -19,12 +19,12 @@ function defaultFilter(_value, _index, _array) {
|
|
|
19
19
|
}
|
|
20
20
|
exports.defaultFilter = defaultFilter;
|
|
21
21
|
function setGeneratorOptionDefaults(options) {
|
|
22
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
|
|
22
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
23
23
|
var templateFolder = (0, path_1.resolve)("".concat(__dirname, "/.."), 'templates');
|
|
24
24
|
options.typeFilterCallBack = (_a = options.typeFilterCallBack) !== null && _a !== void 0 ? _a : defaultFilter;
|
|
25
25
|
options.valuePropertyTypeFilterCallBack = (_b = options.valuePropertyTypeFilterCallBack) !== null && _b !== void 0 ? _b : defaultFilter;
|
|
26
26
|
options.referencePropertyTypeFilterCallBack = (_c = options.referencePropertyTypeFilterCallBack) !== null && _c !== void 0 ? _c : defaultFilter;
|
|
27
|
-
options.templates = __assign(__assign({}, options.templates), { model: (_e = (_d = options.templates) === null || _d === void 0 ? void 0 : _d.model) !== null && _e !== void 0 ? _e : "".concat(templateFolder, "/model.ts.hbs"),
|
|
27
|
+
options.templates = __assign(__assign({}, options.templates), { model: (_e = (_d = options.templates) === null || _d === void 0 ? void 0 : _d.model) !== null && _e !== void 0 ? _e : "".concat(templateFolder, "/model.ts.hbs"), entity: (_g = (_f = options.templates) === null || _f === void 0 ? void 0 : _f.entity) !== null && _g !== void 0 ? _g : "".concat(templateFolder, "/entity.ts.hbs"), form: (_j = (_h = options.templates) === null || _h === void 0 ? void 0 : _h.form) !== null && _j !== void 0 ? _j : "".concat(templateFolder, "/form.ts.hbs"), formGroupFactory: (_l = (_k = options.templates) === null || _k === void 0 ? void 0 : _k.formGroupFactory) !== null && _l !== void 0 ? _l : "".concat(templateFolder, "/form-group-factory.ts.hbs"), testObjectFactory: (_o = (_m = options.templates) === null || _m === void 0 ? void 0 : _m.testObjectFactory) !== null && _o !== void 0 ? _o : "".concat(templateFolder, "/test-object-factory.ts.hbs"), barrel: (_q = (_p = options.templates) === null || _p === void 0 ? void 0 : _p.barrel) !== null && _q !== void 0 ? _q : "".concat(templateFolder, "/index.ts.hbs"), enum: (_s = (_r = options.templates) === null || _r === void 0 ? void 0 : _r.barrel) !== null && _s !== void 0 ? _s : "".concat(templateFolder, "/enum.ts.hbs"), modelProperties: (_u = (_t = options.templates) === null || _t === void 0 ? void 0 : _t.barrel) !== null && _u !== void 0 ? _u : "".concat(templateFolder, "/model-properties.ts.hbs"), endpoints: (_w = (_v = options.templates) === null || _v === void 0 ? void 0 : _v.endpoints) !== null && _w !== void 0 ? _w : "".concat(templateFolder, "/endpoints.ts.hbs") });
|
|
28
28
|
return options;
|
|
29
29
|
}
|
|
30
30
|
exports.setGeneratorOptionDefaults = setGeneratorOptionDefaults;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-generator",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.287.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",
|
|
@@ -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/index.ts.hbs
CHANGED