@devlearning/swagger-generator 1.1.5 → 1.1.7
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.
- package/dist/generators-writers/angular/api-angular-writer.js +2 -1
- package/dist/generators-writers/angular/constants.d.ts +1 -1
- package/dist/generators-writers/angular/constants.js +1 -1
- package/dist/models/swagger-component-property.js +1 -0
- package/dist/models/swagger-component.js +1 -0
- package/dist/models/swagger-content.js +1 -0
- package/dist/models/swagger-info.js +1 -0
- package/dist/models/swagger-method.js +1 -0
- package/dist/models/swagger-schema.js +1 -0
- package/dist/models/swagger.js +1 -0
- package/package.json +1 -1
- package/src/generators-writers/angular/api-angular-writer.ts +3 -1
- package/src/generators-writers/angular/constants.ts +1 -1
- package/dist/templates/api.mustache +0 -29
- package/dist/templates/model.mustache +0 -18
|
@@ -29,7 +29,7 @@ export class ApiAngularWriter {
|
|
|
29
29
|
${queryParametersPreparation}${requestPreparation}return this._http.${method}<${returnTypeString}>(\`\${this._baseUrl}${api.url}${queryParameters}\`${haveRequest ? ', wrappedRequest' : ''}, ${httpOptions})
|
|
30
30
|
.pipe(
|
|
31
31
|
map(x => this._handleResponse(x)),
|
|
32
|
-
catchError((err, obs) => this._handleError(err,
|
|
32
|
+
catchError((err, obs) => this._handleError(err, obs, skipErrorHandling))
|
|
33
33
|
);
|
|
34
34
|
}
|
|
35
35
|
`;
|
|
@@ -43,6 +43,7 @@ export class ApiAngularWriter {
|
|
|
43
43
|
const typeName = parameter.typeName === 'dateTime' ? libraryDate : `${prefixType}${Normalizator.mapTsTypeToAngular(parameter.typeName)}`;
|
|
44
44
|
parametersString += `${parameter.name}${parameter.nullable ? '?' : ''}: ${typeName}, `;
|
|
45
45
|
});
|
|
46
|
+
parametersString += 'skipErrorHandling: boolean = false, ';
|
|
46
47
|
if (api.parameters.length > 0)
|
|
47
48
|
parametersString = parametersString.substring(0, parametersString.length - 2);
|
|
48
49
|
return parametersString;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const API_PRE = "import { HttpClient } from '@angular/common/http';\nimport { Observable, catchError, map } from 'rxjs';\nimport * as Models from './model.autogenerated';\nimport { HttpHeaders } from \"@angular/common/http\";\n\nexport const httpOptions = {\n headers: new HttpHeaders({ 'Content-Type': 'application/json' }),\n};\n\nexport const httpOptionsMultipart = {};\n\nexport abstract class ApiAutogeneratedService {\n constructor(\n public _http: HttpClient,\n public _baseUrl: string,\n ) { }\n\n protected abstract _momentToString(moment: moment.Moment): string;\n protected abstract _handleRequest<T>(request: T): T;\n protected abstract _handleMultipart<T>(request: T): FormData;\n protected abstract _handleResponse<T>(response: T): T;\n protected abstract _handleError(error: any, obs:
|
|
1
|
+
export declare const API_PRE = "import { HttpClient } from '@angular/common/http';\nimport { Observable, catchError, map } from 'rxjs';\nimport * as Models from './model.autogenerated';\nimport { HttpHeaders } from \"@angular/common/http\";\n\nexport const httpOptions = {\n headers: new HttpHeaders({ 'Content-Type': 'application/json' }),\n};\n\nexport const httpOptionsMultipart = {};\n\nexport abstract class ApiAutogeneratedService {\n constructor(\n public _http: HttpClient,\n public _baseUrl: string,\n ) { }\n\n protected abstract _momentToString(moment: moment.Moment): string;\n protected abstract _handleRequest<T>(request: T): T;\n protected abstract _handleMultipart<T>(request: T): FormData;\n protected abstract _handleResponse<T>(response: T): T;\n protected abstract _handleError<T>(error: any, obs: Observable<T>, skipErrorHandling: boolean): Observable<never>;\n";
|
|
2
2
|
export declare const API_POST = "}";
|
|
3
3
|
export declare const MODEL_PRE = "import * as moment from 'moment';\n ";
|
|
4
4
|
export declare const MODEL_POST = "\n";
|
|
@@ -19,7 +19,7 @@ export abstract class ApiAutogeneratedService {
|
|
|
19
19
|
protected abstract _handleRequest<T>(request: T): T;
|
|
20
20
|
protected abstract _handleMultipart<T>(request: T): FormData;
|
|
21
21
|
protected abstract _handleResponse<T>(response: T): T;
|
|
22
|
-
protected abstract _handleError(error: any, obs:
|
|
22
|
+
protected abstract _handleError<T>(error: any, obs: Observable<T>, skipErrorHandling: boolean): Observable<never>;
|
|
23
23
|
`;
|
|
24
24
|
export const API_POST = `}`;
|
|
25
25
|
export const MODEL_PRE = `import * as moment from 'moment';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -41,7 +41,7 @@ export class ApiAngularWriter {
|
|
|
41
41
|
${queryParametersPreparation}${requestPreparation}return this._http.${method}<${returnTypeString}>(\`\${this._baseUrl}${api.url}${queryParameters}\`${haveRequest ? ', wrappedRequest' : ''}, ${httpOptions})
|
|
42
42
|
.pipe(
|
|
43
43
|
map(x => this._handleResponse(x)),
|
|
44
|
-
catchError((err, obs) => this._handleError(err,
|
|
44
|
+
catchError((err, obs) => this._handleError(err, obs, skipErrorHandling))
|
|
45
45
|
);
|
|
46
46
|
}
|
|
47
47
|
`;
|
|
@@ -60,6 +60,8 @@ export class ApiAngularWriter {
|
|
|
60
60
|
parametersString += `${parameter.name}${parameter.nullable ? '?' : ''}: ${typeName}, `;
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
parametersString += 'skipErrorHandling: boolean = false, ';
|
|
64
|
+
|
|
63
65
|
if (api.parameters.length > 0)
|
|
64
66
|
parametersString = parametersString.substring(0, parametersString.length - 2);
|
|
65
67
|
|
|
@@ -20,7 +20,7 @@ export abstract class ApiAutogeneratedService {
|
|
|
20
20
|
protected abstract _handleRequest<T>(request: T): T;
|
|
21
21
|
protected abstract _handleMultipart<T>(request: T): FormData;
|
|
22
22
|
protected abstract _handleResponse<T>(response: T): T;
|
|
23
|
-
protected abstract _handleError(error: any, obs:
|
|
23
|
+
protected abstract _handleError<T>(error: any, obs: Observable<T>, skipErrorHandling: boolean): Observable<never>;
|
|
24
24
|
`;
|
|
25
25
|
|
|
26
26
|
export const API_POST =
|
|
@@ -1,29 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
-
}
|