@devlearning/swagger-generator 1.0.25 → 1.0.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/.vscode/launch.json +28 -22
  2. package/README.md +209 -209
  3. package/dist/api.constants.js +22 -22
  4. package/dist/generators-writers/angular/api-angular-writer.js +15 -15
  5. package/dist/generators-writers/angular/constants.js +24 -24
  6. package/dist/generators-writers/angular/model-angular-writer.js +6 -6
  7. package/dist/generators-writers/nextjs/api-nextjs-writer.js +12 -12
  8. package/dist/generators-writers/nextjs/constants.js +4 -4
  9. package/dist/generators-writers/nextjs/model-nextjs-writer.js +6 -6
  10. package/dist/models/swagger-component-property.js +1 -0
  11. package/dist/models/swagger-component.js +1 -0
  12. package/dist/models/swagger-content.js +1 -0
  13. package/dist/models/swagger-info.js +1 -0
  14. package/dist/models/swagger-method.js +1 -0
  15. package/dist/models/swagger-schema.js +1 -0
  16. package/dist/models/swagger.js +1 -0
  17. package/package.json +45 -45
  18. package/src/api.constants.ts +26 -26
  19. package/src/generator-old.ts +449 -449
  20. package/src/generator.ts +582 -582
  21. package/src/generators-writers/angular/api-angular-writer.ts +141 -141
  22. package/src/generators-writers/angular/constants.ts +36 -36
  23. package/src/generators-writers/angular/model-angular-writer.ts +62 -62
  24. package/src/generators-writers/dart/api-dart-writer.ts +190 -190
  25. package/src/generators-writers/dart/model-dart-writer.ts +162 -162
  26. package/src/generators-writers/dart/models/import-definition-dart.ts +5 -5
  27. package/src/generators-writers/dart/normalizator.ts +72 -72
  28. package/src/generators-writers/dart/templates/api.mustache +36 -36
  29. package/src/generators-writers/dart/templates/enum.mustache +14 -13
  30. package/src/generators-writers/dart/templates/model.mustache +17 -17
  31. package/src/generators-writers/nextjs/api-nextjs-writer.ts +156 -156
  32. package/src/generators-writers/nextjs/constants.ts +5 -5
  33. package/src/generators-writers/nextjs/model-nextjs-writer.ts +61 -61
  34. package/src/generators-writers/utils.ts +78 -78
  35. package/src/index.ts +96 -96
  36. package/src/models/api-dto.ts +17 -17
  37. package/src/models/enum-value-dto.ts +3 -3
  38. package/src/models/model-dto.ts +9 -9
  39. package/src/models/parameter-dto.ts +7 -7
  40. package/src/models/property-dto.ts +4 -4
  41. package/src/models/swagger/swagger-component-property.ts +11 -11
  42. package/src/models/swagger/swagger-component.ts +17 -17
  43. package/src/models/swagger/swagger-content.ts +4 -4
  44. package/src/models/swagger/swagger-info.ts +3 -3
  45. package/src/models/swagger/swagger-method.ts +7 -7
  46. package/src/models/swagger/swagger-schema.ts +20 -20
  47. package/src/models/swagger/swagger.ts +38 -38
  48. package/src/models/type-dto.ts +7 -7
  49. package/src/swagger-downloader.ts +12 -12
  50. package/tsconfig.json +28 -28
  51. package/autogen/identity/api/identity_api.dart +0 -100
  52. package/autogen/identity/models/auth_activate_command.dart +0 -14
  53. package/autogen/identity/models/auth_app_authenticate_command.dart +0 -16
  54. package/autogen/identity/models/auth_generate_reset_password_code_command.dart +0 -15
  55. package/autogen/identity/models/auth_refresh_token_command.dart +0 -15
  56. package/autogen/identity/models/auth_reset_password_command.dart +0 -16
  57. package/autogen/identity/models/auth_user_authenticate_command.dart +0 -15
  58. package/autogen/identity/models/auth_user_dto.dart +0 -18
  59. package/autogen/identity/models/auth_verify_reset_password_code_command.dart +0 -14
  60. package/autogen/identity/models/authentication_token.dart +0 -17
  61. package/autogen/mvc/models/problem_details.dart +0 -17
  62. package/autogen/product/api/product_api.dart +0 -70
  63. package/autogen/product/models/geoposition.dart +0 -14
  64. package/autogen/product/models/product_category_dto.dart +0 -15
  65. package/autogen/product/models/product_category_list_query_response.dart +0 -14
  66. package/autogen/product/models/product_category_save_command.dart +0 -15
  67. package/autogen/product/models/product_list_nearby_query.dart +0 -20
  68. package/autogen/product/models/product_list_nearby_query_filter.dart +0 -15
  69. package/autogen/product/models/product_list_nearby_query_order_by.dart +0 -10
  70. package/autogen/product/models/product_save_command.dart +0 -13
  71. package/autogen/service_defaults/models/application_exception.dart +0 -14
  72. package/autogen/service_defaults/models/result.dart +0 -17
  73. package/autogen/service_defaults/models/sort_direction.dart +0 -10
  74. package/autogen/user_profile/api/user_profile_api.dart +0 -51
  75. package/autogen/user_profile/models/user_general_info_save_command.dart +0 -17
  76. package/dist/generators-writers/dart/templates/api.mustache +0 -36
  77. package/dist/generators-writers/dart/templates/enum.mustache +0 -14
  78. package/dist/generators-writers/dart/templates/model.mustache +0 -18
@@ -1,100 +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(
20
- AuthAppAuthenticateCommand request
21
- ) async {
22
- final response = await _dio.post(
23
- '/identity/auth/app/token',
24
- data: request.toJson(),
25
- );
26
- return AuthenticationToken.fromJson(response.data);
27
- }
28
-
29
- Future<AuthenticationToken> authUserToken(
30
- AuthUserAuthenticateCommand request
31
- ) async {
32
- final response = await _dio.post(
33
- '/identity/auth/user/token',
34
- data: request.toJson(),
35
- );
36
- return AuthenticationToken.fromJson(response.data);
37
- }
38
-
39
- Future<AuthenticationToken> authRefreshToken(
40
- AuthRefreshTokenCommand request
41
- ) async {
42
- final response = await _dio.post(
43
- '/identity/auth/refresh-token',
44
- data: request.toJson(),
45
- );
46
- return AuthenticationToken.fromJson(response.data);
47
- }
48
-
49
- Future<Result> authGenerateResetPasswordCode(
50
- AuthGenerateResetPasswordCodeCommand request
51
- ) async {
52
- final response = await _dio.post(
53
- '/identity/auth/generate-reset-password-code',
54
- data: request.toJson(),
55
- );
56
- return Result.fromJson(response.data);
57
- }
58
-
59
- Future<Result> authResetPassword(
60
- AuthResetPasswordCommand request
61
- ) async {
62
- final response = await _dio.post(
63
- '/identity/auth/reset-password',
64
- data: request.toJson(),
65
- );
66
- return Result.fromJson(response.data);
67
- }
68
-
69
- Future<Result> authVerifyResetPasswordCode(
70
- AuthVerifyResetPasswordCodeCommand request
71
- ) async {
72
- final response = await _dio.post(
73
- '/identity/auth/verify-reset-password-code',
74
- data: request.toJson(),
75
- );
76
- return Result.fromJson(response.data);
77
- }
78
-
79
- Future<Result> authActivate(
80
- AuthActivateCommand request
81
- ) async {
82
- final response = await _dio.post(
83
- '/identity/auth/activate',
84
- data: request.toJson(),
85
- );
86
- return Result.fromJson(response.data);
87
- }
88
-
89
- Future<AuthUserDto> authUserRead(
90
-
91
- ) async {
92
- final response = await _dio.get(
93
- '/identity/auth-user/read',
94
- queryParameters: {
95
- },
96
- );
97
- return AuthUserDto.fromJson(response.data);
98
- }
99
-
100
- }
@@ -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 with _$ {
8
- const factory ({
9
- String? username,
10
- String? activationCode,
11
- }) = _;
12
-
13
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? appId,
10
- String? secret,
11
- String? audience,
12
- String? ipAddress,
13
- }) = _;
14
-
15
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? usernameOrEmail,
10
- String? host,
11
- String? urlResetPassword,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? uniqueName,
10
- String? refreshToken,
11
- String? ipAddress,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? usernameOrEmail,
10
- String? verificationCode,
11
- String? password,
12
- String? confirmPassword,
13
- }) = _;
14
-
15
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? username,
10
- String? password,
11
- String? ipAddress,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- required String idAuthUser,
10
- required String uniqueId,
11
- String? username,
12
- String? email,
13
- DateTime? activationDate,
14
- DateTime? lockedDate,
15
- }) = _;
16
-
17
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? usernameOrEmail,
10
- String? verificationCode,
11
- }) = _;
12
-
13
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? uniqueName,
10
- String? accessToken,
11
- int? expiresIn,
12
- String? refreshToken,
13
- int? refreshTokenExpiresIn,
14
- }) = _;
15
-
16
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
8
- const factory ({
9
- String? type,
10
- String? title,
11
- int? status,
12
- String? detail,
13
- String? instance,
14
- }) = _;
15
-
16
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
17
- }
@@ -1,70 +0,0 @@
1
- import 'package:coqudo_app/core/di/injector.dart';
2
- import 'package:dio/dio.dart';
3
- import 'package:coqudo_app/autogen/service_defaults/models/result.dart';
4
- import 'package:coqudo_app/autogen/product/models/product_list_nearby_query.dart';
5
- import 'package:coqudo_app/autogen/product/models/product_save_command.dart';
6
- import 'package:coqudo_app/autogen/product/models/product_category_list_query_response.dart';
7
- import 'package:coqudo_app/autogen/product/models/product_category_save_command.dart';
8
-
9
- class ProductApi {
10
- final Dio _dio;
11
-
12
- ProductApi() : _dio = getIt<Dio>();
13
-
14
- Future<Result> productRead(
15
-
16
- int myProperty,
17
- ) async {
18
- final response = await _dio.get(
19
- '/product/product/read',
20
- queryParameters: {
21
- 'myProperty': myProperty,
22
- },
23
- );
24
- return Result.fromJson(response.data);
25
- }
26
-
27
- Future<Result> productListNearby(
28
- ProductListNearbyQuery request
29
- ) async {
30
- final response = await _dio.post(
31
- '/product/product/list-nearby',
32
- data: request.toJson(),
33
- );
34
- return Result.fromJson(response.data);
35
- }
36
-
37
- Future<Result> productSave(
38
- ProductSaveCommand request
39
- ) async {
40
- final response = await _dio.post(
41
- '/product/product/save',
42
- data: request.toJson(),
43
- );
44
- return Result.fromJson(response.data);
45
- }
46
-
47
- Future<ProductCategoryListQueryResponse> productCategoryList(
48
-
49
- int? idProductCategoryParent,
50
- ) async {
51
- final response = await _dio.get(
52
- '/product/product-category/list',
53
- queryParameters: {
54
- if (idProductCategoryParent != null) 'idProductCategoryParent': idProductCategoryParent,
55
- },
56
- );
57
- return ProductCategoryListQueryResponse.fromJson(response.data);
58
- }
59
-
60
- Future<Result> productCategorySave(
61
- ProductCategorySaveCommand request
62
- ) async {
63
- final response = await _dio.post(
64
- '/product/product-category/save',
65
- data: request.toJson(),
66
- );
67
- return Result.fromJson(response.data);
68
- }
69
-
70
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'geoposition.freezed.dart';
4
- part 'geoposition.g.dart';
5
-
6
- @freezed
7
- abstract class with _$ {
8
- const factory ({
9
- required double latitude,
10
- required double longitude,
11
- }) = _;
12
-
13
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
14
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'product_category_dto.freezed.dart';
4
- part 'product_category_dto.g.dart';
5
-
6
- @freezed
7
- abstract class with _$ {
8
- const factory ({
9
- required int idProductCategory,
10
- int? idProductCategoryParent,
11
- String? name,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
15
- }
@@ -1,14 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- import 'package:coqudo_app/autogen/product/models/product_category_dto.dart';
3
-
4
- part 'product_category_list_query_response.freezed.dart';
5
- part 'product_category_list_query_response.g.dart';
6
-
7
- @freezed
8
- abstract class with _$ {
9
- const factory ({
10
- ProductCategoryDto? items,
11
- }) = _;
12
-
13
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
14
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'product_category_save_command.freezed.dart';
4
- part 'product_category_save_command.g.dart';
5
-
6
- @freezed
7
- abstract class with _$ {
8
- const factory ({
9
- required int idProductCategory,
10
- int? idProductCategoryParent,
11
- String? name,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
15
- }
@@ -1,20 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- import 'package:coqudo_app/autogen/product/models/product_list_nearby_query_filter.dart';
3
- import 'package:coqudo_app/autogen/product/models/product_list_nearby_query_order_by.dart';
4
- import 'package:coqudo_app/autogen/service_defaults/models/sort_direction.dart';
5
-
6
- part 'product_list_nearby_query.freezed.dart';
7
- part 'product_list_nearby_query.g.dart';
8
-
9
- @freezed
10
- abstract class with _$ {
11
- const factory ({
12
- ProductListNearbyQueryFilter? filter,
13
- required int pageNumber,
14
- required int pageSize,
15
- required ProductListNearbyQueryOrderBy orderBy,
16
- SortDirection? sortDirection,
17
- }) = _;
18
-
19
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
20
- }
@@ -1,15 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
- import 'package:coqudo_app/autogen/product/models/geoposition.dart';
3
-
4
- part 'product_list_nearby_query_filter.freezed.dart';
5
- part 'product_list_nearby_query_filter.g.dart';
6
-
7
- @freezed
8
- abstract class with _$ {
9
- const factory ({
10
- Geoposition? position,
11
- required int radiusInKm,
12
- }) = _;
13
-
14
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
15
- }
@@ -1,10 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- @JsonEnum(fieldRename: FieldRename.pascal)
4
- enum ProductListNearbyQueryOrderBy {
5
- Distance(1),
6
- Price(2);
7
-
8
- final int value;
9
- const ProductListNearbyQueryOrderBy(this.value);
10
- }
@@ -1,13 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- part 'product_save_command.freezed.dart';
4
- part 'product_save_command.g.dart';
5
-
6
- @freezed
7
- abstract class with _$ {
8
- const factory ({
9
- required int myProperty,
10
- }) = _;
11
-
12
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
13
- }
@@ -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 with _$ {
8
- const factory ({
9
- String? message,
10
- String? stackTrace,
11
- }) = _;
12
-
13
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(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 with _$ {
9
- const factory ({
10
- required bool isSuccess,
11
- String? message,
12
- String? stackTrace,
13
- ApplicationException? exception,
14
- }) = _;
15
-
16
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
17
- }
@@ -1,10 +0,0 @@
1
- import 'package:freezed_annotation/freezed_annotation.dart';
2
-
3
- @JsonEnum(fieldRename: FieldRename.pascal)
4
- enum SortDirection {
5
- Asc(1),
6
- Desc(2);
7
-
8
- final int value;
9
- const SortDirection(this.value);
10
- }
@@ -1,51 +0,0 @@
1
- import 'package:coqudo_app/core/di/injector.dart';
2
- import 'package:dio/dio.dart';
3
- import 'package:coqudo_app/autogen/service_defaults/models/result.dart';
4
- import 'package:coqudo_app/autogen/user_profile/models/user_general_info_save_command.dart';
5
-
6
- class UserProfileApi {
7
- final Dio _dio;
8
-
9
- UserProfileApi() : _dio = getIt<Dio>();
10
-
11
- Future<Result> userGeneralInfoRead(
12
-
13
- String name,
14
- DateTime? date,
15
- int? integer,
16
- ) async {
17
- final response = await _dio.get(
18
- '/user-profile/UserGeneralInfo/read',
19
- queryParameters: {
20
- 'name': name,
21
- if (date != null) 'date': date,
22
- if (integer != null) 'integer': integer,
23
- },
24
- );
25
- return Result.fromJson(response.data);
26
- }
27
-
28
- Future<Result> userGeneralInfoList(
29
-
30
- String name,
31
- ) async {
32
- final response = await _dio.get(
33
- '/user-profile/UserGeneralInfo/list',
34
- queryParameters: {
35
- 'name': name,
36
- },
37
- );
38
- return Result.fromJson(response.data);
39
- }
40
-
41
- Future<Result> userGeneralInfoSave(
42
- UserGeneralInfoSaveCommand request
43
- ) async {
44
- final response = await _dio.post(
45
- '/user-profile/UserGeneralInfo/save',
46
- data: request.toJson(),
47
- );
48
- return Result.fromJson(response.data);
49
- }
50
-
51
- }
@@ -1,17 +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 with _$ {
8
- const factory ({
9
- String? displayName,
10
- String? profilePictureUrl,
11
- String? email,
12
- String? phoneNumber,
13
- required int avgRating,
14
- }) = _;
15
-
16
- factory .fromJson(Map<String, dynamic> json) => _$FromJson(json);
17
- }
@@ -1,36 +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}}(
14
- {{#haveRequest}}{{requestType}} request{{/haveRequest}}
15
- {{#queryParams}}
16
- {{type}}{{#nullable}}?{{/nullable}} {{name}},
17
- {{/queryParams}}
18
- ) async {
19
- final response = await _dio.{{httpMethod}}(
20
- '{{{path}}}',
21
- {{#haveRequest}}
22
- data: request.toJson(),
23
- {{/haveRequest}}
24
- {{^haveRequest}}
25
- queryParameters: {
26
- {{#queryParams}}
27
- {{#nullable}}if ({{name}} != null) {{/nullable}}'{{name}}': {{name}},
28
- {{/queryParams}}
29
- },
30
- {{/haveRequest}}
31
- );
32
- return {{responseType}}.fromJson(response.data);
33
- }
34
-
35
- {{/endpoints}}
36
- }
@@ -1,14 +0,0 @@
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 +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
- }