@devlearning/swagger-generator 1.0.24 → 1.0.25

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 (76) hide show
  1. package/.vscode/launch.json +22 -22
  2. package/README.md +209 -209
  3. package/autogen/identity/api/identity_api.dart +100 -100
  4. package/autogen/identity/models/auth_activate_command.dart +14 -14
  5. package/autogen/identity/models/auth_app_authenticate_command.dart +16 -16
  6. package/autogen/identity/models/auth_generate_reset_password_code_command.dart +15 -15
  7. package/autogen/identity/models/auth_refresh_token_command.dart +15 -15
  8. package/autogen/identity/models/auth_reset_password_command.dart +16 -16
  9. package/autogen/identity/models/auth_user_authenticate_command.dart +15 -15
  10. package/autogen/identity/models/auth_user_dto.dart +18 -18
  11. package/autogen/identity/models/auth_verify_reset_password_code_command.dart +14 -14
  12. package/autogen/identity/models/authentication_token.dart +17 -17
  13. package/autogen/mvc/models/problem_details.dart +17 -17
  14. package/autogen/product/api/product_api.dart +70 -0
  15. package/autogen/product/models/geoposition.dart +14 -0
  16. package/autogen/product/models/product_category_dto.dart +15 -0
  17. package/autogen/product/models/product_category_list_query_response.dart +14 -0
  18. package/autogen/product/models/product_category_save_command.dart +15 -0
  19. package/autogen/product/models/product_list_nearby_query.dart +20 -0
  20. package/autogen/product/models/product_list_nearby_query_filter.dart +15 -0
  21. package/autogen/product/models/product_list_nearby_query_order_by.dart +10 -0
  22. package/autogen/product/models/product_save_command.dart +13 -0
  23. package/autogen/service_defaults/models/application_exception.dart +14 -14
  24. package/autogen/service_defaults/models/result.dart +17 -17
  25. package/autogen/service_defaults/models/sort_direction.dart +10 -0
  26. package/autogen/user_profile/api/user_profile_api.dart +51 -62
  27. package/autogen/user_profile/models/user_general_info_save_command.dart +17 -13
  28. package/dist/api.constants.js +22 -22
  29. package/dist/generator.js +9 -4
  30. package/dist/generators-writers/angular/api-angular-writer.js +15 -15
  31. package/dist/generators-writers/angular/constants.js +24 -24
  32. package/dist/generators-writers/angular/model-angular-writer.js +6 -6
  33. package/dist/generators-writers/dart/model-dart-writer.js +63 -60
  34. package/dist/generators-writers/dart/templates/api.mustache +36 -36
  35. package/dist/generators-writers/dart/templates/enum.mustache +14 -0
  36. package/dist/generators-writers/dart/templates/model.mustache +18 -18
  37. package/dist/generators-writers/nextjs/api-nextjs-writer.js +12 -12
  38. package/dist/generators-writers/nextjs/constants.js +4 -4
  39. package/dist/generators-writers/nextjs/model-nextjs-writer.js +6 -6
  40. package/package.json +45 -45
  41. package/src/api.constants.ts +26 -26
  42. package/src/generator-old.ts +449 -449
  43. package/src/generator.ts +582 -577
  44. package/src/generators-writers/angular/api-angular-writer.ts +141 -141
  45. package/src/generators-writers/angular/constants.ts +36 -36
  46. package/src/generators-writers/angular/model-angular-writer.ts +62 -62
  47. package/src/generators-writers/dart/api-dart-writer.ts +190 -190
  48. package/src/generators-writers/dart/model-dart-writer.ts +162 -143
  49. package/src/generators-writers/dart/models/import-definition-dart.ts +5 -5
  50. package/src/generators-writers/dart/normalizator.ts +72 -72
  51. package/src/generators-writers/dart/templates/api.mustache +36 -36
  52. package/src/generators-writers/dart/templates/enum.mustache +14 -0
  53. package/src/generators-writers/dart/templates/model.mustache +18 -18
  54. package/src/generators-writers/nextjs/api-nextjs-writer.ts +156 -156
  55. package/src/generators-writers/nextjs/constants.ts +5 -5
  56. package/src/generators-writers/nextjs/model-nextjs-writer.ts +61 -61
  57. package/src/generators-writers/utils.ts +78 -78
  58. package/src/index.ts +96 -96
  59. package/src/models/api-dto.ts +17 -17
  60. package/src/models/enum-value-dto.ts +3 -3
  61. package/src/models/model-dto.ts +9 -9
  62. package/src/models/parameter-dto.ts +7 -7
  63. package/src/models/property-dto.ts +4 -4
  64. package/src/models/swagger/swagger-component-property.ts +11 -11
  65. package/src/models/swagger/swagger-component.ts +17 -17
  66. package/src/models/swagger/swagger-content.ts +4 -4
  67. package/src/models/swagger/swagger-info.ts +3 -3
  68. package/src/models/swagger/swagger-method.ts +7 -7
  69. package/src/models/swagger/swagger-schema.ts +20 -20
  70. package/src/models/swagger/swagger.ts +38 -38
  71. package/src/models/type-dto.ts +7 -7
  72. package/src/swagger-downloader.ts +12 -12
  73. package/tsconfig.json +28 -28
  74. package/autogen/user_profile/models/test_save_command.dart +0 -13
  75. package/dist/templates/api.mustache +0 -29
  76. package/dist/templates/model.mustache +0 -18
@@ -1,144 +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 ModelDefinitionDart {
12
- modelName?: string;
13
- fields?: { name: string; type: string }[];
14
- imports?: string[];
15
- }
16
-
17
- interface FieldDefinitionDart {
18
- name: string;
19
- type: string;
20
- typeName: string;
21
- nullable: string;
22
- required: string;
23
- }
24
-
25
- interface ExportModelDefinitionDart {
26
- models: ExportModelItemDefinitionDart[];
27
- }
28
-
29
- interface ExportModelItemDefinitionDart {
30
- filename?: string;
31
- }
32
-
33
- export class ModelDartWriter {
34
- private _commandLineArgs: CommandLineArgs;
35
-
36
- constructor(commandLineArgs: CommandLineArgs) {
37
- this._commandLineArgs = commandLineArgs;
38
- }
39
-
40
- write(models: ModelDto[]) {
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
- }
49
-
50
- models.forEach(model => {
51
- const normalizedInfo = Normalizator.getNormalizedInfo(model);
52
- const dartModel = <ModelDefinitionDart>{
53
- filename: normalizedInfo.filename,
54
- path: this._commandLineArgs.outputDirectory,
55
- modelName: normalizedInfo.modelName,
56
- fields: [],
57
- imports: [],
58
- };
59
-
60
- var imports = <ImportDefinitionDart[]>[];
61
-
62
- model.properties.forEach(property => {
63
- var fieldTypeName = Normalizator.mapTsTypeToDart(property.typeName);
64
-
65
- fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
66
-
67
- if (property.isTypeReference) {
68
- if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
69
- models.forEach(currModel => {
70
- if (currModel.typeName === property.typeName) {
71
- const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
72
- imports.push({
73
- type: property,
74
- import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
75
- });
76
- }
77
- });
78
- }
79
- }
80
-
81
-
82
- dartModel.fields!.push(<FieldDefinitionDart>{
83
- name: property.name,
84
- type: fieldTypeName,
85
- typeName: property.typeName,
86
- nullable: property.nullable ? '?' : '',
87
- required: property.nullable ? '' : 'required ',
88
- });
89
-
90
- });
91
-
92
- dartModel.imports = imports.map(i => i.import);
93
-
94
- let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
95
-
96
- Utils.ensureDirectorySync(`${destinationPath}`);
97
-
98
- let result = Mustache.default.render(template, dartModel);
99
- writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
100
- });
101
-
102
- // var exportDataModels = <ExportModelItemDefinitionDart[]>[];
103
- // models.forEach(model => {
104
- // exportDataModels.push({
105
- // filename: `${model.filename}.dart`
106
- // });
107
- // });
108
-
109
- // var exportData = <ExportModelDefinitionDart>{
110
- // models: exportDataModels
111
- // };
112
- // const exportTemplate = readFileSync('src/generators-writers/dart/templates/model.export.mustache', 'utf-8');
113
- // const exportContent = Mustache.default.render(exportTemplate, exportData);
114
- // writeFileSync(`${this._commandLineArgs.outputDirectory}/_export_models.dart`, exportContent, 'utf-8');
115
-
116
- // const model = [
117
- // {
118
- // filename: 'login_request',
119
- // modelName: 'LoginRequest',
120
- // fields: [
121
- // { name: 'email', type: 'String' },
122
- // { name: 'password', type: 'String' }
123
- // ]
124
- // },
125
- // {
126
- // filename: 'login_response',
127
- // modelName: 'LoginResponse',
128
- // fields: [
129
- // { name: 'token', type: 'String' }
130
- // ]
131
- // }
132
- // ];
133
-
134
-
135
- // let modelString = '';
136
-
137
- // models.forEach(model => {
138
- // modelString += this._modelString(model);
139
- // });
140
-
141
-
142
- // this._writeFile(modelString);
143
- }
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
+ }
144
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
+ }
@@ -0,0 +1,14 @@
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);
14
+ }
@@ -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 {{modelName}} with _${{modelName}} {
11
- const factory {{modelName}}({
12
- {{#fields}}
13
- {{required}}{{type}}{{nullable}} {{name}},
14
- {{/fields}}
15
- }) = _{{modelName}};
16
-
17
- factory {{modelName}}.fromJson(Map<String, dynamic> json) => _${{modelName}}FromJson(json);
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 {{modelName}} with _${{modelName}} {
11
+ const factory {{modelName}}({
12
+ {{#fields}}
13
+ {{required}}{{type}}{{nullable}} {{name}},
14
+ {{/fields}}
15
+ }) = _{{modelName}};
16
+
17
+ factory {{modelName}}.fromJson(Map<String, dynamic> json) => _${{modelName}}FromJson(json);
18
+ }