@devlearning/swagger-generator 1.0.17 → 1.0.19
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/.vscode/launch.json +2 -2
- package/autogen/user_profile/models/test_read_query.dart +2 -1
- package/dist/generators-writers/dart/api-dart-writer.js +10 -3
- package/dist/generators-writers/dart/model-dart-writer.js +10 -3
- package/package.json +1 -1
- package/src/generators-writers/dart/api-dart-writer.ts +10 -3
- package/src/generators-writers/dart/model-dart-writer.ts +10 -3
package/.vscode/launch.json
CHANGED
|
@@ -6,7 +6,8 @@ part 'test_read_query.g.dart';
|
|
|
6
6
|
@freezed
|
|
7
7
|
abstract class TestReadQuery with _$TestReadQuery {
|
|
8
8
|
const factory TestReadQuery({
|
|
9
|
-
String
|
|
9
|
+
required String name,
|
|
10
|
+
required String date,
|
|
10
11
|
}) = _TestReadQuery;
|
|
11
12
|
|
|
12
13
|
factory TestReadQuery.fromJson(Map<String, dynamic> json) => _$TestReadQueryFromJson(json);
|
|
@@ -3,14 +3,21 @@ import { Utils } from '../utils.js';
|
|
|
3
3
|
import * as Mustache from 'mustache';
|
|
4
4
|
import { Normalizator } from './normalizator.js';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
6
7
|
export class ApiDartWriter {
|
|
7
8
|
_commandLineArgs;
|
|
8
9
|
constructor(commandLineArgs) {
|
|
9
10
|
this._commandLineArgs = commandLineArgs;
|
|
10
11
|
}
|
|
11
12
|
write(apis, models) {
|
|
12
|
-
const
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
const templatePath = path.join(__dirname, 'templates', 'api.mustache');
|
|
13
16
|
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
17
|
+
let importDirectory = this._commandLineArgs.outputDirectory;
|
|
18
|
+
if (importDirectory.startsWith('lib/')) {
|
|
19
|
+
importDirectory = importDirectory.slice('lib/'.length);
|
|
20
|
+
}
|
|
14
21
|
const grouped = this._groupByTag(apis);
|
|
15
22
|
for (const [tag, apis] of Object.entries(grouped)) {
|
|
16
23
|
console.log(`Api: ${tag}`);
|
|
@@ -58,7 +65,7 @@ export class ApiDartWriter {
|
|
|
58
65
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
59
66
|
imports.push({
|
|
60
67
|
type: api.parameters[0],
|
|
61
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
68
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
62
69
|
});
|
|
63
70
|
}
|
|
64
71
|
});
|
|
@@ -71,7 +78,7 @@ export class ApiDartWriter {
|
|
|
71
78
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
72
79
|
imports.push({
|
|
73
80
|
type: api.returnType,
|
|
74
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
81
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
75
82
|
});
|
|
76
83
|
}
|
|
77
84
|
});
|
|
@@ -3,14 +3,21 @@ import * as Mustache from 'mustache';
|
|
|
3
3
|
import { Utils } from '../utils.js';
|
|
4
4
|
import { Normalizator } from './normalizator.js';
|
|
5
5
|
import path from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
6
7
|
export class ModelDartWriter {
|
|
7
8
|
_commandLineArgs;
|
|
8
9
|
constructor(commandLineArgs) {
|
|
9
10
|
this._commandLineArgs = commandLineArgs;
|
|
10
11
|
}
|
|
11
12
|
write(models) {
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
14
|
+
const __dirname = path.dirname(__filename);
|
|
15
|
+
const templatePath = path.join(__dirname, 'templates', 'model.mustache');
|
|
16
|
+
const template = readFileSync(templatePath, 'utf-8');
|
|
17
|
+
let importDirectory = this._commandLineArgs.outputDirectory;
|
|
18
|
+
if (importDirectory.startsWith('lib/')) {
|
|
19
|
+
importDirectory = importDirectory.slice('lib/'.length);
|
|
20
|
+
}
|
|
14
21
|
models.forEach(model => {
|
|
15
22
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
16
23
|
const dartModel = {
|
|
@@ -34,7 +41,7 @@ export class ModelDartWriter {
|
|
|
34
41
|
const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
|
|
35
42
|
imports.push({
|
|
36
43
|
type: property,
|
|
37
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
44
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
38
45
|
});
|
|
39
46
|
}
|
|
40
47
|
});
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@ import { TypeDto } from '@src/models/type-dto.js';
|
|
|
9
9
|
import { ImportDefinitionDart } from './models/import-definition-dart.js';
|
|
10
10
|
import { Normalizator } from './normalizator.js';
|
|
11
11
|
import path from 'path';
|
|
12
|
+
import { fileURLToPath } from 'url';
|
|
12
13
|
|
|
13
14
|
interface ApiDefinitionDart {
|
|
14
15
|
package: string;
|
|
@@ -40,8 +41,14 @@ export class ApiDartWriter {
|
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
write(apis: ApiDto[], models: ModelDto[]) {
|
|
43
|
-
const
|
|
44
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
45
|
+
const __dirname = path.dirname(__filename);
|
|
46
|
+
const templatePath = path.join(__dirname, 'templates', 'api.mustache');
|
|
44
47
|
const template = fs.readFileSync(templatePath, 'utf-8');
|
|
48
|
+
let importDirectory = this._commandLineArgs.outputDirectory;
|
|
49
|
+
if(importDirectory.startsWith('lib/')) {
|
|
50
|
+
importDirectory = importDirectory.slice('lib/'.length);
|
|
51
|
+
}
|
|
45
52
|
|
|
46
53
|
const grouped = this._groupByTag(apis);
|
|
47
54
|
|
|
@@ -100,7 +107,7 @@ export class ApiDartWriter {
|
|
|
100
107
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
101
108
|
imports.push({
|
|
102
109
|
type: api.parameters[0],
|
|
103
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
110
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
104
111
|
});
|
|
105
112
|
}
|
|
106
113
|
});
|
|
@@ -114,7 +121,7 @@ export class ApiDartWriter {
|
|
|
114
121
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
115
122
|
imports.push({
|
|
116
123
|
type: api.returnType!,
|
|
117
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
124
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
118
125
|
});
|
|
119
126
|
}
|
|
120
127
|
});
|
|
@@ -6,6 +6,7 @@ import { CommandLineArgs } from '@src/index.js';
|
|
|
6
6
|
import { ImportDefinitionDart } from './models/import-definition-dart.js';
|
|
7
7
|
import { Normalizator } from './normalizator.js';
|
|
8
8
|
import path from 'path';
|
|
9
|
+
import { fileURLToPath } from 'url';
|
|
9
10
|
|
|
10
11
|
interface ModelDefinitionDart {
|
|
11
12
|
modelName?: string;
|
|
@@ -37,8 +38,14 @@ export class ModelDartWriter {
|
|
|
37
38
|
}
|
|
38
39
|
|
|
39
40
|
write(models: ModelDto[]) {
|
|
40
|
-
const
|
|
41
|
-
const
|
|
41
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
42
|
+
const __dirname = path.dirname(__filename);
|
|
43
|
+
const templatePath = path.join(__dirname, 'templates', 'model.mustache');
|
|
44
|
+
const template = readFileSync(templatePath, 'utf-8');
|
|
45
|
+
let importDirectory = this._commandLineArgs.outputDirectory;
|
|
46
|
+
if (importDirectory.startsWith('lib/')) {
|
|
47
|
+
importDirectory = importDirectory.slice('lib/'.length);
|
|
48
|
+
}
|
|
42
49
|
|
|
43
50
|
models.forEach(model => {
|
|
44
51
|
const normalizedInfo = Normalizator.getNormalizedInfo(model);
|
|
@@ -68,7 +75,7 @@ export class ModelDartWriter {
|
|
|
68
75
|
const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
|
|
69
76
|
imports.push({
|
|
70
77
|
type: property,
|
|
71
|
-
import: `import 'package:${this._commandLineArgs.package}/${
|
|
78
|
+
import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
|
|
72
79
|
});
|
|
73
80
|
}
|
|
74
81
|
});
|