@devlearning/swagger-generator 1.0.11 → 1.0.13

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 (52) hide show
  1. package/.vscode/launch.json +6 -0
  2. package/README.md +4 -2
  3. package/autogen/identity/api/identity_api.dart +82 -0
  4. package/autogen/identity/models/auth_activate_command.dart +14 -0
  5. package/autogen/identity/models/auth_app_authenticate_command.dart +16 -0
  6. package/autogen/identity/models/auth_generate_reset_password_code_command.dart +15 -0
  7. package/autogen/identity/models/auth_refresh_token_command.dart +15 -0
  8. package/autogen/identity/models/auth_reset_password_command.dart +16 -0
  9. package/autogen/identity/models/auth_user_authenticate_command.dart +15 -0
  10. package/autogen/identity/models/auth_user_dto.dart +18 -0
  11. package/autogen/identity/models/auth_verify_reset_password_code_command.dart +14 -0
  12. package/autogen/identity/models/authentication_token.dart +17 -0
  13. package/autogen/mvc/models/problem_details.dart +17 -0
  14. package/autogen/service_defaults/models/application_exception.dart +14 -0
  15. package/autogen/service_defaults/models/result.dart +17 -0
  16. package/autogen/user_profile/api/user_profile_api.dart +46 -0
  17. package/autogen/user_profile/models/test_list_query.dart +13 -0
  18. package/autogen/user_profile/models/test_read_query.dart +13 -0
  19. package/autogen/user_profile/models/test_save_command.dart +13 -0
  20. package/autogen/user_profile/models/user_general_info_save_command.dart +13 -0
  21. package/dist/generator.js +63 -31
  22. package/dist/generators-writers/angular/api-angular-writer.js +1 -1
  23. package/dist/generators-writers/dart/api-dart-writer.js +110 -0
  24. package/dist/generators-writers/dart/model-dart-writer.js +124 -0
  25. package/dist/generators-writers/dart/models/import-definition-dart.js +1 -0
  26. package/dist/generators-writers/dart/normalizator.js +35 -0
  27. package/dist/generators-writers/nextjs/api-nextjs-writer.js +1 -1
  28. package/dist/generators-writers/utils.js +43 -2
  29. package/dist/index.js +72 -16
  30. package/dist/models/swagger/swagger-component-property.js +10 -0
  31. package/dist/models/swagger/swagger-component.js +1 -0
  32. package/dist/models/swagger/swagger-schema.js +1 -0
  33. package/package.json +11 -5
  34. package/src/generator.ts +67 -38
  35. package/src/generators-writers/angular/api-angular-writer.ts +1 -1
  36. package/src/generators-writers/dart/api-dart-writer.ts +164 -0
  37. package/src/generators-writers/dart/model-dart-writer.ts +176 -0
  38. package/src/generators-writers/dart/models/import-definition-dart.ts +6 -0
  39. package/src/generators-writers/dart/normalizator.ts +44 -0
  40. package/src/generators-writers/dart/templates/api.mustache +29 -0
  41. package/src/generators-writers/dart/templates/model.mustache +18 -0
  42. package/src/generators-writers/nextjs/api-nextjs-writer.ts +1 -1
  43. package/src/generators-writers/utils.ts +54 -2
  44. package/src/index.ts +80 -16
  45. package/src/models/api-dto.ts +1 -0
  46. package/src/models/model-dto.ts +1 -0
  47. package/src/models/swagger/swagger-component-property.ts +10 -9
  48. package/src/models/swagger/swagger-component.ts +11 -2
  49. package/src/models/swagger/swagger-schema.ts +18 -6
  50. package/src/models/swagger/swagger.ts +1 -0
  51. package/autogeneration/output/api.autogenerated.ts +0 -95
  52. package/autogeneration/output/model.autogenerated.ts +0 -69
@@ -0,0 +1,176 @@
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
+
9
+ interface ModelDefinitionDart {
10
+ modelName?: string;
11
+ fields?: { name: string; type: string }[];
12
+ imports?: string[];
13
+ }
14
+
15
+ interface FieldDefinitionDart {
16
+ name: string;
17
+ type: string;
18
+ typeName: string;
19
+ nullable: string;
20
+ required: string;
21
+ }
22
+
23
+ interface ExportModelDefinitionDart {
24
+ models: ExportModelItemDefinitionDart[];
25
+ }
26
+
27
+ interface ExportModelItemDefinitionDart {
28
+ filename?: string;
29
+ }
30
+
31
+ export class ModelDartWriter {
32
+ private _commandLineArgs: CommandLineArgs;
33
+
34
+ constructor(commandLineArgs: CommandLineArgs) {
35
+ this._commandLineArgs = commandLineArgs;
36
+ }
37
+
38
+ write(models: ModelDto[]) {
39
+ const template = readFileSync('src/generators-writers/dart/templates/model.mustache', 'utf-8');
40
+
41
+ models.forEach(model => {
42
+ const normalizedInfo = Normalizator.getNormalizedInfo(model);
43
+ const dartModel = <ModelDefinitionDart>{
44
+ filename: normalizedInfo.filename,
45
+ path: this._commandLineArgs.outputDirectory,
46
+ modelName: normalizedInfo.modelName,
47
+ fields: [],
48
+ imports: [],
49
+ };
50
+
51
+ var imports = <ImportDefinitionDart[]>[];
52
+
53
+ model.properties.forEach(property => {
54
+ var fieldTypeName = this._mapTsTypeToDart(property.typeName);
55
+
56
+ // if (fieldTypeName.endsWith('Exception')) {
57
+ // debugger
58
+ // }
59
+
60
+ fieldTypeName = Normalizator.getNormalizedTypeName(fieldTypeName);
61
+
62
+ if (property.isTypeReference) {
63
+ if (imports.findIndex(x => x.type.typeName == property.typeName) == -1) {
64
+ models.forEach(currModel => {
65
+ if (currModel.typeName === property.typeName) {
66
+ const normalizedInfo = Normalizator.getNormalizedInfo(currModel);
67
+ imports.push({
68
+ type: property,
69
+ import: `import 'package:${this._commandLineArgs.package}/${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}/${normalizedInfo.filename}.dart';`
70
+ });
71
+ }
72
+ });
73
+ }
74
+ }
75
+
76
+
77
+ dartModel.fields!.push(<FieldDefinitionDart>{
78
+ name: property.name,
79
+ type: fieldTypeName,
80
+ typeName: property.typeName,
81
+ nullable: property.nullable ? '?' : '',
82
+ required: property.nullable ? '' : 'required ',
83
+ });
84
+
85
+ });
86
+
87
+ dartModel.imports = imports.map(i => i.import);
88
+
89
+ let destinationPath = `${this._commandLineArgs.outputDirectory}/${normalizedInfo.subPath}`;
90
+
91
+ Utils.ensureDirectorySync(`${destinationPath}`);
92
+
93
+ let result = Mustache.default.render(template, dartModel);
94
+ writeFileSync(`${destinationPath}/${normalizedInfo.filename}.dart`, result, 'utf-8');
95
+ });
96
+
97
+ // var exportDataModels = <ExportModelItemDefinitionDart[]>[];
98
+ // models.forEach(model => {
99
+ // exportDataModels.push({
100
+ // filename: `${model.filename}.dart`
101
+ // });
102
+ // });
103
+
104
+ // var exportData = <ExportModelDefinitionDart>{
105
+ // models: exportDataModels
106
+ // };
107
+ // const exportTemplate = readFileSync('src/generators-writers/dart/templates/model.export.mustache', 'utf-8');
108
+ // const exportContent = Mustache.default.render(exportTemplate, exportData);
109
+ // writeFileSync(`${this._commandLineArgs.outputDirectory}/_export_models.dart`, exportContent, 'utf-8');
110
+
111
+ // const model = [
112
+ // {
113
+ // filename: 'login_request',
114
+ // modelName: 'LoginRequest',
115
+ // fields: [
116
+ // { name: 'email', type: 'String' },
117
+ // { name: 'password', type: 'String' }
118
+ // ]
119
+ // },
120
+ // {
121
+ // filename: 'login_response',
122
+ // modelName: 'LoginResponse',
123
+ // fields: [
124
+ // { name: 'token', type: 'String' }
125
+ // ]
126
+ // }
127
+ // ];
128
+
129
+
130
+ // let modelString = '';
131
+
132
+ // models.forEach(model => {
133
+ // modelString += this._modelString(model);
134
+ // });
135
+
136
+
137
+ // this._writeFile(modelString);
138
+ }
139
+
140
+ private _mapTsTypeToDart(type: string): string {
141
+ const normalized = type.trim().toLowerCase();
142
+
143
+ if (normalized.endsWith("[]")) {
144
+ const inner = normalized.slice(0, -2).trim();
145
+ return `List<${this._mapTsTypeToDart(inner)}>`;
146
+ }
147
+
148
+ switch (normalized) {
149
+ case "string":
150
+ case "uuid":
151
+ case "date":
152
+ case "datetime":
153
+ return "String";
154
+ case "number":
155
+ case "float":
156
+ case "double":
157
+ return "double";
158
+ case "integer":
159
+ case "int":
160
+ case "long":
161
+ return "int";
162
+ case "boolean":
163
+ case "bool":
164
+ return "bool";
165
+ case "any":
166
+ case "object":
167
+ return "dynamic";
168
+ case "null":
169
+ case "undefined":
170
+ return "Null";
171
+ default:
172
+ // per tipi personalizzati (es. modelli) restituisci con PascalCase
173
+ return Utils.toPascalCase(type);
174
+ }
175
+ }
176
+ }
@@ -0,0 +1,6 @@
1
+ import { TypeDto } from "@src/models/type-dto.js";
2
+
3
+ export interface ImportDefinitionDart {
4
+ type: TypeDto;
5
+ import: string
6
+ }
@@ -0,0 +1,44 @@
1
+ import { ModelDto } from "@src/models/model-dto.js";
2
+ import { Utils } from "../utils.js";
3
+
4
+ export class Normalizator {
5
+
6
+ // public static normalizeModelName(modelName: string): string {
7
+ // let normalizeModelName = modelName.split('.').pop()!;
8
+ // return Utils.toDartClassName(filename) ?? filename;
9
+ // }
10
+
11
+
12
+ // subPath = model.name.split('.').slice(0, -1).join('');
13
+ // subPath = `${Utils.toDartFileName(subPath)}/models`;
14
+
15
+ public static getNormalizedInfo(model: ModelDto) {
16
+ let subPath = '';
17
+ let filename = '';
18
+ let modelName = '';
19
+
20
+ if (model.name && model.name.includes('.')) {
21
+ subPath = model.name.split('.').slice(0, -1).join('');
22
+ subPath = `${Utils.toDartFileName(subPath)}/models`;
23
+ filename = model.name.split('.').pop()!;
24
+ modelName = Utils.toDartClassName(filename) ?? filename;
25
+ filename = Utils.toDartFileName(filename!);
26
+ } else {
27
+ subPath = '';
28
+ filename = Utils.toDartFileName(model.name);
29
+ modelName = Utils.toDartClassName(model.name) ?? model.name;
30
+ }
31
+
32
+ return {
33
+ filename: filename,
34
+ subPath: subPath,
35
+ modelName: modelName,
36
+ }
37
+ }
38
+
39
+ public static getNormalizedTypeName(typeName: string): string {
40
+ let formattedTypeName = typeName.split('.').pop()!;
41
+ return Utils.toDartClassName(formattedTypeName) ?? typeName;
42
+ }
43
+
44
+ }
@@ -0,0 +1,29 @@
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}}({{#haveRequest}}{{requestType}} request{{/haveRequest}}) async {
14
+ final response = await _dio.{{httpMethod}}(
15
+ '{{{path}}}',
16
+ {{#haveRequest}}
17
+ {{#isGet}}
18
+ queryParameters: request.toJson(),
19
+ {{/isGet}}
20
+ {{^isGet}}
21
+ data: request.toJson(),
22
+ {{/isGet}}
23
+ {{/haveRequest}}
24
+ );
25
+ return {{responseType}}.fromJson(response.data);
26
+ }
27
+
28
+ {{/endpoints}}
29
+ }
@@ -0,0 +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
+ }
@@ -24,7 +24,7 @@ export class ApiNextJsWriter {
24
24
 
25
25
  private _apiString(api: ApiDto) {
26
26
 
27
- let apiNameNormalized = Utils.toCamelCase(Utils.getApiNameNormalized(api.name));
27
+ let apiNameNormalized = Utils.toCamelCase(Utils.getNormalizedApiPath(api.name));
28
28
  let parametersString = this._parameters(api);
29
29
  let queryParametersPreparation = this._queryParametersPreparation(api);
30
30
  let requestPreparation = this._requestPreparation(api);
@@ -1,14 +1,25 @@
1
1
  import { SwaggerSchema } from "@src/models/swagger/swagger-schema.js";
2
+ import fs from 'fs';
3
+ import path from 'path';
2
4
 
3
5
  export class Utils {
4
6
 
5
- public static getApiNameNormalized(apiName: string) {
7
+ public static getNormalizedApiPath(apiName: string) {
6
8
  let normalizedApiName = apiName.replace('/api/v{version}/', '').replaceAll('/', '_');
7
9
 
8
10
  if (normalizedApiName.charAt(0) == '_') {
9
11
  normalizedApiName = normalizedApiName.slice(1);
10
12
  }
11
- return this.toFirstLetterLowercase(normalizedApiName);
13
+
14
+ normalizedApiName = normalizedApiName.replace(/-([a-zA-Z])/g, (_, char) => char.toUpperCase());
15
+
16
+ normalizedApiName = this.toCamelCase(normalizedApiName);
17
+
18
+ normalizedApiName = this.toFirstLetterLowercase(normalizedApiName);
19
+
20
+ normalizedApiName = normalizedApiName.replaceAll('_', '');
21
+
22
+ return normalizedApiName;
12
23
  }
13
24
 
14
25
  public static toFirstLetterLowercase(value: string) {
@@ -19,9 +30,50 @@ export class Utils {
19
30
  return input.replace(/_([a-zA-Z])/g, (_, letter) => letter.toUpperCase());
20
31
  }
21
32
 
33
+ public static toPascalCase(input: string): string {
34
+ return input
35
+ .replace(/[_\-\s]+(.)?/g, (_, c) => (c ? c.toUpperCase() : ""))
36
+ .replace(/^(.)/, (_, c) => c.toUpperCase());
37
+ }
38
+
22
39
  public static isDate(schema?: SwaggerSchema) {
23
40
  if (!schema) return false;
24
41
 
25
42
  return schema.type == 'string' && schema.format == 'date-time';
26
43
  }
44
+
45
+ public static toDartFileName(name: string): string {
46
+ return name
47
+ .replace(/\./g, '_') // sostituisce i punti con underscore
48
+ .replace(/([a-z0-9])([A-Z])/g, '$1_$2') // aggiunge _ tra camelCase
49
+ .toLowerCase();
50
+ }
51
+
52
+ public static toDartClassName(name: string): string | undefined {
53
+ if (!name) return undefined;
54
+
55
+ return name.replace(/\./g, ''); // rimuove i punti per ottenere PascalCase
56
+ }
57
+
58
+ public static async ensureDirectorySync(dirPath: string) {
59
+ if (!fs.existsSync(dirPath)) {
60
+ fs.mkdirSync(dirPath, { recursive: true });
61
+ }
62
+ }
63
+
64
+ public static async clearDirectory(dirPath: string) {
65
+ if (!fs.existsSync(dirPath)) return;
66
+
67
+ for (const file of fs.readdirSync(dirPath)) {
68
+ const fullPath = path.join(dirPath, file);
69
+ const stat = fs.statSync(fullPath);
70
+
71
+ if (stat.isDirectory()) {
72
+ fs.rmSync(fullPath, { recursive: true, force: true });
73
+ } else {
74
+ fs.unlinkSync(fullPath);
75
+ }
76
+ }
77
+ }
78
+
27
79
  }
package/src/index.ts CHANGED
@@ -1,33 +1,97 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ import yargs from 'yargs';
4
+ import { hideBin } from 'yargs/helpers';
3
5
  import { Generator } from './generator.js';
4
6
  import { SwaggerDownloader } from './swagger-downloader.js';
5
7
 
6
- var args = process.argv.slice(2);
8
+ export enum DateTimeLibrary {
9
+ Moment = 'moment',
10
+ DateFns = 'date-fn',
11
+ }
7
12
 
8
- if (args.length !== 4) {
9
- console.log("Warning: Requires 3 arguments");
10
- console.log("node index.js [swaggerJsonUrl] [outputDirectory] [angular|next] [moment|date-fns]");
11
- process.exit();
13
+ export enum TargetGeneration {
14
+ Angular = 'angular',
15
+ Next = 'next',
16
+ Dart = 'dart',
12
17
  }
13
18
 
14
- const swaggerJsonUrl = args[0];
15
- const outputDirectory = args[1];
16
- const outputFormat = args[2] == 'next' ? 'next' : 'angular';
17
- const dateLib = args[3] == 'moment' ? 'moment' : 'date-fns';
19
+ export interface CommandLineArgs {
20
+ swaggerJsonUrl: string;
21
+ outputDirectory: string;
22
+ target: TargetGeneration;
23
+ dateTimeLibrary?: DateTimeLibrary;
24
+ package?: string;
25
+ }
18
26
 
19
- //const excludedModels = ['Type', 'MethodBase', 'Assembly', 'MethodInfo']
20
- // const apiUrl = args[0]//"http://localhost:5208";
21
- // const version = args[1]; //"1";
22
- // const swaggerJsonUrl = `${apiUrl}/swagger/v${version}/swagger.json`;
27
+ const argv = yargs(hideBin(process.argv))
28
+ .scriptName("swagger-gen")
29
+ .usage('Usage: $0 --url <swaggerJsonUrl> --output <outputDirectory> --target <target> [--dateTimeLibrary <dateTimeLibrary>] [--package <name>]')
30
+ .option('url', {
31
+ alias: 'u',
32
+ type: 'string',
33
+ demandOption: true,
34
+ describe: 'URL of swagger.json file',
35
+ })
36
+ .option('output', {
37
+ alias: 'o',
38
+ type: 'string',
39
+ demandOption: true,
40
+ describe: 'Output directory for generated code',
41
+ })
42
+ .option('target', {
43
+ alias: 't',
44
+ type: 'string',
45
+ choices: ['angular', 'next', 'dart'],
46
+ demandOption: true,
47
+ describe: 'Target format for the generated code',
48
+ })
49
+ .option('dateTimeLibrary', {
50
+ alias: 'd',
51
+ type: 'string',
52
+ choices: ['moment', 'date-fns'],
53
+ default: 'date-fns',
54
+ describe: 'Date library to use for date handling',
55
+ })
56
+ .option('package', {
57
+ alias: 'p',
58
+ type: 'string',
59
+ describe: 'For Dart: package name for Dart project',
60
+ })
61
+ .help()
62
+ .parseSync();
63
+
64
+ const commandLineArgs: CommandLineArgs = {
65
+ swaggerJsonUrl: argv.url,
66
+ outputDirectory: argv.output,
67
+ target: parseTargetGeneration(argv.target),
68
+ dateTimeLibrary: parseDateTimeLibrary(argv.dateTimeLibrary),
69
+ package: argv.package ?? '',
70
+ };
23
71
 
24
72
  const swaggerDownloader = new SwaggerDownloader();
25
73
 
26
- swaggerDownloader.download(new URL(swaggerJsonUrl))
74
+ swaggerDownloader.download(new URL(commandLineArgs.swaggerJsonUrl))
27
75
  .then(swaggerDoc => {
28
- return new Generator(swaggerDoc, outputDirectory, outputFormat, dateLib);
76
+ return new Generator(swaggerDoc, commandLineArgs);
29
77
  })
30
78
  .then(generator => { generator.generate(); });
31
79
 
32
80
 
33
- // require('./index.js')({swaggerDownloader});
81
+ // require('./index.js')({swaggerDownloader});
82
+
83
+ function parseDateTimeLibrary(value: string): DateTimeLibrary | undefined {
84
+ const values = Object.values(DateTimeLibrary);
85
+ if (values.includes(value as DateTimeLibrary)) {
86
+ return value as DateTimeLibrary;
87
+ }
88
+ return undefined;
89
+ }
90
+
91
+ function parseTargetGeneration(value: string): TargetGeneration {
92
+ const values = Object.values(TargetGeneration);
93
+ if (values.includes(value as TargetGeneration)) {
94
+ return value as TargetGeneration;
95
+ }
96
+ throw new Error(`Invalid OutputFormat: ${value}`);
97
+ }
@@ -11,6 +11,7 @@ export interface ApiDto {
11
11
  returnType: TypeDto | undefined;
12
12
  haveRequest: boolean;
13
13
  isMultiPart: boolean;
14
+ tag: string;
14
15
 
15
16
  swaggerMethodKey: { [key: string]: SwaggerMethod; };
16
17
  swaggerMethod: SwaggerMethod;
@@ -2,6 +2,7 @@ import { EnumValueDto } from "./enum-value-dto.js";
2
2
  import { PropertyDto } from "./property-dto.js";
3
3
 
4
4
  export interface ModelDto {
5
+ typeName: string;
5
6
  modelType: 'enum' | 'interface' | 'class';
6
7
  name: string;
7
8
  properties: PropertyDto[];
@@ -1,11 +1,12 @@
1
1
  import { SwaggerSchema } from "./swagger-schema.js";
2
2
 
3
- export interface SwaggerComponentProperty {
4
- type: string;
5
- $ref: string;
6
- format: string;
7
- items: SwaggerSchema;
8
- properties: { [key: string]: SwaggerComponentProperty; };
9
- nullable: boolean;
10
- minLength: number;
11
- }
3
+ // export interface SwaggerComponentProperty {
4
+ // type: string;
5
+ // $ref: string;
6
+ // allOf: SwaggerComponentProperty[];
7
+ // format: string;
8
+ // items: SwaggerSchema;
9
+ // properties: { [key: string]: SwaggerComponentProperty; };
10
+ // nullable: boolean;
11
+ // minLength: number;
12
+ // }
@@ -1,8 +1,17 @@
1
- import { SwaggerComponentProperty } from "./swagger-component-property.js";
1
+ // import { SwaggerComponentProperty } from "./swagger-component-property.js";
2
+
3
+ import { SwaggerSchema } from "./swagger-schema.js";
4
+
5
+ // export interface SwaggerComponent {
6
+ // type: string;
7
+ // properties: { [key: string]: SwaggerComponentProperty; };
8
+ // additionalProperties: boolean;
9
+ // enum: string[];
10
+ // }
2
11
 
3
12
  export interface SwaggerComponent {
4
13
  type: string;
5
- properties: { [key: string]: SwaggerComponentProperty; };
14
+ properties: { [key: string]: SwaggerSchema; };
6
15
  additionalProperties: boolean;
7
16
  enum: string[];
8
17
  }
@@ -1,9 +1,21 @@
1
- import { SwaggerComponentProperty } from "./swagger-component-property.js";
1
+ // import { SwaggerComponentProperty } from "./swagger-component-property.js";
2
+
3
+ // export interface SwaggerSchema {
4
+ // type: string;
5
+ // $ref: string;
6
+ // allOf: SwaggerSchema[];
7
+ // format: string;
8
+ // items: SwaggerSchema;
9
+ // properties: { [key: string]: SwaggerComponentProperty; };
10
+ // }
2
11
 
3
12
  export interface SwaggerSchema {
4
- type: string;
5
- $ref: string;
6
- format: string;
7
- items: SwaggerSchema;
8
- properties: { [key: string]: SwaggerComponentProperty; };
13
+ type?: string;
14
+ $ref?: string;
15
+ allOf?: SwaggerSchema[];
16
+ format?: string;
17
+ items?: SwaggerSchema;
18
+ properties?: { [key: string]: SwaggerSchema };
19
+ nullable?: boolean;
20
+ minLength?: number;
9
21
  }
@@ -21,6 +21,7 @@ export interface SwaggerParameter {
21
21
  export interface SwaggerRequestBody {
22
22
  content: { [key: string]: SwaggerContent; };
23
23
  encoding : SwaggerEncoding;
24
+ required?: boolean;
24
25
  }
25
26
 
26
27
  export interface SwaggerResponses {
@@ -1,95 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { Observable, catchError, map } from 'rxjs';
3
- import * as Models from './model.autogenerated';
4
- import { HttpHeaders } from "@angular/common/http";
5
-
6
- export const httpOptions = {
7
- headers: new HttpHeaders({ 'Content-Type': 'application/json' }),
8
- };
9
-
10
- export const httpOptionsMultipart = {};
11
-
12
- export abstract class ApiAutogeneratedService {
13
- constructor(
14
- public _http: HttpClient,
15
- public _baseUrl: string,
16
- ) { }
17
-
18
- protected abstract _momentToString(moment: moment.Moment): string;
19
- protected abstract _handleRequest<T>(request: T): T;
20
- protected abstract _handleMultipart<T>(request: T): FormData;
21
- protected abstract _handleResponse<T>(response: T): T;
22
- protected abstract _handleError(error: any, obs: any): Observable<never>;
23
-
24
-
25
- public catalog_Product_Read(idProduct?: number): Observable<Models.Product> {
26
- let idProductParam: string = idProduct != null && idProduct != undefined ? encodeURIComponent('' + idProduct) : '';
27
- return this._http.get<Models.Product>(`${this._baseUrl}/catalog/Product/Read?idProduct=${idProductParam}`, httpOptions)
28
- .pipe(
29
- map(x => this._handleResponse(x)),
30
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
31
- );
32
- }
33
-
34
- public catalog_Product_List(): Observable<Models.Product[]> {
35
- return this._http.get<Models.Product[]>(`${this._baseUrl}/catalog/Product/List`, httpOptions)
36
- .pipe(
37
- map(x => this._handleResponse(x)),
38
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
39
- );
40
- }
41
-
42
- public identiy_token(request: Models.AuthTokenCommand): Observable<Models.AuthenticationToken> {
43
- let wrappedRequest = this._handleRequest(request);
44
- return this._http.post<Models.AuthenticationToken>(`${this._baseUrl}/identiy/token`, wrappedRequest, httpOptions)
45
- .pipe(
46
- map(x => this._handleResponse(x)),
47
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
48
- );
49
- }
50
-
51
- public identiy_refreshToken(request: Models.AuthRefreshTokenCommand): Observable<Models.AuthenticationToken> {
52
- let wrappedRequest = this._handleRequest(request);
53
- return this._http.post<Models.AuthenticationToken>(`${this._baseUrl}/identiy/refreshToken`, wrappedRequest, httpOptions)
54
- .pipe(
55
- map(x => this._handleResponse(x)),
56
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
57
- );
58
- }
59
-
60
- public identiy_generateResetPasswordCode(request: Models.AuthGenerateResetPasswordCodeCommand): Observable<Models.Result> {
61
- let wrappedRequest = this._handleRequest(request);
62
- return this._http.post<Models.Result>(`${this._baseUrl}/identiy/generateResetPasswordCode`, wrappedRequest, httpOptions)
63
- .pipe(
64
- map(x => this._handleResponse(x)),
65
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
66
- );
67
- }
68
-
69
- public identiy_resetPassword(request: Models.AuthResetPasswordCommand): Observable<Models.Result> {
70
- let wrappedRequest = this._handleRequest(request);
71
- return this._http.post<Models.Result>(`${this._baseUrl}/identiy/resetPassword`, wrappedRequest, httpOptions)
72
- .pipe(
73
- map(x => this._handleResponse(x)),
74
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
75
- );
76
- }
77
-
78
- public identiy_verifyResetPasswordCode(request: Models.AuthVerifyResetPasswordCodeCommand): Observable<Models.Result> {
79
- let wrappedRequest = this._handleRequest(request);
80
- return this._http.post<Models.Result>(`${this._baseUrl}/identiy/verifyResetPasswordCode`, wrappedRequest, httpOptions)
81
- .pipe(
82
- map(x => this._handleResponse(x)),
83
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
84
- );
85
- }
86
-
87
- public tenant_Tenant(): Observable<string> {
88
- return this._http.get<string>(`${this._baseUrl}/tenant/Tenant`, httpOptions)
89
- .pipe(
90
- map(x => this._handleResponse(x)),
91
- catchError((err, obs) => this._handleError(err, <Observable<any>>obs))
92
- );
93
- }
94
-
95
- }