@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.
@@ -14,8 +14,8 @@
14
14
  "type": "node-terminal"
15
15
  },
16
16
  {
17
- "command": "npm run debug-dart",
18
- "name": "Debug Dart",
17
+ "command": "npm run debug-flutter",
18
+ "name": "Debug Flutter",
19
19
  "request": "launch",
20
20
  "type": "node-terminal"
21
21
  }
@@ -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? name,
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 templatePath = path.join(__dirname, 'generators-writers', 'dart', 'templates', 'api.mustache');
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
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 templatePath = path.join(__dirname, 'generators-writers', 'dart', 'templates', 'model.mustache');
13
- const template = readFileSync('src/generators-writers/dart/templates/model.mustache', 'utf-8');
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
44
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
38
45
  });
39
46
  }
40
47
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlearning/swagger-generator",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Swagger generator apis and models for Angular and NextJS",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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 templatePath = path.join(__dirname, 'generators-writers', 'dart', 'templates', 'api.mustache');
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
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 templatePath = path.join(__dirname, 'generators-writers', 'dart', 'templates', 'model.mustache');
41
- const template = readFileSync('src/generators-writers/dart/templates/model.mustache', 'utf-8');
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}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
78
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
72
79
  });
73
80
  }
74
81
  });