swaggular 0.2.2 → 0.2.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.
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AngularRequestType = exports.AngularResponseType = exports.NativeType = void 0;
4
- var NativeType;
5
- (function (NativeType) {
6
- NativeType["String"] = "string";
7
- NativeType["Number"] = "number";
8
- NativeType["Boolean"] = "boolean";
9
- NativeType["Array"] = "Array";
10
- NativeType["Date"] = "Date";
11
- NativeType["File"] = "File";
12
- NativeType["Any"] = "any";
13
- NativeType["Void"] = "void";
14
- })(NativeType || (exports.NativeType = NativeType = {}));
15
- var AngularResponseType;
16
- (function (AngularResponseType) {
17
- AngularResponseType["Json"] = "json";
18
- AngularResponseType["Text"] = "text";
19
- AngularResponseType["Blob"] = "blob";
20
- AngularResponseType["ArrayBuffer"] = "arrayBuffer";
21
- })(AngularResponseType || (exports.AngularResponseType = AngularResponseType = {}));
22
- var AngularRequestType;
23
- (function (AngularRequestType) {
24
- AngularRequestType["Get"] = "get";
25
- AngularRequestType["Post"] = "post";
26
- AngularRequestType["Put"] = "put";
27
- AngularRequestType["Delete"] = "delete";
28
- AngularRequestType["Patch"] = "patch";
29
- })(AngularRequestType || (exports.AngularRequestType = AngularRequestType = {}));
@@ -1,62 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.interfaceDataStore = void 0;
4
- class InterfaceDataStore {
5
- genericInterfaces = {};
6
- baseInterfaces = {};
7
- generatedInterfaces = {};
8
- generatedEnums = {};
9
- componentsSchemas = {};
10
- constructor() { }
11
- setComponentsSchemas(componentsSchemas) {
12
- this.componentsSchemas = componentsSchemas;
13
- }
14
- getComponentsSchema(name) {
15
- return this.componentsSchemas[name];
16
- }
17
- exists(name) {
18
- return (this.genericInterfaces[name] !== undefined ||
19
- this.baseInterfaces[name] !== undefined ||
20
- this.generatedInterfaces[name] !== undefined ||
21
- this.generatedEnums[name] !== undefined);
22
- }
23
- addInterfaces(interfacesData) {
24
- for (const inter of interfacesData) {
25
- this.generatedInterfaces[inter.name] = inter;
26
- }
27
- }
28
- computeExtendsFrom(properties) {
29
- if (properties.length === 0)
30
- return { extendsFrom: undefined, properties: [] };
31
- const currentPropertiesNames = new Set(properties.map((p) => p.name));
32
- for (const [name, schema] of Object.entries(this.baseInterfaces)) {
33
- if (schema.properties.length !== properties.length)
34
- continue;
35
- const required = schema.properties
36
- .filter((p) => !p.optional)
37
- .map((p) => p.name);
38
- if (required.some((r) => !currentPropertiesNames.has(r))) {
39
- continue;
40
- }
41
- const optional = schema.properties
42
- .filter((p) => p.optional)
43
- .map((p) => p.name);
44
- const remainingProperties = properties
45
- .filter((p) => !required.includes(p.name))
46
- .filter((p) => !optional.includes(p.name));
47
- if (remainingProperties.length === 0 &&
48
- schema.properties.some((p) => p.type === "generic")) {
49
- return {
50
- extendsFrom: name,
51
- properties: [],
52
- };
53
- }
54
- return {
55
- extendsFrom: name,
56
- properties: remainingProperties,
57
- };
58
- }
59
- return { extendsFrom: undefined, properties };
60
- }
61
- }
62
- exports.interfaceDataStore = new InterfaceDataStore();
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serviceStore = void 0;
4
- class ServiceStore {
5
- services = {};
6
- addService(name, content) {
7
- this.services[name] = content;
8
- }
9
- addServices(services) {
10
- services.forEach((service) => {
11
- this.services[service.name] = service;
12
- });
13
- }
14
- getService(name) {
15
- return this.services[name];
16
- }
17
- }
18
- exports.serviceStore = new ServiceStore();
@@ -1,324 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.swaggerStore = void 0;
37
- const fs = __importStar(require("fs"));
38
- const path = __importStar(require("path"));
39
- const path_utils_1 = require("../utils/path-utils");
40
- const string_utils_1 = require("../utils/string-utils");
41
- class SwaggerStore {
42
- swagger = undefined;
43
- pathsGroupedByScope = undefined;
44
- addSwagger(filePath, options = { mode: "tags" }) {
45
- const absolutePath = path.resolve(filePath);
46
- const content = fs.readFileSync(absolutePath, { encoding: "utf8" });
47
- this.swagger = JSON.parse(content);
48
- if (!this.swagger)
49
- return;
50
- this.groupByScopes(this.swagger, options);
51
- }
52
- getSwagger() {
53
- return this.swagger;
54
- }
55
- getPaths() {
56
- return this.swagger?.paths;
57
- }
58
- getSchemas() {
59
- return this.swagger?.components?.schemas;
60
- }
61
- getPathsGroupedByScope() {
62
- return this.pathsGroupedByScope;
63
- }
64
- getGroupByPath(path) {
65
- if (!this.pathsGroupedByScope)
66
- return;
67
- for (const value of Object.values(this.pathsGroupedByScope)) {
68
- if (value.paths.includes(path))
69
- return value;
70
- }
71
- return undefined;
72
- }
73
- groupByScopes(swagger, options) {
74
- this.pathsGroupedByScope = this.groupPaths(swagger.paths, options);
75
- }
76
- /**
77
- * Groups OpenAPI paths based on the specified mode (tags or path).
78
- *
79
- * @param paths - The OpenAPI paths object to group.
80
- * @param options - Configuration for grouping:
81
- * - `mode`: 'tags' to group by OpenAPI tags, or 'path' to group by path segments.
82
- * - `segmentsToIgnore`: (mode 'path' only) Array of path segments to skip during normalization.
83
- * - `ignoreVariables`: (mode 'path' only) Whether to ignore template variables like {id} during grouping.
84
- * @returns A record where keys are group names and values are GroupedPath objects.
85
- *
86
- * @remarks
87
- * When in 'path' mode, it creates primary groups using the first non-ignored segment.
88
- * If a group contains more than 8 HTTP methods across all its paths, it attempts to
89
- * create subgroups for paths that have at least 2 HTTP methods and additional segments.
90
- */
91
- groupPaths(paths, options = { mode: "tags" }) {
92
- if (options.mode === "tags") {
93
- return this.groupByTags(paths, options);
94
- }
95
- else {
96
- return this.groupByPath(paths, options);
97
- }
98
- }
99
- groupByTags(paths, options) {
100
- const tagGroups = {};
101
- const methods = [
102
- "get",
103
- "put",
104
- "post",
105
- "delete",
106
- "options",
107
- "head",
108
- "patch",
109
- "trace",
110
- ];
111
- for (const [pathKey, pathItem] of Object.entries(paths)) {
112
- if (!pathItem)
113
- continue;
114
- const tags = new Set();
115
- for (const method of methods) {
116
- const operation = pathItem[method];
117
- if (operation?.tags && operation.tags.length > 0) {
118
- operation.tags.forEach((tag) => tags.add((0, string_utils_1.removeAllWhitespace)(tag)));
119
- }
120
- }
121
- if (tags.size === 0) {
122
- const groupKey = "Default";
123
- if (!tagGroups[groupKey])
124
- tagGroups[groupKey] = [];
125
- tagGroups[groupKey].push(pathKey);
126
- }
127
- else {
128
- tags.forEach((tag) => {
129
- if (!tagGroups[tag])
130
- tagGroups[tag] = [];
131
- tagGroups[tag].push(pathKey);
132
- });
133
- }
134
- }
135
- const finalGroups = {};
136
- const sortedTags = Object.keys(tagGroups).sort();
137
- for (const tagName of sortedTags) {
138
- const pathKeys = tagGroups[tagName].sort();
139
- const totalMethods = pathKeys.reduce((sum, pk) => sum + this.getMethodCount(paths[pk]), 0);
140
- if (totalMethods <= 8) {
141
- const groupName = (0, string_utils_1.toPascalCase)([tagName]);
142
- finalGroups[groupName] = {
143
- groupName,
144
- baseSegments: this.getCommonSegments(pathKeys),
145
- paths: pathKeys,
146
- baseUrl: (0, path_utils_1.findCommonBaseUrl)(pathKeys),
147
- };
148
- }
149
- else {
150
- // Find common segments of this tag group to start splitting from a meaningful depth
151
- const commonSegs = this.getCommonSegments(pathKeys);
152
- // But we want the group names to start with the TagName
153
- this.splitRecursively(paths, pathKeys, commonSegs, options, finalGroups, commonSegs.length, tagName);
154
- }
155
- }
156
- return finalGroups;
157
- }
158
- groupByPath(paths, options) {
159
- const finalGroups = {};
160
- const pathKeys = Object.keys(paths).filter((k) => !!paths[k]);
161
- // 1. Initial primary grouping by the first non-ignored segment
162
- const initialBuckets = {};
163
- for (const pk of pathKeys) {
164
- const normalized = this.getNormalizedSegments(pk, options);
165
- const first = normalized.length > 0 ? normalized[0] : "Default";
166
- if (!initialBuckets[first])
167
- initialBuckets[first] = [];
168
- initialBuckets[first].push(pk);
169
- }
170
- const sortedPrimaryKeys = Object.keys(initialBuckets).sort();
171
- for (const primaryKey of sortedPrimaryKeys) {
172
- const pathsInBucket = initialBuckets[primaryKey];
173
- const prefix = primaryKey === "Default" ? [] : [primaryKey];
174
- this.splitRecursively(paths, pathsInBucket, prefix, options, finalGroups, 0);
175
- }
176
- // Ensure the resulting groups are deterministic
177
- const sortedResult = {};
178
- const sortedGroupNames = Object.keys(finalGroups).sort();
179
- for (const name of sortedGroupNames) {
180
- sortedResult[name] = finalGroups[name];
181
- }
182
- return sortedResult;
183
- }
184
- /**
185
- * Recursively splits a group of paths based on their segments if the method count threshold is exceeded.
186
- */
187
- splitRecursively(allPaths, currentPaths, currentPrefix, options, finalGroups, initialDepth, customNamePrefix) {
188
- const totalMethods = currentPaths.reduce((sum, pk) => sum + this.getMethodCount(allPaths[pk]), 0);
189
- const depth = currentPrefix.length;
190
- // Condition 1: If small enough, keep as one group.
191
- if (totalMethods <= 8) {
192
- this.addToFinalGroups(currentPaths, currentPrefix, finalGroups, initialDepth, customNamePrefix);
193
- return;
194
- }
195
- // Attempt to split.
196
- const stayers = [];
197
- const branchMap = {};
198
- for (const pk of currentPaths) {
199
- const normalized = this.getNormalizedSegments(pk, options);
200
- if (normalized.length > depth) {
201
- const next = normalized[depth];
202
- if (!branchMap[next])
203
- branchMap[next] = [];
204
- branchMap[next].push(pk);
205
- }
206
- else {
207
- stayers.push(pk);
208
- }
209
- }
210
- const nextSegs = Object.keys(branchMap);
211
- // If no possible split (no more segments), stop.
212
- if (nextSegs.length === 0) {
213
- this.addToFinalGroups(currentPaths, currentPrefix, finalGroups, initialDepth, customNamePrefix);
214
- return;
215
- }
216
- // Identify which branches can move.
217
- // A path (or group of paths) can move ONLY if it has >= 2 methods.
218
- const movingBranches = [];
219
- const remainingToStay = [...stayers];
220
- for (const seg of nextSegs) {
221
- const paths = branchMap[seg];
222
- const count = paths.reduce((sum, pk) => sum + this.getMethodCount(allPaths[pk]), 0);
223
- if (count >= 2) {
224
- movingBranches.push({ seg, paths });
225
- }
226
- else {
227
- remainingToStay.push(...paths);
228
- }
229
- }
230
- // If no branches can move according to the 2-method rule, stop and keep everything here.
231
- if (movingBranches.length === 0) {
232
- this.addToFinalGroups(currentPaths, currentPrefix, finalGroups, initialDepth, customNamePrefix);
233
- return;
234
- }
235
- // Optimization: If only one branch can move and no stayers, zip prefix.
236
- if (movingBranches.length === 1 && remainingToStay.length === 0) {
237
- this.splitRecursively(allPaths, currentPaths, [...currentPrefix, movingBranches[0].seg], options, finalGroups, initialDepth, customNamePrefix);
238
- return;
239
- }
240
- // Otherwise, split: remainingToStay form the group at current level, movingBranches recurse.
241
- if (remainingToStay.length > 0) {
242
- this.addToFinalGroups(remainingToStay, currentPrefix, finalGroups, initialDepth, customNamePrefix);
243
- }
244
- for (const branch of movingBranches.sort((a, b) => a.seg.localeCompare(b.seg))) {
245
- this.splitRecursively(allPaths, branch.paths, [...currentPrefix, branch.seg], options, finalGroups, initialDepth, customNamePrefix);
246
- }
247
- }
248
- addToFinalGroups(paths, prefix, finalGroups, initialDepth, customNamePrefix) {
249
- let groupName;
250
- if (customNamePrefix) {
251
- const trailing = prefix.slice(initialDepth);
252
- groupName = (0, string_utils_1.toPascalCase)([customNamePrefix, ...trailing]);
253
- }
254
- else {
255
- groupName = prefix.length > 0 ? (0, string_utils_1.toPascalCase)(prefix) : "Default";
256
- }
257
- if (finalGroups[groupName]) {
258
- const existing = finalGroups[groupName];
259
- existing.paths = [...new Set([...existing.paths, ...paths])].sort();
260
- existing.baseSegments = this.getCommonSegments(existing.paths);
261
- existing.baseUrl = (0, path_utils_1.findCommonBaseUrl)(existing.paths);
262
- }
263
- else {
264
- finalGroups[groupName] = {
265
- groupName,
266
- baseSegments: this.getCommonSegments(paths),
267
- paths: paths.sort(),
268
- baseUrl: (0, path_utils_1.findCommonBaseUrl)(paths),
269
- };
270
- }
271
- }
272
- getNormalizedSegments(path, options) {
273
- const segments = path.split("/").filter((s) => s);
274
- const result = [];
275
- for (const segment of segments) {
276
- if (options.segmentsToIgnore?.includes(segment))
277
- continue;
278
- if (options.ignoreVariables && (0, path_utils_1.isVariable)(segment))
279
- continue;
280
- result.push(segment);
281
- }
282
- return result;
283
- }
284
- getMethodCount(pathItem) {
285
- const methods = [
286
- "get",
287
- "put",
288
- "post",
289
- "delete",
290
- "options",
291
- "head",
292
- "patch",
293
- "trace",
294
- ];
295
- let count = 0;
296
- for (const method of methods) {
297
- if (pathItem[method]) {
298
- count++;
299
- }
300
- }
301
- return count;
302
- }
303
- getCommonSegments(paths) {
304
- if (paths.length === 0)
305
- return [];
306
- const pathSegments = paths.map((p) => p
307
- .replace(/^\/+api\/+/, "")
308
- .split("/")
309
- .filter((s) => s));
310
- const firstPath = pathSegments[0];
311
- const common = [];
312
- for (let i = 0; i < firstPath.length; i++) {
313
- const segment = firstPath[i];
314
- if (pathSegments.every((ps) => ps[i] === segment)) {
315
- common.push(segment);
316
- }
317
- else {
318
- break;
319
- }
320
- }
321
- return common;
322
- }
323
- }
324
- exports.swaggerStore = new SwaggerStore();
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.angularServiceTemplate = void 0;
4
- const angularServiceTemplate = (params) => {
5
- return `
6
- import { HttpClient } from "@angular/common/http";
7
- import { Observable } from "rxjs";
8
- import { inject, Injectable } from '@angular/core';
9
- import { ${params.imports} } from '../../models';
10
- import { HttpHelper } from '@umss/shared/utils';
11
-
12
- @Injectable({
13
- providedIn: "root"
14
- })
15
- export class ${params.name}Service {
16
-
17
- private readonly baseUrl = "${params.baseUrl}";
18
- private readonly http = inject(HttpClient);
19
-
20
- ${params.methods}
21
- }`;
22
- };
23
- exports.angularServiceTemplate = angularServiceTemplate;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pagedRequestTemplate = void 0;
4
- exports.pagedRequestTemplate = `
5
- export interface PagedRequestDto {
6
- /**
7
- * format: int32
8
- * maximum: 2147483647
9
- * minimum: 1
10
- */
11
- pageNumber?: number;
12
- /**
13
- * format: int32
14
- * maximum: 100
15
- * minimum: 1
16
- */
17
- pageSize?: number;
18
- searchTerm?: string | null;
19
- sortBy?: string | null;
20
- sortDescending?: boolean;
21
- }
22
- `;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.pagedResultTemplate = void 0;
4
- exports.pagedResultTemplate = `
5
- export interface PagedResultDto<T> {
6
- items: T[];
7
- totalCount: number;
8
- pageNumber: number;
9
- pageSize: number;
10
- totalPages: number;
11
- hasPreviousPage: boolean;
12
- hasNextPage: boolean;
13
- }`;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addImportToInterface = addImportToInterface;
4
- function addImportToInterface(interfaceString, imports, commons, modelInPath) {
5
- const commonImports = commons.filter((c) => imports.includes(c));
6
- let commonImportString = "";
7
- if (commonImports.length > 0) {
8
- commonImportString = `import { ${commonImports.join(", ")} } from "../../common";`;
9
- }
10
- const dtosImports = [];
11
- for (const [model, path] of Object.entries(modelInPath)) {
12
- if (!path)
13
- continue;
14
- if (!imports.includes(model))
15
- continue;
16
- const [outerKey, innerKey] = path;
17
- const modelName = innerKey.replace(".dto.ts", "");
18
- dtosImports.push(`import { ${modelName} } from "../${outerKey}/${innerKey}";`);
19
- }
20
- return `${commonImportString.length > 0 ? commonImportString + "\n" : ""}${dtosImports.join("\n")}\n${interfaceString}`;
21
- }
@@ -1,134 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getImports = getImports;
4
- exports.buildInterface = buildInterface;
5
- exports.buildEnum = buildEnum;
6
- exports.generateSchemaInterfaces = generateSchemaInterfaces;
7
- exports.buildComments = buildComments;
8
- const paged_request_template_1 = require("../templates/paged-request-template");
9
- const paged_result_template_1 = require("../templates/paged-result-template");
10
- const build_types_1 = require("../utils/build-types");
11
- const to_case_1 = require("../utils/to-case");
12
- function getImports(schema, type) {
13
- const imports = [];
14
- if (!schema["$ref"]) {
15
- return [];
16
- }
17
- if (type.startsWith("PagedResultDto")) {
18
- imports.push("PagedResultDto");
19
- const splited = type.replaceAll(">", "").split("<");
20
- splited.forEach((s) => imports.push(s));
21
- }
22
- return imports;
23
- }
24
- function buildInterface(name, schema) {
25
- if (name.endsWith("PagedResultDto"))
26
- return { content: null, imports: [] };
27
- const lines = [];
28
- lines.push(`export interface ${name} {`);
29
- const imports = new Set();
30
- for (const [prop, def] of Object.entries(schema.properties)) {
31
- const comments = buildComments(def);
32
- const tsType = (0, build_types_1.switchTypeJson)(def);
33
- if (def["$ref"]) {
34
- getImports(def, tsType).forEach((i) => imports.add(i));
35
- }
36
- const optional = def.nullable || !schema.required?.includes(prop);
37
- const nullable = def.nullable ? " | null" : "";
38
- lines.push(`${comments}\n\t${(0, to_case_1.lowerFirst)(prop)}${optional ? "?" : ""}: ${tsType}${nullable};`);
39
- }
40
- lines.push(`}`);
41
- return { content: lines.join("\n"), imports: [] };
42
- }
43
- function buildEnum(name, schema) {
44
- const lines = [];
45
- lines.push(`export enum ${name} {`);
46
- for (const value of schema.enum) {
47
- lines.push(`\t${value} = "${value}",`);
48
- }
49
- lines.push(`}`);
50
- return lines.join("\n");
51
- }
52
- function generateSchemaInterfaces(schemas, paths, parametersTypes) {
53
- const interfaces = {};
54
- for (const [name, schema] of Object.entries(schemas)) {
55
- if (schema.type === "string" && schema.enum && schema.enum.length > 0) {
56
- const enumString = buildEnum(name, schema);
57
- if (!enumString)
58
- continue;
59
- interfaces[name] = { content: enumString, imports: [] };
60
- continue;
61
- }
62
- if (schema.type === "object" && schema.properties) {
63
- const interfaceString = buildInterface(name, schema);
64
- if (!interfaceString.content)
65
- continue;
66
- interfaces[name] = {
67
- content: interfaceString.content,
68
- imports: interfaceString.imports,
69
- };
70
- continue;
71
- }
72
- }
73
- const defaultPagedRequestDtoKeys = [
74
- "pageNumber",
75
- "pageSize",
76
- "searchTerm",
77
- "sortBy",
78
- "sortDescending",
79
- ];
80
- const requestImports = new Set();
81
- for (const value of Object.values(parametersTypes)) {
82
- const { method, parameterType } = value;
83
- const path = paths[method];
84
- if (!path.parameters || path.parameters.length === 0)
85
- continue;
86
- const properties = [];
87
- for (const param of path.parameters) {
88
- if (defaultPagedRequestDtoKeys.includes(param.name) ||
89
- param.in !== "query")
90
- continue;
91
- const tsType = (0, build_types_1.switchTypeJson)(param.schema);
92
- if (param.schema["$ref"]) {
93
- getImports(param.schema, tsType).forEach((i) => requestImports.add(i));
94
- }
95
- const comments = buildComments(param.schema);
96
- properties.push(`${comments}\n\t${(0, to_case_1.lowerFirst)(param.name)}?: ${tsType};`);
97
- }
98
- let interfaceTemplate = `export interface ${parameterType} extends PagedRequestDto {
99
- ${properties.join("\n")}
100
- }`;
101
- requestImports.add("PagedRequestDto");
102
- interfaces[parameterType] = {
103
- content: interfaceTemplate,
104
- imports: Array.from(requestImports),
105
- };
106
- }
107
- return {
108
- ...interfaces,
109
- ["PagedRequestDto"]: { content: paged_request_template_1.pagedRequestTemplate, imports: [] },
110
- ["PagedResultDto"]: { content: paged_result_template_1.pagedResultTemplate, imports: [] },
111
- };
112
- }
113
- function buildComments(param) {
114
- const comments = [];
115
- if (param.format !== undefined) {
116
- comments.push(`format: ${param.format}`);
117
- }
118
- if (param.minLength !== undefined) {
119
- comments.push(`minLength: ${param.minLength}`);
120
- }
121
- if (param.maxLength !== undefined) {
122
- comments.push(`maxLength: ${param.maxLength}`);
123
- }
124
- if (param.minimum !== undefined) {
125
- comments.push(`minimum: ${param.minimum}`);
126
- }
127
- if (param.maximum !== undefined) {
128
- comments.push(`maximum: ${param.maximum}`);
129
- }
130
- if (comments.length > 0) {
131
- return ` /**\n * ${comments.join("\n * ")}\n */`;
132
- }
133
- return "";
134
- }