@devlearning/swagger-generator 1.0.18 → 1.0.20

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 (30) hide show
  1. package/dist/generator.js +20 -19
  2. package/dist/generators-writers/angular/model-angular-writer.js +4 -1
  3. package/dist/generators-writers/dart/api-dart-writer.js +10 -2
  4. package/dist/generators-writers/dart/model-dart-writer.js +7 -5
  5. package/dist/generators-writers/nextjs/model-nextjs-writer.js +4 -1
  6. package/package.json +1 -1
  7. package/src/generator.ts +20 -21
  8. package/src/generators-writers/angular/model-angular-writer.ts +4 -1
  9. package/src/generators-writers/dart/api-dart-writer.ts +11 -2
  10. package/src/generators-writers/dart/model-dart-writer.ts +11 -10
  11. package/src/generators-writers/nextjs/model-nextjs-writer.ts +4 -1
  12. package/src/models/swagger/swagger-component.ts +1 -0
  13. package/autogen/identity/api/identity_api.dart +0 -82
  14. package/autogen/identity/models/auth_activate_command.dart +0 -14
  15. package/autogen/identity/models/auth_app_authenticate_command.dart +0 -16
  16. package/autogen/identity/models/auth_generate_reset_password_code_command.dart +0 -15
  17. package/autogen/identity/models/auth_refresh_token_command.dart +0 -15
  18. package/autogen/identity/models/auth_reset_password_command.dart +0 -16
  19. package/autogen/identity/models/auth_user_authenticate_command.dart +0 -15
  20. package/autogen/identity/models/auth_user_dto.dart +0 -18
  21. package/autogen/identity/models/auth_verify_reset_password_code_command.dart +0 -14
  22. package/autogen/identity/models/authentication_token.dart +0 -17
  23. package/autogen/mvc/models/problem_details.dart +0 -17
  24. package/autogen/service_defaults/models/application_exception.dart +0 -14
  25. package/autogen/service_defaults/models/result.dart +0 -17
  26. package/autogen/user_profile/api/user_profile_api.dart +0 -46
  27. package/autogen/user_profile/models/test_list_query.dart +0 -13
  28. package/autogen/user_profile/models/test_read_query.dart +0 -14
  29. package/autogen/user_profile/models/test_save_command.dart +0 -13
  30. package/autogen/user_profile/models/user_general_info_save_command.dart +0 -13
package/dist/generator.js CHANGED
@@ -3,7 +3,7 @@ import { ApiAngularWriter } from './generators-writers/angular/api-angular-write
3
3
  import { SingleBar, Presets } from 'cli-progress';
4
4
  import { ModelNextJsWriter } from './generators-writers/nextjs/model-nextjs-writer.js';
5
5
  import { ModelAngularWriter } from './generators-writers/angular/model-angular-writer.js';
6
- import { DateTimeLibrary, TargetGeneration } from './index.js';
6
+ import { TargetGeneration } from './index.js';
7
7
  import { ApiDartWriter } from './generators-writers/dart/api-dart-writer.js';
8
8
  import { ModelDartWriter } from './generators-writers/dart/model-dart-writer.js';
9
9
  import { Utils } from './generators-writers/utils.js';
@@ -49,7 +49,6 @@ export class Generator {
49
49
  const apiSwaggerMethodKey = this._swagger.paths[apiName];
50
50
  const apiMethod = Object.getOwnPropertyNames(apiSwaggerMethodKey)[0];
51
51
  const apiSwaggerMethod = apiSwaggerMethodKey[apiMethod];
52
- // console.debug(`\tAPI - ${apiName} - ${apiMethod}`);
53
52
  let apiDto = {
54
53
  name: apiName,
55
54
  url: apiName.replace('{version}', '1'),
@@ -109,7 +108,6 @@ export class Generator {
109
108
  for (let index = 0; index < Object.getOwnPropertyNames(this._swagger.components.schemas).length; index++) {
110
109
  const modelName = Object.getOwnPropertyNames(this._swagger.components.schemas)[index];
111
110
  const swaggerComponent = this._swagger.components.schemas[modelName];
112
- // console.debug(`\tModel - ${modelName}`);
113
111
  this._models.push({
114
112
  typeName: modelName,
115
113
  modelType: swaggerComponent.type == 'integer' ? 'enum' : 'class',
@@ -123,13 +121,14 @@ export class Generator {
123
121
  const swaggerMethod = this._swagger.paths[apiName];
124
122
  const method = Object.getOwnPropertyNames(swaggerMethod)[0];
125
123
  const swaggerMethodInfo = swaggerMethod[method];
126
- this._models.push({
127
- typeName: this.getApiNameNormalized(apiName),
128
- modelType: 'class',
129
- name: this.getApiNameNormalized(apiName),
130
- properties: this.retrieveComponentProperties(swaggerMethodInfo.requestBody.content[contentTypeMultipartFormData].schema),
131
- enumValues: [],
132
- });
124
+ throw new Error(`MultiPart FormData is not supported yet for ${apiName} - ${method}.`);
125
+ // this._models.push({
126
+ // typeName: this.getApiNameNormalized(apiName),
127
+ // modelType: 'class',
128
+ // name: this.getApiNameNormalized(apiName),
129
+ // properties: this.retrieveComponentProperties(swaggerMethodInfo.requestBody.content[contentTypeMultipartFormData].schema),
130
+ // enumValues: [],
131
+ // });
133
132
  });
134
133
  }
135
134
  generateApi() {
@@ -386,17 +385,18 @@ export class Generator {
386
385
  getObjectName(ref) {
387
386
  return ref.replace('#/components/schemas/', '');
388
387
  }
389
- retrieveComponentProperties(swaggerCopmponent) {
390
- if (swaggerCopmponent.properties == null)
388
+ retrieveComponentProperties(swaggerComponent) {
389
+ if (swaggerComponent.properties == null)
391
390
  return [];
392
391
  let properties = [];
393
- for (let index = 0; index < Object.getOwnPropertyNames(swaggerCopmponent.properties).length; index++) {
394
- const propertyName = Object.getOwnPropertyNames(swaggerCopmponent.properties)[index];
395
- const type = this.retrieveType(swaggerCopmponent.properties[propertyName]);
392
+ for (let index = 0; index < Object.getOwnPropertyNames(swaggerComponent.properties).length; index++) {
393
+ const propertyName = Object.getOwnPropertyNames(swaggerComponent.properties)[index];
394
+ const required = swaggerComponent.required && swaggerComponent.required.includes(propertyName);
395
+ const type = this.retrieveType(swaggerComponent.properties[propertyName]);
396
396
  properties.push({
397
397
  ...type,
398
398
  name: propertyName,
399
- nullable: type.nullable,
399
+ nullable: required || type.nullable,
400
400
  });
401
401
  }
402
402
  return properties;
@@ -450,11 +450,12 @@ export class Generator {
450
450
  }
451
451
  if (nestedUsedType != '' && usedTypes.findIndex(x => x.typeName == nestedUsedType) == -1) {
452
452
  let nested = this._swagger.components.schemas[nestedUsedType];
453
+ const required = swaggerComponent.required && swaggerComponent.required.includes(propertyName);
453
454
  usedTypes.push({
454
455
  typeName: nestedUsedType,
455
456
  isTypeReference: nested.type == 'object',
456
457
  isNativeType: nested.type != 'object',
457
- nullable: false,
458
+ nullable: required,
458
459
  isArray: false,
459
460
  isVoid: false,
460
461
  //potrebbe essere un enum
@@ -478,11 +479,11 @@ export class Generator {
478
479
  }
479
480
  else {
480
481
  if (schema.type == 'integer')
481
- nativeType = 'number';
482
+ nativeType = 'integer'; //era number
482
483
  if (schema.type == 'string' && schema.format == null)
483
484
  nativeType = 'string';
484
485
  if (schema.type == 'string' && schema.format == 'date-time')
485
- nativeType = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date';
486
+ nativeType = 'dateTime';
486
487
  if (schema.type == 'string' && schema.format == 'uuid')
487
488
  nativeType = 'string';
488
489
  if (schema.type == 'string' && schema.format == 'binary')
@@ -23,7 +23,10 @@ ${this._properties(model)}${this._enumValues(model)}
23
23
  _properties(model) {
24
24
  let propertiesString = '';
25
25
  model.properties.forEach(property => {
26
- propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${property.typeName};\n`;
26
+ //const libraryDate = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date'
27
+ const libraryDate = 'moment.Moment';
28
+ const typeName = property.typeName === 'dateTime' ? libraryDate : property.typeName;
29
+ propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${typeName};\n`;
27
30
  });
28
31
  return propertiesString.trimEnd();
29
32
  }
@@ -14,6 +14,10 @@ export class ApiDartWriter {
14
14
  const __dirname = path.dirname(__filename);
15
15
  const templatePath = path.join(__dirname, 'templates', 'api.mustache');
16
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
+ }
17
21
  const grouped = this._groupByTag(apis);
18
22
  for (const [tag, apis] of Object.entries(grouped)) {
19
23
  console.log(`Api: ${tag}`);
@@ -45,6 +49,10 @@ export class ApiDartWriter {
45
49
  methodName = methodName.slice(tag.length);
46
50
  methodName = Utils.toFirstLetterLowercase(methodName);
47
51
  }
52
+ // console.debug(`\tAPI - ${apiName} - ${apiMethod}`);
53
+ if (methodName == "userGeneralInfoTestRead") {
54
+ debugger;
55
+ }
48
56
  const endpoint = {
49
57
  methodName: methodName,
50
58
  httpMethod: api.method.toLowerCase(),
@@ -61,7 +69,7 @@ export class ApiDartWriter {
61
69
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
62
70
  imports.push({
63
71
  type: api.parameters[0],
64
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
72
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
65
73
  });
66
74
  }
67
75
  });
@@ -74,7 +82,7 @@ export class ApiDartWriter {
74
82
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
75
83
  imports.push({
76
84
  type: api.returnType,
77
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
85
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
78
86
  });
79
87
  }
80
88
  });
@@ -14,6 +14,10 @@ export class ModelDartWriter {
14
14
  const __dirname = path.dirname(__filename);
15
15
  const templatePath = path.join(__dirname, 'templates', 'model.mustache');
16
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
+ }
17
21
  models.forEach(model => {
18
22
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
19
23
  const dartModel = {
@@ -26,9 +30,6 @@ export class ModelDartWriter {
26
30
  var imports = [];
27
31
  model.properties.forEach(property => {
28
32
  var fieldTypeName = this._mapTsTypeToDart(property.typeName);
29
- // if (fieldTypeName.endsWith('Exception')) {
30
- // debugger
31
- // }
32
33
  fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
33
34
  if (property.isTypeReference) {
34
35
  if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
@@ -37,7 +38,7 @@ export class ModelDartWriter {
37
38
  const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
38
39
  imports.push({
39
40
  type: property,
40
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
41
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
41
42
  });
42
43
  }
43
44
  });
@@ -102,8 +103,9 @@ export class ModelDartWriter {
102
103
  case "string":
103
104
  case "uuid":
104
105
  case "date":
105
- case "datetime":
106
106
  return "String";
107
+ case "dateTime":
108
+ return "DateTime";
107
109
  case "number":
108
110
  case "float":
109
111
  case "double":
@@ -22,7 +22,10 @@ ${this._properties(model)}${this._enumValues(model)}
22
22
  _properties(model) {
23
23
  let propertiesString = '';
24
24
  model.properties.forEach(property => {
25
- propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${property.typeName};\n`;
25
+ //const libraryDate = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date'
26
+ const libraryDate = 'Date';
27
+ const typeName = property.typeName === 'dateTime' ? libraryDate : property.typeName;
28
+ propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${typeName};\n`;
26
29
  });
27
30
  return propertiesString.trimEnd();
28
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devlearning/swagger-generator",
3
- "version": "1.0.18",
3
+ "version": "1.0.20",
4
4
  "description": "Swagger generator apis and models for Angular and NextJS",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/generator.ts CHANGED
@@ -74,8 +74,6 @@ export class Generator {
74
74
  const apiMethod = Object.getOwnPropertyNames(apiSwaggerMethodKey)[0];
75
75
  const apiSwaggerMethod = apiSwaggerMethodKey[apiMethod];
76
76
 
77
- // console.debug(`\tAPI - ${apiName} - ${apiMethod}`);
78
-
79
77
  let apiDto: ApiDto = {
80
78
  name: apiName,
81
79
  url: apiName.replace('{version}', '1'),
@@ -149,7 +147,6 @@ export class Generator {
149
147
 
150
148
  const swaggerComponent = this._swagger.components.schemas[modelName];
151
149
 
152
- // console.debug(`\tModel - ${modelName}`);
153
150
  this._models.push({
154
151
  typeName: modelName,
155
152
  modelType: swaggerComponent.type == 'integer' ? 'enum' : 'class',
@@ -166,13 +163,14 @@ export class Generator {
166
163
  const method = Object.getOwnPropertyNames(swaggerMethod)[0];
167
164
  const swaggerMethodInfo = swaggerMethod[method];
168
165
 
169
- this._models.push({
170
- typeName: this.getApiNameNormalized(apiName),
171
- modelType: 'class',
172
- name: this.getApiNameNormalized(apiName),
173
- properties: this.retrieveComponentProperties(swaggerMethodInfo.requestBody.content[contentTypeMultipartFormData].schema),
174
- enumValues: [],
175
- });
166
+ throw new Error(`MultiPart FormData is not supported yet for ${apiName} - ${method}.`);
167
+ // this._models.push({
168
+ // typeName: this.getApiNameNormalized(apiName),
169
+ // modelType: 'class',
170
+ // name: this.getApiNameNormalized(apiName),
171
+ // properties: this.retrieveComponentProperties(swaggerMethodInfo.requestBody.content[contentTypeMultipartFormData].schema),
172
+ // enumValues: [],
173
+ // });
176
174
  });
177
175
  }
178
176
 
@@ -446,18 +444,18 @@ export class Generator {
446
444
  return ref.replace('#/components/schemas/', '');
447
445
  }
448
446
 
449
- retrieveComponentProperties(swaggerCopmponent: SwaggerComponent | SwaggerSchema) {
450
- if (swaggerCopmponent.properties == null) return [];
447
+ retrieveComponentProperties(swaggerComponent: SwaggerComponent) {
448
+ if (swaggerComponent.properties == null) return [];
451
449
 
452
450
  let properties: PropertyDto[] = [];
453
- for (let index = 0; index < Object.getOwnPropertyNames(swaggerCopmponent.properties).length; index++) {
454
- const propertyName = Object.getOwnPropertyNames(swaggerCopmponent.properties)[index];
455
-
456
- const type = this.retrieveType(swaggerCopmponent.properties[propertyName]);
451
+ for (let index = 0; index < Object.getOwnPropertyNames(swaggerComponent.properties).length; index++) {
452
+ const propertyName = Object.getOwnPropertyNames(swaggerComponent.properties)[index];
453
+ const required = swaggerComponent.required && swaggerComponent.required.includes(propertyName);
454
+ const type = this.retrieveType(swaggerComponent.properties[propertyName]);
457
455
  properties.push({
458
456
  ...type,
459
457
  name: propertyName,
460
- nullable: type.nullable,
458
+ nullable: required || type.nullable,
461
459
  });
462
460
  }
463
461
 
@@ -512,7 +510,7 @@ export class Generator {
512
510
 
513
511
  if (swaggerComponent.properties[propertyName].$ref) {
514
512
  nestedUsedType = swaggerComponent.properties[propertyName].$ref!.replace('#/components/schemas/', '');
515
- }else if (swaggerComponent.properties[propertyName].allOf && swaggerComponent.properties[propertyName].allOf![0] && swaggerComponent.properties[propertyName].allOf![0]!.$ref) {
513
+ } else if (swaggerComponent.properties[propertyName].allOf && swaggerComponent.properties[propertyName].allOf![0] && swaggerComponent.properties[propertyName].allOf![0]!.$ref) {
516
514
  nestedUsedType = swaggerComponent.properties[propertyName].allOf![0]!.$ref!.replace('#/components/schemas/', ''); //TODO Assuming allOf contains a single $ref
517
515
  } else if (swaggerComponent.properties[propertyName].type == 'array' && swaggerComponent.properties[propertyName].items?.$ref) {
518
516
  nestedUsedType = swaggerComponent.properties[propertyName].items!.$ref!.replace('#/components/schemas/', '');
@@ -520,11 +518,12 @@ export class Generator {
520
518
 
521
519
  if (nestedUsedType != '' && usedTypes.findIndex(x => x.typeName == nestedUsedType) == -1) {
522
520
  let nested = this._swagger.components.schemas[nestedUsedType];
521
+ const required = swaggerComponent.required && swaggerComponent.required.includes(propertyName);
523
522
  usedTypes.push({
524
523
  typeName: nestedUsedType,
525
524
  isTypeReference: nested.type == 'object',
526
525
  isNativeType: nested.type != 'object',
527
- nullable: false,
526
+ nullable: required,
528
527
  isArray: false,
529
528
  isVoid: false,
530
529
  //potrebbe essere un enum
@@ -546,9 +545,9 @@ export class Generator {
546
545
  nativeType = this.getNativeType(schema.items);
547
546
  nativeType += '[]';
548
547
  } else {
549
- if (schema.type == 'integer') nativeType = 'number';
548
+ if (schema.type == 'integer') nativeType = 'integer'; //era number
550
549
  if (schema.type == 'string' && schema.format == null) nativeType = 'string';
551
- if (schema.type == 'string' && schema.format == 'date-time') nativeType = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date';
550
+ if (schema.type == 'string' && schema.format == 'date-time') nativeType = 'dateTime';
552
551
  if (schema.type == 'string' && schema.format == 'uuid') nativeType = 'string';
553
552
  if (schema.type == 'string' && schema.format == 'binary') nativeType = 'File';
554
553
  if (schema.type == 'number') nativeType = 'number';
@@ -34,7 +34,10 @@ ${this._properties(model)}${this._enumValues(model)}
34
34
  let propertiesString = '';
35
35
 
36
36
  model.properties.forEach(property => {
37
- propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${property.typeName};\n`;
37
+ //const libraryDate = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date'
38
+ const libraryDate = 'moment.Moment';
39
+ const typeName = property.typeName === 'dateTime' ? libraryDate : property.typeName;
40
+ propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${typeName};\n`;
38
41
  });
39
42
 
40
43
  return propertiesString.trimEnd();
@@ -45,6 +45,10 @@ export class ApiDartWriter {
45
45
  const __dirname = path.dirname(__filename);
46
46
  const templatePath = path.join(__dirname, 'templates', 'api.mustache');
47
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
+ }
48
52
 
49
53
  const grouped = this._groupByTag(apis);
50
54
 
@@ -86,6 +90,11 @@ export class ApiDartWriter {
86
90
  methodName = Utils.toFirstLetterLowercase(methodName);
87
91
  }
88
92
 
93
+ // console.debug(`\tAPI - ${apiName} - ${apiMethod}`);
94
+ if (methodName == "userGeneralInfoTestRead") {
95
+ debugger
96
+ }
97
+
89
98
  const endpoint = <EndpointDefinitionDart>{
90
99
  methodName: methodName,
91
100
  httpMethod: api.method.toLowerCase() as HttpMethodDart,
@@ -103,7 +112,7 @@ export class ApiDartWriter {
103
112
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
104
113
  imports.push({
105
114
  type: api.parameters[0],
106
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
115
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
107
116
  });
108
117
  }
109
118
  });
@@ -117,7 +126,7 @@ export class ApiDartWriter {
117
126
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
118
127
  imports.push({
119
128
  type: api.returnType!,
120
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
129
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
121
130
  });
122
131
  }
123
132
  });
@@ -42,6 +42,10 @@ export class ModelDartWriter {
42
42
  const __dirname = path.dirname(__filename);
43
43
  const templatePath = path.join(__dirname, 'templates', 'model.mustache');
44
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
+ }
45
49
 
46
50
  models.forEach(model => {
47
51
  const normalizedInfo = Normalizator.getNormalizedInfo(model);
@@ -58,10 +62,6 @@ export class ModelDartWriter {
58
62
  model.properties.forEach(property => {
59
63
  var fieldTypeName = this._mapTsTypeToDart(property.typeName);
60
64
 
61
- // if (fieldTypeName.endsWith('Exception')) {
62
- // debugger
63
- // }
64
-
65
65
  fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
66
66
 
67
67
  if (property.isTypeReference) {
@@ -71,7 +71,7 @@ export class ModelDartWriter {
71
71
  const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
72
72
  imports.push({
73
73
  type: property,
74
- import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
74
+ import: `import 'package:${this._commandLineArgs.package}/${importDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
75
75
  });
76
76
  }
77
77
  });
@@ -154,12 +154,13 @@ export class ModelDartWriter {
154
154
  case "string":
155
155
  case "uuid":
156
156
  case "date":
157
- case "datetime":
158
157
  return "String";
159
- case "number":
160
- case "float":
161
- case "double":
162
- return "double";
158
+ case "dateTime":
159
+ return "DateTime";
160
+ case "number":
161
+ case "float":
162
+ case "double":
163
+ return "double";
163
164
  case "integer":
164
165
  case "int":
165
166
  case "long":
@@ -33,7 +33,10 @@ ${this._properties(model)}${this._enumValues(model)}
33
33
  let propertiesString = '';
34
34
 
35
35
  model.properties.forEach(property => {
36
- propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${property.typeName};\n`;
36
+ //const libraryDate = this._commandLineArgs.dateTimeLibrary == DateTimeLibrary.Moment ? 'moment.Moment' : 'Date'
37
+ const libraryDate = 'Date';
38
+ const typeName = property.typeName === 'dateTime' ? libraryDate : property.typeName;
39
+ propertiesString += ` ${property.name}${property.nullable ? '?' : ''}: ${typeName};\n`;
37
40
  });
38
41
 
39
42
  return propertiesString.trimEnd();
@@ -14,4 +14,5 @@ export interface SwaggerComponent {
14
14
  properties: { [key: string]: SwaggerSchema; };
15
15
  additionalProperties: boolean;
16
16
  enum: string[];
17
+ required: string[];
17
18
  }
@@ -1,82 +0,0 @@
1
- import 'package:coqudo_app/core/di/injector.dart';
2
- import 'package:dio/dio.dart';
3
- import 'package:coqudo_app/autogen/identity/models/auth_app_authenticate_command.dart';
4
- import 'package:coqudo_app/autogen/identity/models/authentication_token.dart';
5
- import 'package:coqudo_app/autogen/identity/models/auth_user_authenticate_command.dart';
6
- import 'package:coqudo_app/autogen/identity/models/auth_refresh_token_command.dart';
7
- import 'package:coqudo_app/autogen/identity/models/auth_generate_reset_password_code_command.dart';
8
- import 'package:coqudo_app/autogen/service_defaults/models/result.dart';
9
- import 'package:coqudo_app/autogen/identity/models/auth_reset_password_command.dart';
10
- import 'package:coqudo_app/autogen/identity/models/auth_verify_reset_password_code_command.dart';
11
- import 'package:coqudo_app/autogen/identity/models/auth_activate_command.dart';
12
- import 'package:coqudo_app/autogen/identity/models/auth_user_dto.dart';
13
-
14
- class IdentityApi {
15
- final Dio _dio;
16
-
17
- IdentityApi() : _dio = getIt<Dio>();
18
-
19
- Future<AuthenticationToken> authAppToken(AuthAppAuthenticateCommand request) async {
20
- final response = await _dio.post(
21
- '/identity/auth/app/token',
22
- data: request.toJson(),
23
- );
24
- return AuthenticationToken.fromJson(response.data);
25
- }
26
-
27
- Future<AuthenticationToken> authUserToken(AuthUserAuthenticateCommand request) async {
28
- final response = await _dio.post(
29
- '/identity/auth/user/token',
30
- data: request.toJson(),
31
- );
32
- return AuthenticationToken.fromJson(response.data);
33
- }
34
-
35
- Future<AuthenticationToken> authRefreshToken(AuthRefreshTokenCommand request) async {
36
- final response = await _dio.post(
37
- '/identity/auth/refresh-token',
38
- data: request.toJson(),
39
- );
40
- return AuthenticationToken.fromJson(response.data);
41
- }
42
-
43
- Future<Result> authGenerateResetPasswordCode(AuthGenerateResetPasswordCodeCommand request) async {
44
- final response = await _dio.post(
45
- '/identity/auth/generate-reset-password-code',
46
- data: request.toJson(),
47
- );
48
- return Result.fromJson(response.data);
49
- }
50
-
51
- Future<Result> authResetPassword(AuthResetPasswordCommand request) async {
52
- final response = await _dio.post(
53
- '/identity/auth/reset-password',
54
- data: request.toJson(),
55
- );
56
- return Result.fromJson(response.data);
57
- }
58
-
59
- Future<Result> authVerifyResetPasswordCode(AuthVerifyResetPasswordCodeCommand request) async {
60
- final response = await _dio.post(
61
- '/identity/auth/verify-reset-password-code',
62
- data: request.toJson(),
63
- );
64
- return Result.fromJson(response.data);
65
- }
66
-
67
- Future<Result> authActivate(AuthActivateCommand request) async {
68
- final response = await _dio.post(
69
- '/identity/auth/activate',
70
- data: request.toJson(),
71
- );
72
- return Result.fromJson(response.data);
73
- }
74
-
75
- Future<AuthUserDto> authUserRead() async {
76
- final response = await _dio.get(
77
- '/identity/auth-user/read',
78
- );
79
- return AuthUserDto.fromJson(response.data);
80
- }
81
-
82
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_activate_command.freezed.dart';
4
- part 'auth_activate_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthActivateCommand with _$AuthActivateCommand {
8
- const factory AuthActivateCommand({
9
- required String username,
10
- required String activationCode,
11
- }) = _AuthActivateCommand;
12
-
13
- factory AuthActivateCommand.fromJson(Map<String, dynamic> json) => _$AuthActivateCommandFromJson(json);
14
- }
@@ -1,16 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_app_authenticate_command.freezed.dart';
4
- part 'auth_app_authenticate_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthAppAuthenticateCommand with _$AuthAppAuthenticateCommand {
8
- const factory AuthAppAuthenticateCommand({
9
- required String appId,
10
- required String secret,
11
- required String audience,
12
- String? ipAddress,
13
- }) = _AuthAppAuthenticateCommand;
14
-
15
- factory AuthAppAuthenticateCommand.fromJson(Map<String, dynamic> json) => _$AuthAppAuthenticateCommandFromJson(json);
16
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_generate_reset_password_code_command.freezed.dart';
4
- part 'auth_generate_reset_password_code_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthGenerateResetPasswordCodeCommand with _$AuthGenerateResetPasswordCodeCommand {
8
- const factory AuthGenerateResetPasswordCodeCommand({
9
- required String usernameOrEmail,
10
- required String host,
11
- required String urlResetPassword,
12
- }) = _AuthGenerateResetPasswordCodeCommand;
13
-
14
- factory AuthGenerateResetPasswordCodeCommand.fromJson(Map<String, dynamic> json) => _$AuthGenerateResetPasswordCodeCommandFromJson(json);
15
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_refresh_token_command.freezed.dart';
4
- part 'auth_refresh_token_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthRefreshTokenCommand with _$AuthRefreshTokenCommand {
8
- const factory AuthRefreshTokenCommand({
9
- required String uniqueName,
10
- required String refreshToken,
11
- String? ipAddress,
12
- }) = _AuthRefreshTokenCommand;
13
-
14
- factory AuthRefreshTokenCommand.fromJson(Map<String, dynamic> json) => _$AuthRefreshTokenCommandFromJson(json);
15
- }
@@ -1,16 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_reset_password_command.freezed.dart';
4
- part 'auth_reset_password_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthResetPasswordCommand with _$AuthResetPasswordCommand {
8
- const factory AuthResetPasswordCommand({
9
- required String usernameOrEmail,
10
- required String verificationCode,
11
- required String password,
12
- required String confirmPassword,
13
- }) = _AuthResetPasswordCommand;
14
-
15
- factory AuthResetPasswordCommand.fromJson(Map<String, dynamic> json) => _$AuthResetPasswordCommandFromJson(json);
16
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_user_authenticate_command.freezed.dart';
4
- part 'auth_user_authenticate_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthUserAuthenticateCommand with _$AuthUserAuthenticateCommand {
8
- const factory AuthUserAuthenticateCommand({
9
- required String username,
10
- required String password,
11
- String? ipAddress,
12
- }) = _AuthUserAuthenticateCommand;
13
-
14
- factory AuthUserAuthenticateCommand.fromJson(Map<String, dynamic> json) => _$AuthUserAuthenticateCommandFromJson(json);
15
- }
@@ -1,18 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_user_dto.freezed.dart';
4
- part 'auth_user_dto.g.dart';
5
-
6
- @freezed
7
- abstract class AuthUserDto with _$AuthUserDto {
8
- const factory AuthUserDto({
9
- required String idAuthUser,
10
- required String uniqueId,
11
- String? username,
12
- String? email,
13
- String? activationDate,
14
- String? lockedDate,
15
- }) = _AuthUserDto;
16
-
17
- factory AuthUserDto.fromJson(Map<String, dynamic> json) => _$AuthUserDtoFromJson(json);
18
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'auth_verify_reset_password_code_command.freezed.dart';
4
- part 'auth_verify_reset_password_code_command.g.dart';
5
-
6
- @freezed
7
- abstract class AuthVerifyResetPasswordCodeCommand with _$AuthVerifyResetPasswordCodeCommand {
8
- const factory AuthVerifyResetPasswordCodeCommand({
9
- String? usernameOrEmail,
10
- String? verificationCode,
11
- }) = _AuthVerifyResetPasswordCodeCommand;
12
-
13
- factory AuthVerifyResetPasswordCodeCommand.fromJson(Map<String, dynamic> json) => _$AuthVerifyResetPasswordCodeCommandFromJson(json);
14
- }
@@ -1,17 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'authentication_token.freezed.dart';
4
- part 'authentication_token.g.dart';
5
-
6
- @freezed
7
- abstract class AuthenticationToken with _$AuthenticationToken {
8
- const factory AuthenticationToken({
9
- required String uniqueName,
10
- required String accessToken,
11
- required double expiresIn,
12
- required String refreshToken,
13
- required double refreshTokenExpiresIn,
14
- }) = _AuthenticationToken;
15
-
16
- factory AuthenticationToken.fromJson(Map<String, dynamic> json) => _$AuthenticationTokenFromJson(json);
17
- }
@@ -1,17 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'problem_details.freezed.dart';
4
- part 'problem_details.g.dart';
5
-
6
- @freezed
7
- abstract class ProblemDetails with _$ProblemDetails {
8
- const factory ProblemDetails({
9
- String? type,
10
- String? title,
11
- double? status,
12
- String? detail,
13
- String? instance,
14
- }) = _ProblemDetails;
15
-
16
- factory ProblemDetails.fromJson(Map<String, dynamic> json) => _$ProblemDetailsFromJson(json);
17
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'application_exception.freezed.dart';
4
- part 'application_exception.g.dart';
5
-
6
- @freezed
7
- abstract class ApplicationException with _$ApplicationException {
8
- const factory ApplicationException({
9
- String? message,
10
- String? stackTrace,
11
- }) = _ApplicationException;
12
-
13
- factory ApplicationException.fromJson(Map<String, dynamic> json) => _$ApplicationExceptionFromJson(json);
14
- }
@@ -1,17 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- import 'package:coqudo_app/autogen/service_defaults/models/application_exception.dart';
3
-
4
- part 'result.freezed.dart';
5
- part 'result.g.dart';
6
-
7
- @freezed
8
- abstract class Result with _$Result {
9
- const factory Result({
10
- required bool isSuccess,
11
- String? message,
12
- String? stackTrace,
13
- ApplicationException? exception,
14
- }) = _Result;
15
-
16
- factory Result.fromJson(Map<String, dynamic> json) => _$ResultFromJson(json);
17
- }
@@ -1,46 +0,0 @@
1
- import 'package:coqudo_app/core/di/injector.dart';
2
- import 'package:dio/dio.dart';
3
- import 'package:coqudo_app/autogen/user_profile/models/test_read_query.dart';
4
- import 'package:coqudo_app/autogen/service_defaults/models/result.dart';
5
- import 'package:coqudo_app/autogen/user_profile/models/test_list_query.dart';
6
- import 'package:coqudo_app/autogen/user_profile/models/test_save_command.dart';
7
- import 'package:coqudo_app/autogen/user_profile/models/user_general_info_save_command.dart';
8
-
9
- class UserProfileApi {
10
- final Dio _dio;
11
-
12
- UserProfileApi() : _dio = getIt<Dio>();
13
-
14
- Future<Result> userGeneralInfoTestRead(TestReadQuery request) async {
15
- final response = await _dio.get(
16
- '/user-profile/UserGeneralInfo/test/read',
17
- queryParameters: request.toJson(),
18
- );
19
- return Result.fromJson(response.data);
20
- }
21
-
22
- Future<Result> userGeneralInfoTestList(TestListQuery request) async {
23
- final response = await _dio.get(
24
- '/user-profile/UserGeneralInfo/test/list',
25
- queryParameters: request.toJson(),
26
- );
27
- return Result.fromJson(response.data);
28
- }
29
-
30
- Future<Result> userGeneralInfoTestSave(TestSaveCommand request) async {
31
- final response = await _dio.post(
32
- '/user-profile/UserGeneralInfo/test/save',
33
- data: request.toJson(),
34
- );
35
- return Result.fromJson(response.data);
36
- }
37
-
38
- Future<Result> userGeneralInfoSave(UserGeneralInfoSaveCommand request) async {
39
- final response = await _dio.post(
40
- '/user-profile/UserGeneralInfo/save',
41
- data: request.toJson(),
42
- );
43
- return Result.fromJson(response.data);
44
- }
45
-
46
- }
@@ -1,13 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'test_list_query.freezed.dart';
4
- part 'test_list_query.g.dart';
5
-
6
- @freezed
7
- abstract class TestListQuery with _$TestListQuery {
8
- const factory TestListQuery({
9
- String? name,
10
- }) = _TestListQuery;
11
-
12
- factory TestListQuery.fromJson(Map<String, dynamic> json) => _$TestListQueryFromJson(json);
13
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'test_read_query.freezed.dart';
4
- part 'test_read_query.g.dart';
5
-
6
- @freezed
7
- abstract class TestReadQuery with _$TestReadQuery {
8
- const factory TestReadQuery({
9
- required String name,
10
- required String date,
11
- }) = _TestReadQuery;
12
-
13
- factory TestReadQuery.fromJson(Map<String, dynamic> json) => _$TestReadQueryFromJson(json);
14
- }
@@ -1,13 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'test_save_command.freezed.dart';
4
- part 'test_save_command.g.dart';
5
-
6
- @freezed
7
- abstract class TestSaveCommand with _$TestSaveCommand {
8
- const factory TestSaveCommand({
9
- required String name,
10
- }) = _TestSaveCommand;
11
-
12
- factory TestSaveCommand.fromJson(Map<String, dynamic> json) => _$TestSaveCommandFromJson(json);
13
- }
@@ -1,13 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'user_general_info_save_command.freezed.dart';
4
- part 'user_general_info_save_command.g.dart';
5
-
6
- @freezed
7
- abstract class UserGeneralInfoSaveCommand with _$UserGeneralInfoSaveCommand {
8
- const factory UserGeneralInfoSaveCommand({
9
- String? name,
10
- }) = _UserGeneralInfoSaveCommand;
11
-
12
- factory UserGeneralInfoSaveCommand.fromJson(Map<String, dynamic> json) => _$UserGeneralInfoSaveCommandFromJson(json);
13
- }