@devlearning/swagger-generator 1.0.26 → 1.0.28

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 (78) hide show
  1. package/.vscode/launch.json +28 -22
  2. package/README.md +209 -209
  3. package/dist/api.constants.js +22 -22
  4. package/dist/generators-writers/angular/api-angular-writer.js +15 -15
  5. package/dist/generators-writers/angular/constants.js +24 -24
  6. package/dist/generators-writers/angular/model-angular-writer.js +6 -6
  7. package/dist/generators-writers/dart/templates/api.mustache +36 -36
  8. package/dist/generators-writers/dart/templates/enum.mustache +14 -13
  9. package/dist/generators-writers/dart/templates/model.mustache +17 -17
  10. package/dist/generators-writers/nextjs/api-nextjs-writer.js +12 -12
  11. package/dist/generators-writers/nextjs/constants.js +4 -4
  12. package/dist/generators-writers/nextjs/model-nextjs-writer.js +6 -6
  13. package/dist/models/swagger-component-property.js +1 -0
  14. package/dist/models/swagger-component.js +1 -0
  15. package/dist/models/swagger-content.js +1 -0
  16. package/dist/models/swagger-info.js +1 -0
  17. package/dist/models/swagger-method.js +1 -0
  18. package/dist/models/swagger-schema.js +1 -0
  19. package/dist/models/swagger.js +1 -0
  20. package/package.json +45 -45
  21. package/src/api.constants.ts +26 -26
  22. package/src/generator-old.ts +449 -449
  23. package/src/generator.ts +582 -582
  24. package/src/generators-writers/angular/api-angular-writer.ts +141 -141
  25. package/src/generators-writers/angular/constants.ts +36 -36
  26. package/src/generators-writers/angular/model-angular-writer.ts +62 -62
  27. package/src/generators-writers/dart/api-dart-writer.ts +190 -190
  28. package/src/generators-writers/dart/model-dart-writer.ts +162 -162
  29. package/src/generators-writers/dart/models/import-definition-dart.ts +5 -5
  30. package/src/generators-writers/dart/normalizator.ts +72 -72
  31. package/src/generators-writers/dart/templates/api.mustache +36 -36
  32. package/src/generators-writers/dart/templates/enum.mustache +14 -13
  33. package/src/generators-writers/dart/templates/model.mustache +17 -17
  34. package/src/generators-writers/nextjs/api-nextjs-writer.ts +156 -156
  35. package/src/generators-writers/nextjs/constants.ts +5 -5
  36. package/src/generators-writers/nextjs/model-nextjs-writer.ts +61 -61
  37. package/src/generators-writers/utils.ts +78 -78
  38. package/src/index.ts +96 -96
  39. package/src/models/api-dto.ts +17 -17
  40. package/src/models/enum-value-dto.ts +3 -3
  41. package/src/models/model-dto.ts +9 -9
  42. package/src/models/parameter-dto.ts +7 -7
  43. package/src/models/property-dto.ts +4 -4
  44. package/src/models/swagger/swagger-component-property.ts +11 -11
  45. package/src/models/swagger/swagger-component.ts +17 -17
  46. package/src/models/swagger/swagger-content.ts +4 -4
  47. package/src/models/swagger/swagger-info.ts +3 -3
  48. package/src/models/swagger/swagger-method.ts +7 -7
  49. package/src/models/swagger/swagger-schema.ts +20 -20
  50. package/src/models/swagger/swagger.ts +38 -38
  51. package/src/models/type-dto.ts +7 -7
  52. package/src/swagger-downloader.ts +12 -12
  53. package/tsconfig.json +28 -28
  54. package/autogen/identity/api/identity_api.dart +0 -100
  55. package/autogen/identity/models/auth_activate_command.dart +0 -14
  56. package/autogen/identity/models/auth_app_authenticate_command.dart +0 -16
  57. package/autogen/identity/models/auth_generate_reset_password_code_command.dart +0 -15
  58. package/autogen/identity/models/auth_refresh_token_command.dart +0 -15
  59. package/autogen/identity/models/auth_reset_password_command.dart +0 -16
  60. package/autogen/identity/models/auth_user_authenticate_command.dart +0 -15
  61. package/autogen/identity/models/auth_user_dto.dart +0 -18
  62. package/autogen/identity/models/auth_verify_reset_password_code_command.dart +0 -14
  63. package/autogen/identity/models/authentication_token.dart +0 -17
  64. package/autogen/mvc/models/problem_details.dart +0 -17
  65. package/autogen/product/api/product_api.dart +0 -70
  66. package/autogen/product/models/geoposition.dart +0 -14
  67. package/autogen/product/models/product_category_dto.dart +0 -15
  68. package/autogen/product/models/product_category_list_query_response.dart +0 -14
  69. package/autogen/product/models/product_category_save_command.dart +0 -15
  70. package/autogen/product/models/product_list_nearby_query.dart +0 -20
  71. package/autogen/product/models/product_list_nearby_query_filter.dart +0 -15
  72. package/autogen/product/models/product_list_nearby_query_order_by.dart +0 -10
  73. package/autogen/product/models/product_save_command.dart +0 -13
  74. package/autogen/service_defaults/models/application_exception.dart +0 -14
  75. package/autogen/service_defaults/models/result.dart +0 -17
  76. package/autogen/service_defaults/models/sort_direction.dart +0 -10
  77. package/autogen/user_profile/api/user_profile_api.dart +0 -51
  78. package/autogen/user_profile/models/user_general_info_save_command.dart +0 -17
@@ -1,163 +1,163 @@
1
- import fs, { readFileSync, writeFileSync } from 'fs';
2
- import { ModelDto } from '@src/models/model-dto.js';
3
- import * as Mustache from 'mustache';
4
- import { Utils } from '../utils.js';
5
- import { CommandLineArgs } from '@src/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
- }
22
-
23
- interface EnumItemDefinitionDart {
24
- name: string;
25
- value: string;
26
- isLast: boolean;
27
- }
28
-
29
- interface FieldDefinitionDart {
30
- name: string;
31
- type: string;
32
- typeName: string;
33
- nullable: string;
34
- required: string;
35
- }
36
-
37
- interface ExportClassDefinitionDart {
38
- classes: ClassDefinitionDart[];
39
- }
40
-
41
- interface ExportEnumDefinitionDart {
42
- classes: EnumDefinitionDart[];
43
- }
44
-
45
- interface ExportModelItemDefinitionDart {
46
- filename?: string;
47
- }
48
-
49
- export class ModelDartWriter {
50
- private _commandLineArgs: CommandLineArgs;
51
-
52
- constructor(commandLineArgs: CommandLineArgs) {
53
- this._commandLineArgs = commandLineArgs;
54
- }
55
-
56
- write(models: ModelDto[]) {
57
- this.writeEnums(models.filter(m => m.modelType === 'enum'));
58
- this.writeClasses(models);
59
- }
60
-
61
- writeClasses(models: ModelDto[]) {
62
- const __filename = fileURLToPath(import.meta.url);
63
- const __dirname = path.dirname(__filename);
64
- const templatePath = path.join(__dirname, 'templates', 'model.mustache');
65
- const template = readFileSync(templatePath, 'utf-8');
66
-
67
- let importDirectory = this._commandLineArgs.outputDirectory;
68
- if (importDirectory.startsWith('lib/')) {
69
- importDirectory = importDirectory.slice('lib/'.length);
70
- }
71
-
72
- models.forEach(model => {
73
- if (model.modelType === 'class' || model.modelType === 'interface') {
74
- const normalizedInfo = Normalizator.getNormalizedInfo(model);
75
- const dartModel = <ClassDefinitionDart>{
76
- filename: normalizedInfo.filename,
77
- path: this._commandLineArgs.outputDirectory,
78
- className: normalizedInfo.modelName,
79
- fields: [],
80
- imports: [],
81
- };
82
-
83
- var imports = <ImportDefinitionDart[]>[];
84
-
85
- model.properties.forEach(property => {
86
- var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
87
-
88
- fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
89
-
90
- dartModel.fields!.push(<FieldDefinitionDart>{
91
- name: property.name,
92
- type: fieldTypeName,
93
- typeName: property.typeName,
94
- nullable: property.nullable ? '?' : '',
95
- required: property.nullable ? '' : 'required ',
96
- });
97
-
98
- if (property.isTypeReference) {
99
- if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
100
- models.forEach(currModel => {
101
- if (currModel.typeName === property.typeName) {
102
- const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
103
- imports.push({
104
- type: property,
105
- import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
106
- });
107
- }
108
- });
109
- }
110
- }
111
- });
112
-
113
- dartModel.imports = imports.map(i => i.import);
114
-
115
- let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
116
-
117
- Utils.ensureDirectorySync(`${destinationPath}`);
118
-
119
- let result = Mustache.default.render(template, dartModel);
120
- writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
121
- }
122
- });
123
- }
124
-
125
- writeEnums(models: ModelDto[]) {
126
- const __filename = fileURLToPath(import.meta.url);
127
- const __dirname = path.dirname(__filename);
128
- const templatePath = path.join(__dirname, 'templates', 'enum.mustache');
129
- const template = readFileSync(templatePath, 'utf-8');
130
-
131
- let importDirectory = this._commandLineArgs.outputDirectory;
132
- if (importDirectory.startsWith('lib/')) {
133
- importDirectory = importDirectory.slice('lib/'.length);
134
- }
135
-
136
- models.forEach(model => {
137
- const normalizedInfo = Normalizator.getNormalizedInfo(model);
138
- const dartModel = <EnumDefinitionDart>{
139
- enumName: normalizedInfo.modelName,
140
- path: this._commandLineArgs.outputDirectory,
141
- fields: [],
142
- };
143
-
144
- model.enumValues.forEach(enumItem => {
145
- dartModel.fields!.push(<EnumItemDefinitionDart>{
146
- name: enumItem.name,
147
- value: enumItem.value,
148
- isLast: false,
149
- });
150
- });
151
-
152
- const lastIndex = dartModel.fields!.length - 1;
153
- dartModel.fields![lastIndex].isLast = true;
154
-
155
- let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
156
-
157
- Utils.ensureDirectorySync(`${destinationPath}`);
158
-
159
- let result = Mustache.default.render(template, dartModel);
160
- writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
161
- });
162
- }
1
+ import fs, { readFileSync, writeFileSync } from 'fs';
2
+ import { ModelDto } from '@src/models/model-dto.js';
3
+ import * as Mustache from 'mustache';
4
+ import { Utils } from '../utils.js';
5
+ import { CommandLineArgs } from '@src/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
+ }
22
+
23
+ interface EnumItemDefinitionDart {
24
+ name: string;
25
+ value: string;
26
+ isLast: boolean;
27
+ }
28
+
29
+ interface FieldDefinitionDart {
30
+ name: string;
31
+ type: string;
32
+ typeName: string;
33
+ nullable: string;
34
+ required: string;
35
+ }
36
+
37
+ interface ExportClassDefinitionDart {
38
+ classes: ClassDefinitionDart[];
39
+ }
40
+
41
+ interface ExportEnumDefinitionDart {
42
+ classes: EnumDefinitionDart[];
43
+ }
44
+
45
+ interface ExportModelItemDefinitionDart {
46
+ filename?: string;
47
+ }
48
+
49
+ export class ModelDartWriter {
50
+ private _commandLineArgs: CommandLineArgs;
51
+
52
+ constructor(commandLineArgs: CommandLineArgs) {
53
+ this._commandLineArgs = commandLineArgs;
54
+ }
55
+
56
+ write(models: ModelDto[]) {
57
+ this.writeEnums(models.filter(m => m.modelType === 'enum'));
58
+ this.writeClasses(models);
59
+ }
60
+
61
+ writeClasses(models: ModelDto[]) {
62
+ const __filename = fileURLToPath(import.meta.url);
63
+ const __dirname = path.dirname(__filename);
64
+ const templatePath = path.join(__dirname, 'templates', 'model.mustache');
65
+ const template = readFileSync(templatePath, 'utf-8');
66
+
67
+ let importDirectory = this._commandLineArgs.outputDirectory;
68
+ if (importDirectory.startsWith('lib/')) {
69
+ importDirectory = importDirectory.slice('lib/'.length);
70
+ }
71
+
72
+ models.forEach(model => {
73
+ if (model.modelType === 'class' || model.modelType === 'interface') {
74
+ const normalizedInfo = Normalizator.getNormalizedInfo(model);
75
+ const dartModel = <ClassDefinitionDart>{
76
+ filename: normalizedInfo.filename,
77
+ path: this._commandLineArgs.outputDirectory,
78
+ className: normalizedInfo.modelName,
79
+ fields: [],
80
+ imports: [],
81
+ };
82
+
83
+ var imports = <ImportDefinitionDart[]>[];
84
+
85
+ model.properties.forEach(property => {
86
+ var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
87
+
88
+ fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
89
+
90
+ dartModel.fields!.push(<FieldDefinitionDart>{
91
+ name: property.name,
92
+ type: fieldTypeName,
93
+ typeName: property.typeName,
94
+ nullable: property.nullable ? '?' : '',
95
+ required: property.nullable ? '' : 'required ',
96
+ });
97
+
98
+ if (property.isTypeReference) {
99
+ if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
100
+ models.forEach(currModel => {
101
+ if (currModel.typeName === property.typeName) {
102
+ const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
103
+ imports.push({
104
+ type: property,
105
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
106
+ });
107
+ }
108
+ });
109
+ }
110
+ }
111
+ });
112
+
113
+ dartModel.imports = imports.map(i => i.import);
114
+
115
+ let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
116
+
117
+ Utils.ensureDirectorySync(`${destinationPath}`);
118
+
119
+ let result = Mustache.default.render(template, dartModel);
120
+ writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
121
+ }
122
+ });
123
+ }
124
+
125
+ writeEnums(models: ModelDto[]) {
126
+ const __filename = fileURLToPath(import.meta.url);
127
+ const __dirname = path.dirname(__filename);
128
+ const templatePath = path.join(__dirname, 'templates', 'enum.mustache');
129
+ const template = readFileSync(templatePath, 'utf-8');
130
+
131
+ let importDirectory = this._commandLineArgs.outputDirectory;
132
+ if (importDirectory.startsWith('lib/')) {
133
+ importDirectory = importDirectory.slice('lib/'.length);
134
+ }
135
+
136
+ models.forEach(model => {
137
+ const normalizedInfo = Normalizator.getNormalizedInfo(model);
138
+ const dartModel = <EnumDefinitionDart>{
139
+ enumName: normalizedInfo.modelName,
140
+ path: this._commandLineArgs.outputDirectory,
141
+ fields: [],
142
+ };
143
+
144
+ model.enumValues.forEach(enumItem => {
145
+ dartModel.fields!.push(<EnumItemDefinitionDart>{
146
+ name: enumItem.name,
147
+ value: enumItem.value,
148
+ isLast: false,
149
+ });
150
+ });
151
+
152
+ const lastIndex = dartModel.fields!.length - 1;
153
+ dartModel.fields![lastIndex].isLast = true;
154
+
155
+ let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
156
+
157
+ Utils.ensureDirectorySync(`${destinationPath}`);
158
+
159
+ let result = Mustache.default.render(template, dartModel);
160
+ writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
161
+ });
162
+ }
163
163
  }
@@ -1,6 +1,6 @@
1
- import { TypeDto } from "@src/models/type-dto.js";
2
-
3
- export interface ImportDefinitionDart {
4
- type: TypeDto;
5
- import: string
1
+ import { TypeDto } from "@src/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 "@src/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 "@src/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
  }
@@ -1,36 +1,36 @@
1
- import 'package:{{package}}/core/di/injector.dart';
2
- import 'package:dio/dio.dart';
3
- {{#imports}}
4
- {{{.}}}
5
- {{/imports}}
6
-
7
- class {{apiClassName}} {
8
- final Dio _dio;
9
-
10
- {{apiClassName}}() : _dio = getIt<Dio>();
11
-
12
- {{#endpoints}}
13
- Future<{{responseType}}> {{methodName}}(
14
- {{#haveRequest}}{{requestType}} request{{/haveRequest}}
15
- {{#queryParams}}
16
- {{type}}{{#nullable}}?{{/nullable}} {{name}},
17
- {{/queryParams}}
18
- ) async {
19
- final response = await _dio.{{httpMethod}}(
20
- '{{{path}}}',
21
- {{#haveRequest}}
22
- data: request.toJson(),
23
- {{/haveRequest}}
24
- {{^haveRequest}}
25
- queryParameters: {
26
- {{#queryParams}}
27
- {{#nullable}}if ({{name}} != null) {{/nullable}}'{{name}}': {{name}},
28
- {{/queryParams}}
29
- },
30
- {{/haveRequest}}
31
- );
32
- return {{responseType}}.fromJson(response.data);
33
- }
34
-
35
- {{/endpoints}}
36
- }
1
+ import 'package:{{package}}/core/di/injector.dart';
2
+ import 'package:dio/dio.dart';
3
+ {{#imports}}
4
+ {{{.}}}
5
+ {{/imports}}
6
+
7
+ class {{apiClassName}} {
8
+ final Dio _dio;
9
+
10
+ {{apiClassName}}() : _dio = getIt<Dio>();
11
+
12
+ {{#endpoints}}
13
+ Future<{{responseType}}> {{methodName}}(
14
+ {{#haveRequest}}{{requestType}} request{{/haveRequest}}
15
+ {{#queryParams}}
16
+ {{type}}{{#nullable}}?{{/nullable}} {{name}},
17
+ {{/queryParams}}
18
+ ) async {
19
+ final response = await _dio.{{httpMethod}}(
20
+ '{{{path}}}',
21
+ {{#haveRequest}}
22
+ data: request.toJson(),
23
+ {{/haveRequest}}
24
+ {{^haveRequest}}
25
+ queryParameters: {
26
+ {{#queryParams}}
27
+ {{#nullable}}if ({{name}} != null) {{/nullable}}'{{name}}': {{name}},
28
+ {{/queryParams}}
29
+ },
30
+ {{/haveRequest}}
31
+ );
32
+ return {{responseType}}.fromJson(response.data);
33
+ }
34
+
35
+ {{/endpoints}}
36
+ }
@@ -1,14 +1,15 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- {{#imports}}
3
- {{{.}}}
4
- {{/imports}}
5
-
6
- @JsonEnum(fieldRename: FieldRename.pascal)
7
- enum {{enumName}} {
8
- {{#fields}}
9
- {{name}}({{value}}){{#isLast}};{{/isLast}}{{^isLast}},{{/isLast}}
10
- {{/fields}}
11
-
12
- final int value;
13
- const {{enumName}}(this.value);
1
+ import 'package:freezed_annotation/freezed_annotation.dart';
2
+ {{#imports}}
3
+ {{{.}}}
4
+ {{/imports}}
5
+
6
+ @JsonEnum(fieldRename: FieldRename.pascal)
7
+ enum {{enumName}} {
8
+ {{#fields}}
9
+ @JsonValue({{value}})
10
+ {{name}}({{value}}){{#isLast}};{{/isLast}}{{^isLast}},{{/isLast}}
11
+ {{/fields}}
12
+
13
+ final int value;
14
+ const {{enumName}}(this.value);
14
15
  }
@@ -1,18 +1,18 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- {{#imports}}
3
- {{{.}}}
4
- {{/imports}}
5
-
6
- part '{{filename}}.freezed.dart';
7
- part '{{filename}}.g.dart';
8
-
9
- @freezed
10
- abstract class {{className}} with _${{className}} {
11
- const factory {{className}}({
12
- {{#fields}}
13
- {{required}}{{type}}{{nullable}} {{name}},
14
- {{/fields}}
15
- }) = _{{className}};
16
-
17
- factory {{className}}.fromJson(Map<String, dynamic> json) => _${{className}}FromJson(json);
1
+ import 'package:freezed_annotation/freezed_annotation.dart';
2
+ {{#imports}}
3
+ {{{.}}}
4
+ {{/imports}}
5
+
6
+ part '{{filename}}.freezed.dart';
7
+ part '{{filename}}.g.dart';
8
+
9
+ @freezed
10
+ abstract class {{className}} with _${{className}} {
11
+ const factory {{className}}({
12
+ {{#fields}}
13
+ {{required}}{{type}}{{nullable}} {{name}},
14
+ {{/fields}}
15
+ }) = _{{className}};
16
+
17
+ factory {{className}}.fromJson(Map<String, dynamic> json) => _${{className}}FromJson(json);
18
18
  }