@devlearning/swagger-generator 1.1.13 → 1.1.14
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.
- package/dist/generators-writers/dart/api-dart-writer.d.ts +1 -0
- package/dist/generators-writers/dart/api-dart-writer.js +14 -2
- package/dist/generators-writers/dart/model-dart-writer.d.ts +1 -0
- package/dist/generators-writers/dart/model-dart-writer.js +12 -1
- package/package.json +1 -1
- package/src/generators-writers/dart/api-dart-writer.ts +17 -2
- package/src/generators-writers/dart/model-dart-writer.ts +15 -1
|
@@ -127,9 +127,10 @@ export class ApiDartWriter {
|
|
|
127
127
|
models.forEach(model => {
|
|
128
128
|
if (model.typeName === api.parameters[0]?.typeName) {
|
|
129
129
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
130
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
130
131
|
imports.push({
|
|
131
132
|
type: api.parameters[0],
|
|
132
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
133
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
136
|
});
|
|
@@ -140,9 +141,10 @@ export class ApiDartWriter {
|
|
|
140
141
|
models.forEach(model => {
|
|
141
142
|
if (model.typeName === api.returnType.typeName) {
|
|
142
143
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
144
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
143
145
|
imports.push({
|
|
144
146
|
type: api.returnType,
|
|
145
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
147
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
});
|
|
@@ -150,6 +152,16 @@ export class ApiDartWriter {
|
|
|
150
152
|
}
|
|
151
153
|
return { endpoint };
|
|
152
154
|
}
|
|
155
|
+
_buildImportPath(importDirectory, subPath, filename) {
|
|
156
|
+
// Rimuove slash iniziali e finali da ogni parte
|
|
157
|
+
const parts = [importDirectory, subPath]
|
|
158
|
+
.filter(p => p && p.length > 0)
|
|
159
|
+
.map(p => p.replace(/^\/+|\/+$/g, ''));
|
|
160
|
+
// Aggiunge il filename alla fine
|
|
161
|
+
parts.push(`${filename}.dart`);
|
|
162
|
+
// Unisce con un singolo slash
|
|
163
|
+
return parts.join('/');
|
|
164
|
+
}
|
|
153
165
|
_toPascalCase(input) {
|
|
154
166
|
return input
|
|
155
167
|
.replace(/[_\- ]+/g, ' ') // sostituisce underscore, dash e spazi con uno spazio singolo
|
|
@@ -48,9 +48,10 @@ export class ModelDartWriter {
|
|
|
48
48
|
models.forEach(currModel => {
|
|
49
49
|
if (currModel.typeName === property.typeName) {
|
|
50
50
|
const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
|
|
51
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
51
52
|
imports.push({
|
|
52
53
|
type: property,
|
|
53
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
54
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
54
55
|
});
|
|
55
56
|
}
|
|
56
57
|
});
|
|
@@ -96,4 +97,14 @@ export class ModelDartWriter {
|
|
|
96
97
|
writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
|
|
97
98
|
});
|
|
98
99
|
}
|
|
100
|
+
_buildImportPath(importDirectory, subPath, filename) {
|
|
101
|
+
// Rimuove slash iniziali e finali da ogni parte
|
|
102
|
+
const parts = [importDirectory, subPath]
|
|
103
|
+
.filter(p => p && p.length > 0)
|
|
104
|
+
.map(p => p.replace(/^\/+|\/+$/g, ''));
|
|
105
|
+
// Aggiunge il filename alla fine
|
|
106
|
+
parts.push(`${filename}.dart`);
|
|
107
|
+
// Unisce con un singolo slash
|
|
108
|
+
return parts.join('/');
|
|
109
|
+
}
|
|
99
110
|
}
|
package/package.json
CHANGED
|
@@ -191,9 +191,10 @@ export class ApiDartWriter {
|
|
|
191
191
|
models.forEach(model => {
|
|
192
192
|
if (model.typeName === api.parameters[0]?.typeName) {
|
|
193
193
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
194
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
194
195
|
imports.push({
|
|
195
196
|
type: api.parameters[0],
|
|
196
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
197
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
197
198
|
});
|
|
198
199
|
}
|
|
199
200
|
});
|
|
@@ -205,9 +206,10 @@ export class ApiDartWriter {
|
|
|
205
206
|
models.forEach(model => {
|
|
206
207
|
if (model.typeName === api.returnType!.typeName) {
|
|
207
208
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
209
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
208
210
|
imports.push({
|
|
209
211
|
type: api.returnType!,
|
|
210
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
212
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
211
213
|
});
|
|
212
214
|
}
|
|
213
215
|
});
|
|
@@ -217,6 +219,19 @@ export class ApiDartWriter {
|
|
|
217
219
|
return { endpoint };
|
|
218
220
|
}
|
|
219
221
|
|
|
222
|
+
private _buildImportPath(importDirectory: string, subPath: string, filename: string): string {
|
|
223
|
+
// Rimuove slash iniziali e finali da ogni parte
|
|
224
|
+
const parts = [importDirectory, subPath]
|
|
225
|
+
.filter(p => p && p.length > 0)
|
|
226
|
+
.map(p => p.replace(/^\/+|\/+$/g, ''));
|
|
227
|
+
|
|
228
|
+
// Aggiunge il filename alla fine
|
|
229
|
+
parts.push(`${filename}.dart`);
|
|
230
|
+
|
|
231
|
+
// Unisce con un singolo slash
|
|
232
|
+
return parts.join('/');
|
|
233
|
+
}
|
|
234
|
+
|
|
220
235
|
private _toPascalCase(input: string): string {
|
|
221
236
|
return input
|
|
222
237
|
.replace(/[_\- ]+/g, ' ') // sostituisce underscore, dash e spazi con uno spazio singolo
|
|
@@ -100,9 +100,10 @@ export class ModelDartWriter {
|
|
|
100
100
|
models.forEach(currModel => {
|
|
101
101
|
if (currModel.typeName === property.typeName) {
|
|
102
102
|
const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
|
|
103
|
+
const importPath = this._buildImportPath(importDirectory, normalizedInfo.subPath, normalizedInfo.filename);
|
|
103
104
|
imports.push({
|
|
104
105
|
type: property,
|
|
105
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
106
|
+
import: `import 'package:${this._commandLineArgs.package}/${importPath}';`
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
109
|
});
|
|
@@ -160,4 +161,17 @@ export class ModelDartWriter {
|
|
|
160
161
|
writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
|
|
161
162
|
});
|
|
162
163
|
}
|
|
164
|
+
|
|
165
|
+
private _buildImportPath(importDirectory: string, subPath: string, filename: string): string {
|
|
166
|
+
// Rimuove slash iniziali e finali da ogni parte
|
|
167
|
+
const parts = [importDirectory, subPath]
|
|
168
|
+
.filter(p => p && p.length > 0)
|
|
169
|
+
.map(p => p.replace(/^\/+|\/+$/g, ''));
|
|
170
|
+
|
|
171
|
+
// Aggiunge il filename alla fine
|
|
172
|
+
parts.push(`${filename}.dart`);
|
|
173
|
+
|
|
174
|
+
// Unisce con un singolo slash
|
|
175
|
+
return parts.join('/');
|
|
176
|
+
}
|
|
163
177
|
}
|