@devlearning/swagger-generator 1.1.21 → 1.1.23

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.
Files changed (56) hide show
  1. package/.vscode/launch.json +28 -28
  2. package/README-OLD.md +209 -209
  3. package/README.md +277 -277
  4. package/dist/api.constants.d.ts +1 -1
  5. package/dist/api.constants.js +22 -22
  6. package/dist/generators-writers/angular/api-angular-writer.js +38 -38
  7. package/dist/generators-writers/angular/constants.js +24 -24
  8. package/dist/generators-writers/angular/model-angular-writer.js +6 -6
  9. package/dist/generators-writers/dart/model-dart-writer.js +11 -4
  10. package/dist/generators-writers/dart/templates/api.mustache +143 -143
  11. package/dist/generators-writers/dart/templates/enum.mustache +14 -14
  12. package/dist/generators-writers/dart/templates/model.mustache +23 -23
  13. package/dist/generators-writers/nextjs/api-nextjs-writer.js +12 -12
  14. package/dist/generators-writers/nextjs/constants.js +4 -4
  15. package/dist/generators-writers/nextjs/model-nextjs-writer.js +6 -6
  16. package/dist/generators-writers/utils.d.ts +1 -0
  17. package/dist/generators-writers/utils.js +16 -4
  18. package/dist/templates/api.mustache +29 -0
  19. package/dist/templates/model.mustache +18 -0
  20. package/package.json +49 -49
  21. package/src/api.constants.ts +26 -26
  22. package/src/generator-old.ts +449 -449
  23. package/src/generator.ts +752 -752
  24. package/src/generators-writers/angular/api-angular-writer.ts +187 -187
  25. package/src/generators-writers/angular/constants.ts +36 -36
  26. package/src/generators-writers/angular/model-angular-writer.ts +65 -65
  27. package/src/generators-writers/angular/normalizator.ts +41 -41
  28. package/src/generators-writers/dart/api-dart-writer.ts +303 -303
  29. package/src/generators-writers/dart/model-dart-writer.ts +226 -219
  30. package/src/generators-writers/dart/models/import-definition-dart.ts +5 -5
  31. package/src/generators-writers/dart/normalizator.ts +72 -72
  32. package/src/generators-writers/dart/templates/api.mustache +143 -143
  33. package/src/generators-writers/dart/templates/enum.mustache +14 -14
  34. package/src/generators-writers/dart/templates/model.mustache +23 -23
  35. package/src/generators-writers/nextjs/api-nextjs-writer.ts +157 -157
  36. package/src/generators-writers/nextjs/constants.ts +5 -5
  37. package/src/generators-writers/nextjs/model-nextjs-writer.ts +61 -61
  38. package/src/generators-writers/utils.ts +111 -93
  39. package/src/index.ts +103 -103
  40. package/src/models/api-dto.ts +17 -17
  41. package/src/models/enum-value-dto.ts +3 -3
  42. package/src/models/model-dto.ts +9 -9
  43. package/src/models/parameter-dto.ts +7 -7
  44. package/src/models/property-dto.ts +4 -4
  45. package/src/models/swagger/swagger-component-property.ts +11 -11
  46. package/src/models/swagger/swagger-component.ts +17 -17
  47. package/src/models/swagger/swagger-content.ts +4 -4
  48. package/src/models/swagger/swagger-info.ts +3 -3
  49. package/src/models/swagger/swagger-method.ts +7 -7
  50. package/src/models/swagger/swagger-schema.ts +21 -21
  51. package/src/models/swagger/swagger.ts +38 -38
  52. package/src/models/type-dto.ts +7 -7
  53. package/src/swagger-downloader.ts +46 -46
  54. package/src/utils/logger.ts +73 -73
  55. package/src/utils/swagger-validator.ts +89 -89
  56. package/tsconfig.json +33 -33
@@ -1,220 +1,227 @@
1
- import fs, { readFileSync, writeFileSync } from 'fs';
2
- import { ModelDto } from '../../models/model-dto.js';
3
- import Mustache from 'mustache';
4
- import { Utils } from '../utils.js';
5
- import { CommandLineArgs } from '../../index.js';
6
- import { ImportDefinitionDart } from './models/import-definition-dart.js';
7
- import { Normalizator } from './normalizator.js';
8
- import path from 'path';
9
- import { fileURLToPath } from 'url';
10
-
11
- interface ClassDefinitionDart {
12
- className?: string;
13
- fields?: { name: string; type: string }[];
14
- imports?: string[];
15
- }
16
-
17
- interface EnumDefinitionDart {
18
- enumName?: string;
19
- fields?: EnumItemDefinitionDart[];
20
- imports?: string[];
21
- valueType?: string;
22
- }
23
-
24
- interface EnumItemDefinitionDart {
25
- name: string;
26
- value: string;
27
- isLast: boolean;
28
- }
29
-
30
- interface FieldDefinitionDart {
31
- name: string;
32
- type: string;
33
- typeName: string;
34
- nullable: string;
35
- required: string;
36
- jsonKeyAnnotation?: string;
37
- defaultAnnotation?: string;
38
- }
39
-
40
- interface ExportClassDefinitionDart {
41
- classes: ClassDefinitionDart[];
42
- }
43
-
44
- interface ExportEnumDefinitionDart {
45
- classes: EnumDefinitionDart[];
46
- }
47
-
48
- interface ExportModelItemDefinitionDart {
49
- filename?: string;
50
- }
51
-
52
- export class ModelDartWriter {
53
- private _commandLineArgs: CommandLineArgs;
54
-
55
- constructor(commandLineArgs: CommandLineArgs) {
56
- this._commandLineArgs = commandLineArgs;
57
- }
58
-
59
- write(models: ModelDto[]) {
60
- this.writeEnums(models.filter(m => m.modelType === 'enum'));
61
- this.writeClasses(models);
62
- }
63
-
64
- writeClasses(models: ModelDto[]) {
65
- const __filename = fileURLToPath(import.meta.url);
66
- const __dirname = path.dirname(__filename);
67
- const templatePath = path.join(__dirname, 'templates', 'model.mustache');
68
- const template = readFileSync(templatePath, 'utf-8');
69
-
70
- let importDirectory = this._commandLineArgs.outputDirectory;
71
- if (importDirectory.startsWith('lib/')) {
72
- importDirectory = importDirectory.slice('lib/'.length);
73
- }
74
-
75
- models.forEach(model => {
76
- if (model.modelType === 'class' || model.modelType === 'interface') {
77
- const normalizedInfo = Normalizator.getNormalizedInfo(model);
78
- const dartModel = <ClassDefinitionDart>{
79
- filename: normalizedInfo.filename,
80
- path: this._commandLineArgs.outputDirectory,
81
- className: normalizedInfo.modelName,
82
- fields: [],
83
- imports: [],
84
- };
85
-
86
- var imports = <ImportDefinitionDart[]>[];
87
-
88
- const needsDartIo = model.properties.some(p => {
89
- const normalized = (p.typeName ?? '').trim();
90
- return normalized === 'File' || (p.isArray && normalized === 'File');
91
- });
92
-
93
- if (needsDartIo) {
94
- imports.push({
95
- type: { typeName: 'dart:io' } as any,
96
- import: `import 'dart:io';`
97
- });
98
- }
99
-
100
- model.properties.forEach(property => {
101
- var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
102
-
103
- fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
104
-
105
- const isFileField = property.typeName === 'File';
106
- const isFileArrayField = isFileField && property.isArray;
107
- const jsonKeyAnnotation = isFileField
108
- ? "@JsonKey(includeFromJson: false, includeToJson: false)"
109
- : undefined;
110
-
111
- const defaultAnnotation = isFileArrayField
112
- ? '@Default(<File>[])'
113
- : undefined;
114
-
115
- dartModel.fields!.push(<FieldDefinitionDart>{
116
- name: property.name,
117
- type: property.isArray ? `List<${fieldTypeName}>` : fieldTypeName,
118
- typeName: property.typeName,
119
- nullable: property.nullable && !property.isArray ? '?' : '',
120
- required: (property.nullable && !property.isArray) || isFileArrayField ? '' : 'required ',
121
- jsonKeyAnnotation,
122
- defaultAnnotation,
123
- });
124
-
125
- if (property.isTypeReference) {
126
- if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
127
- models.forEach(currModel => {
128
- if (currModel.typeName === property.typeName) {
129
- const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
130
- const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
131
- imports.push({
132
- type: property,
133
- import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
134
- });
135
- }
136
- });
137
- }
138
- }
139
- });
140
-
141
- dartModel.imports = imports.map(i => i.import);
142
-
143
- let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
144
-
145
- Utils.ensureDirectorySync(`${destinationPath}`);
146
-
147
- let result = Mustache.render(template, dartModel);
148
- writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
149
- }
150
- });
151
- }
152
-
153
- writeEnums(models: ModelDto[]) {
154
- const __filename = fileURLToPath(import.meta.url);
155
- const __dirname = path.dirname(__filename);
156
- const templatePath = path.join(__dirname, 'templates', 'enum.mustache');
157
- const template = readFileSync(templatePath, 'utf-8');
158
-
159
- let importDirectory = this._commandLineArgs.outputDirectory;
160
- if (importDirectory.startsWith('lib/')) {
161
- importDirectory = importDirectory.slice('lib/'.length);
162
- }
163
-
164
- models.forEach(model => {
165
- const normalizedInfo = Normalizator.getNormalizedInfo(model);
166
-
167
- const valueType = this._inferDartEnumValueType(model.enumValues);
168
- const dartModel = <EnumDefinitionDart>{
169
- enumName: normalizedInfo.modelName,
170
- path: this._commandLineArgs.outputDirectory,
171
- fields: [],
172
- valueType,
173
- };
174
-
175
- model.enumValues.forEach(enumItem => {
176
- dartModel.fields!.push(<EnumItemDefinitionDart>{
177
- name: enumItem.name,
178
- value: enumItem.value,
179
- isLast: false,
180
- });
181
- });
182
-
183
- const lastIndex = dartModel.fields!.length - 1;
184
- dartModel.fields![lastIndex].isLast = true;
185
-
186
- let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
187
-
188
- Utils.ensureDirectorySync(`${destinationPath}`);
189
-
190
- let result = Mustache.render(template, dartModel);
191
- writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
192
- });
193
- }
194
-
195
- private _inferDartEnumValueType(enumValues: { value: string }[]): string {
196
- // If values are unquoted and numeric, assume int; otherwise String.
197
- // Generator will quote string enums using JSON.stringify ("...").
198
- if (!enumValues || enumValues.length === 0) return 'String';
199
-
200
- const allNumeric = enumValues.every(v => {
201
- const trimmed = (v.value ?? '').trim();
202
- return /^-?\d+$/.test(trimmed);
203
- });
204
-
205
- return allNumeric ? 'int' : 'String';
206
- }
207
-
208
- private _buildImportPath(importDirectory: string, subPath: string, filename: string): string {
209
- // Rimuove slash iniziali e finali da ogni parte
210
- const parts = [importDirectory, subPath]
211
- .filter(p => p && p.length > 0)
212
- .map(p => p.replace(/^\/+|\/+$/g, ''));
213
-
214
- // Aggiunge il filename alla fine
215
- parts.push(`${filename}.dart`);
216
-
217
- // Unisce con un singolo slash
218
- return parts.join('/');
219
- }
1
+ import fs, { readFileSync, writeFileSync } from 'fs';
2
+ import { ModelDto } from '../../models/model-dto.js';
3
+ import Mustache from 'mustache';
4
+ import { Utils } from '../utils.js';
5
+ import { CommandLineArgs } from '../../index.js';
6
+ import { ImportDefinitionDart } from './models/import-definition-dart.js';
7
+ import { Normalizator } from './normalizator.js';
8
+ import path from 'path';
9
+ import { fileURLToPath } from 'url';
10
+
11
+ interface ClassDefinitionDart {
12
+ className?: string;
13
+ fields?: { name: string; type: string }[];
14
+ imports?: string[];
15
+ }
16
+
17
+ interface EnumDefinitionDart {
18
+ enumName?: string;
19
+ fields?: EnumItemDefinitionDart[];
20
+ imports?: string[];
21
+ valueType?: string;
22
+ }
23
+
24
+ interface EnumItemDefinitionDart {
25
+ name: string;
26
+ value: string;
27
+ isLast: boolean;
28
+ }
29
+
30
+ interface FieldDefinitionDart {
31
+ name: string;
32
+ type: string;
33
+ typeName: string;
34
+ nullable: string;
35
+ required: string;
36
+ jsonKeyAnnotation?: string;
37
+ defaultAnnotation?: string;
38
+ }
39
+
40
+ interface ExportClassDefinitionDart {
41
+ classes: ClassDefinitionDart[];
42
+ }
43
+
44
+ interface ExportEnumDefinitionDart {
45
+ classes: EnumDefinitionDart[];
46
+ }
47
+
48
+ interface ExportModelItemDefinitionDart {
49
+ filename?: string;
50
+ }
51
+
52
+ export class ModelDartWriter {
53
+ private _commandLineArgs: CommandLineArgs;
54
+
55
+ constructor(commandLineArgs: CommandLineArgs) {
56
+ this._commandLineArgs = commandLineArgs;
57
+ }
58
+
59
+ write(models: ModelDto[]) {
60
+ this.writeEnums(models.filter(m => m.modelType === 'enum'));
61
+ this.writeClasses(models);
62
+ }
63
+
64
+ writeClasses(models: ModelDto[]) {
65
+ const __filename = fileURLToPath(import.meta.url);
66
+ const __dirname = path.dirname(__filename);
67
+ const templatePath = path.join(__dirname, 'templates', 'model.mustache');
68
+ const template = readFileSync(templatePath, 'utf-8');
69
+
70
+ let importDirectory = this._commandLineArgs.outputDirectory;
71
+ if (importDirectory.startsWith('lib/')) {
72
+ importDirectory = importDirectory.slice('lib/'.length);
73
+ }
74
+
75
+ models.forEach(model => {
76
+ if (model.modelType === 'class' || model.modelType === 'interface') {
77
+ const normalizedInfo = Normalizator.getNormalizedInfo(model);
78
+ const dartModel = <ClassDefinitionDart>{
79
+ filename: normalizedInfo.filename,
80
+ path: this._commandLineArgs.outputDirectory,
81
+ className: normalizedInfo.modelName,
82
+ fields: [],
83
+ imports: [],
84
+ };
85
+
86
+ var imports = <ImportDefinitionDart[]>[];
87
+
88
+ const needsDartIo = model.properties.some(p => {
89
+ const normalized = (p.typeName ?? '').trim();
90
+ return normalized === 'File' || (p.isArray && normalized === 'File');
91
+ });
92
+
93
+ if (needsDartIo) {
94
+ imports.push({
95
+ type: { typeName: 'dart:io' } as any,
96
+ import: `import 'dart:io';`
97
+ });
98
+ }
99
+
100
+ model.properties.forEach(property => {
101
+ var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
102
+
103
+ fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
104
+
105
+ const isFileField = property.typeName === 'File';
106
+ const isFileArrayField = isFileField && property.isArray === true;
107
+ const jsonKeyAnnotation = isFileField
108
+ ? "@JsonKey(includeFromJson: false, includeToJson: false)"
109
+ : undefined;
110
+ const defaultAnnotation = isFileArrayField
111
+ ? "@Default(<File>[])"
112
+ : undefined;
113
+
114
+ // File fields are excluded from JSON serialization; they must not be `required` for fromJson.
115
+ const nullable = isFileField && !property.isArray
116
+ ? '?'
117
+ : (property.nullable && !property.isArray ? '?' : '');
118
+ const required = isFileField
119
+ ? ''
120
+ : (property.nullable && !property.isArray ? '' : 'required ');
121
+
122
+ dartModel.fields!.push(<FieldDefinitionDart>{
123
+ name: property.name,
124
+ type: property.isArray ? `List<${fieldTypeName}>` : fieldTypeName,
125
+ typeName: property.typeName,
126
+ nullable,
127
+ required,
128
+ jsonKeyAnnotation,
129
+ defaultAnnotation,
130
+ });
131
+
132
+ if (property.isTypeReference) {
133
+ if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
134
+ models.forEach(currModel => {
135
+ if (currModel.typeName === property.typeName) {
136
+ const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
137
+ const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
138
+ imports.push({
139
+ type: property,
140
+ import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
141
+ });
142
+ }
143
+ });
144
+ }
145
+ }
146
+ });
147
+
148
+ dartModel.imports = imports.map(i => i.import);
149
+
150
+ let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
151
+
152
+ Utils.ensureDirectorySync(`${destinationPath}`);
153
+
154
+ let result = Mustache.render(template, dartModel);
155
+ writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
156
+ }
157
+ });
158
+ }
159
+
160
+ writeEnums(models: ModelDto[]) {
161
+ const __filename = fileURLToPath(import.meta.url);
162
+ const __dirname = path.dirname(__filename);
163
+ const templatePath = path.join(__dirname, 'templates', 'enum.mustache');
164
+ const template = readFileSync(templatePath, 'utf-8');
165
+
166
+ let importDirectory = this._commandLineArgs.outputDirectory;
167
+ if (importDirectory.startsWith('lib/')) {
168
+ importDirectory = importDirectory.slice('lib/'.length);
169
+ }
170
+
171
+ models.forEach(model => {
172
+ const normalizedInfo = Normalizator.getNormalizedInfo(model);
173
+
174
+ const valueType = this._inferDartEnumValueType(model.enumValues);
175
+ const dartModel = <EnumDefinitionDart>{
176
+ enumName: normalizedInfo.modelName,
177
+ path: this._commandLineArgs.outputDirectory,
178
+ fields: [],
179
+ valueType,
180
+ };
181
+
182
+ model.enumValues.forEach(enumItem => {
183
+ dartModel.fields!.push(<EnumItemDefinitionDart>{
184
+ name: enumItem.name,
185
+ value: enumItem.value,
186
+ isLast: false,
187
+ });
188
+ });
189
+
190
+ const lastIndex = dartModel.fields!.length - 1;
191
+ dartModel.fields![lastIndex].isLast = true;
192
+
193
+ let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
194
+
195
+ Utils.ensureDirectorySync(`${destinationPath}`);
196
+
197
+ let result = Mustache.render(template, dartModel);
198
+ writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
199
+ });
200
+ }
201
+
202
+ private _inferDartEnumValueType(enumValues: { value: string }[]): string {
203
+ // If values are unquoted and numeric, assume int; otherwise String.
204
+ // Generator will quote string enums using JSON.stringify ("...").
205
+ if (!enumValues || enumValues.length === 0) return 'String';
206
+
207
+ const allNumeric = enumValues.every(v => {
208
+ const trimmed = (v.value ?? '').trim();
209
+ return /^-?\d+$/.test(trimmed);
210
+ });
211
+
212
+ return allNumeric ? 'int' : 'String';
213
+ }
214
+
215
+ private _buildImportPath(importDirectory: string, subPath: string, filename: string): string {
216
+ // Rimuove slash iniziali e finali da ogni parte
217
+ const parts = [importDirectory, subPath]
218
+ .filter(p => p && p.length > 0)
219
+ .map(p => p.replace(/^\/+|\/+$/g, ''));
220
+
221
+ // Aggiunge il filename alla fine
222
+ parts.push(`${filename}.dart`);
223
+
224
+ // Unisce con un singolo slash
225
+ return parts.join('/');
226
+ }
220
227
  }
@@ -1,6 +1,6 @@
1
- import { TypeDto } from "../../../models/type-dto.js";
2
-
3
- export interface ImportDefinitionDart {
4
- type: TypeDto;
5
- import: string
1
+ import { TypeDto } from "../../../models/type-dto.js";
2
+
3
+ export interface ImportDefinitionDart {
4
+ type: TypeDto;
5
+ import: string
6
6
  }
@@ -1,73 +1,73 @@
1
- import { ModelDto } from "../../models/model-dto.js";
2
- import { Utils } from "../utils.js";
3
-
4
- export class Normalizator {
5
-
6
- public static getNormalizedInfo(model: ModelDto) {
7
- let subPath = '';
8
- let filename = '';
9
- let modelName = '';
10
-
11
- if (model.name && model.name.includes('.')) {
12
- subPath = model.name.split('.').slice(0, -1).join('');
13
- subPath = `${Utils.toDartFileName(subPath)}/models`;
14
- filename = model.name.split('.').pop()!;
15
- modelName = Utils.toDartClassName(filename) ?? filename;
16
- filename = Utils.toDartFileName(filename!);
17
- } else {
18
- subPath = '';
19
- filename = Utils.toDartFileName(model.name);
20
- modelName = Utils.toDartClassName(model.name) ?? model.name;
21
- }
22
-
23
- return {
24
- filename: filename,
25
- subPath: subPath,
26
- modelName: modelName,
27
- }
28
- }
29
-
30
- public static getNormalizedTypeName(typeName: string): string {
31
- let formattedTypeName = typeName.split('.').pop()!;
32
- return Utils.toDartClassName(formattedTypeName) ?? typeName;
33
- }
34
-
35
- public static mapTsTypeToDart(type: string): string {
36
- const normalized = type.trim().toLowerCase();
37
-
38
- if (normalized.endsWith("[]")) {
39
- const inner = normalized.slice(0, -2).trim();
40
- return `List<${Normalizator.mapTsTypeToDart(inner)}>`;
41
- }
42
-
43
- switch (normalized) {
44
- case "string":
45
- case "uuid":
46
- case "date":
47
- return "String";
48
- case "dateTime":
49
- return "DateTime";
50
- case "number":
51
- case "float":
52
- case "double":
53
- return "double";
54
- case "integer":
55
- case "int":
56
- case "long":
57
- return "int";
58
- case "boolean":
59
- case "bool":
60
- return "bool";
61
- case "any":
62
- case "object":
63
- return "dynamic";
64
- case "null":
65
- case "undefined":
66
- return "Null";
67
- default:
68
- // per tipi personalizzati (es. modelli) restituisci con PascalCase
69
- return Utils.toPascalCase(type);
70
- }
71
- }
72
-
1
+ import { ModelDto } from "../../models/model-dto.js";
2
+ import { Utils } from "../utils.js";
3
+
4
+ export class Normalizator {
5
+
6
+ public static getNormalizedInfo(model: ModelDto) {
7
+ let subPath = '';
8
+ let filename = '';
9
+ let modelName = '';
10
+
11
+ if (model.name && model.name.includes('.')) {
12
+ subPath = model.name.split('.').slice(0, -1).join('');
13
+ subPath = `${Utils.toDartFileName(subPath)}/models`;
14
+ filename = model.name.split('.').pop()!;
15
+ modelName = Utils.toDartClassName(filename) ?? filename;
16
+ filename = Utils.toDartFileName(filename!);
17
+ } else {
18
+ subPath = '';
19
+ filename = Utils.toDartFileName(model.name);
20
+ modelName = Utils.toDartClassName(model.name) ?? model.name;
21
+ }
22
+
23
+ return {
24
+ filename: filename,
25
+ subPath: subPath,
26
+ modelName: modelName,
27
+ }
28
+ }
29
+
30
+ public static getNormalizedTypeName(typeName: string): string {
31
+ let formattedTypeName = typeName.split('.').pop()!;
32
+ return Utils.toDartClassName(formattedTypeName) ?? typeName;
33
+ }
34
+
35
+ public static mapTsTypeToDart(type: string): string {
36
+ const normalized = type.trim().toLowerCase();
37
+
38
+ if (normalized.endsWith("[]")) {
39
+ const inner = normalized.slice(0, -2).trim();
40
+ return `List<${Normalizator.mapTsTypeToDart(inner)}>`;
41
+ }
42
+
43
+ switch (normalized) {
44
+ case "string":
45
+ case "uuid":
46
+ case "date":
47
+ return "String";
48
+ case "dateTime":
49
+ return "DateTime";
50
+ case "number":
51
+ case "float":
52
+ case "double":
53
+ return "double";
54
+ case "integer":
55
+ case "int":
56
+ case "long":
57
+ return "int";
58
+ case "boolean":
59
+ case "bool":
60
+ return "bool";
61
+ case "any":
62
+ case "object":
63
+ return "dynamic";
64
+ case "null":
65
+ case "undefined":
66
+ return "Null";
67
+ default:
68
+ // per tipi personalizzati (es. modelli) restituisci con PascalCase
69
+ return Utils.toPascalCase(type);
70
+ }
71
+ }
72
+
73
73
  }