@devlearning/swagger-generator 1.0.27 → 1.0.28
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.
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import 'package:{{package}}/core/di/injector.dart';
|
|
2
|
+
import 'package:dio/dio.dart';
|
|
3
|
+
{{#imports}}
|
|
4
|
+
{{{.}}}
|
|
5
|
+
{{/imports}}
|
|
6
|
+
|
|
7
|
+
class {{apiClassName}} {
|
|
8
|
+
final Dio _dio;
|
|
9
|
+
|
|
10
|
+
{{apiClassName}}() : _dio = getIt<Dio>();
|
|
11
|
+
|
|
12
|
+
{{#endpoints}}
|
|
13
|
+
Future<{{responseType}}> {{methodName}}(
|
|
14
|
+
{{#haveRequest}}{{requestType}} request{{/haveRequest}}
|
|
15
|
+
{{#queryParams}}
|
|
16
|
+
{{type}}{{#nullable}}?{{/nullable}} {{name}},
|
|
17
|
+
{{/queryParams}}
|
|
18
|
+
) async {
|
|
19
|
+
final response = await _dio.{{httpMethod}}(
|
|
20
|
+
'{{{path}}}',
|
|
21
|
+
{{#haveRequest}}
|
|
22
|
+
data: request.toJson(),
|
|
23
|
+
{{/haveRequest}}
|
|
24
|
+
{{^haveRequest}}
|
|
25
|
+
queryParameters: {
|
|
26
|
+
{{#queryParams}}
|
|
27
|
+
{{#nullable}}if ({{name}} != null) {{/nullable}}'{{name}}': {{name}},
|
|
28
|
+
{{/queryParams}}
|
|
29
|
+
},
|
|
30
|
+
{{/haveRequest}}
|
|
31
|
+
);
|
|
32
|
+
return {{responseType}}.fromJson(response.data);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
{{/endpoints}}
|
|
36
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
@JsonValue({{value}})
|
|
10
|
+
{{name}}({{value}}){{#isLast}};{{/isLast}}{{^isLast}},{{/isLast}}
|
|
11
|
+
{{/fields}}
|
|
12
|
+
|
|
13
|
+
final int value;
|
|
14
|
+
const {{enumName}}(this.value);
|
|
15
|
+
}
|
|
@@ -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 {{className}} with _${{className}} {
|
|
11
|
+
const factory {{className}}({
|
|
12
|
+
{{#fields}}
|
|
13
|
+
{{required}}{{type}}{{nullable}} {{name}},
|
|
14
|
+
{{/fields}}
|
|
15
|
+
}) = _{{className}};
|
|
16
|
+
|
|
17
|
+
factory {{className}}.fromJson(Map<String, dynamic> json) => _${{className}}FromJson(json);
|
|
18
|
+
}
|