@devlearning/swagger-generator 1.0.16 → 1.0.18

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,13 +3,16 @@ 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');
14
17
  const grouped = this._groupByTag(apis);
15
18
  for (const [tag, apis] of Object.entries(grouped)) {
@@ -3,14 +3,17 @@ 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');
14
17
  models.forEach(model => {
15
18
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
16
19
  const dartModel = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlearning/swagger-generator",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "Swagger generator apis and models for Angular and NextJS",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -9,7 +9,7 @@
9
9
  "debug-nextjs": "npx tsx src/index.ts --url http://localhost:7550/swagger/ApiGateway/swagger.json --output autogeneration/output --target next --dateTimeLibrary date-fns",
10
10
  "debug-flutter": "npx tsx src/index.ts --url http://localhost:7550/swagger/ApiGateway/swagger.json --output autogen --target flutter --package coqudo_app",
11
11
  "copy-templates": "copyfiles -u 3 \"src/generators-writers/dart/templates/**/*\" dist/generators-writers/dart",
12
- "deploy": "npx tsc & copyfiles & npm publish"
12
+ "deploy": "npx tsc && npm publish"
13
13
  },
14
14
  "bin": {
15
15
  "swgen": "./dist/index.js"
@@ -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,7 +41,9 @@ 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');
45
48
 
46
49
  const grouped = this._groupByTag(apis);
@@ -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,10 @@ 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');
42
45
 
43
46
  models.forEach(model => {
44
47
  const normalizedInfo = Normalizator.getNormalizedInfo(model);