@@ -5,12 +5,13 @@ import {{spec.title | caseUcfirst}}Models
5
5
6
6
/// {{ service .description }}
7
7
open class {{ service .name | caseUcfirst }}: Service {
8
+
8
9
{%~ for method in service .methods %}
9
10
///
10
11
/// {{ method .title }}
11
12
///
12
13
{%~ if method .description %}
13
- {{ method .description | swiftComment }}
14
+ {{~ method .description | swiftComment }}
14
15
///
15
16
{%~ endif %}
16
17
{%~ for parameter in method .parameters .all %}
@@ -49,6 +50,7 @@ open class {{ service.name | caseUcfirst }}: Service {
49
50
{%~ endfor %}
50
51
]
51
52
{%~ endif %}
53
+
52
54
{%~ if method .responseModel %}
53
55
let converter: ([String: Any]) -> {{ method | returnType(spec ) | raw }} = { dict in
54
56
{%~ if method .responseModel == ' any' %}
@@ -57,6 +59,7 @@ open class {{ service.name | caseUcfirst }}: Service {
57
59
return {{ spec .title | caseUcfirst }}Models.{{method .responseModel | caseUcfirst }}.from(map: dict)
58
60
{%~ endif %}
59
61
}
62
+
60
63
{%~ endif %}
61
64
{%~ if ' multipart/form-data' in method .consumes %}
62
65
{{~ include (' swift/base/requests/file.twig' ) }}
@@ -65,53 +68,45 @@ open class {{ service.name | caseUcfirst }}: Service {
65
68
{%~ endif %}
66
69
{%~ endif %}
67
70
}
71
+ {%~ if method .responseModel | hasGenericType(spec ) %}
68
72
69
- {% endfor %}
73
+ ///
74
+ /// {{ method .title }}
75
+ ///
76
+ {%~ if method .description %}
77
+ {{~ method .description | swiftComment }}
78
+ ///
79
+ {%~ endif %}
80
+ {%~ for parameter in method .parameters .all %}
81
+ /// @param {{ parameter | typeName | raw }} {{ parameter .name | caseCamel }}
82
+ {%~ endfor %}
83
+ /// @throws Exception
84
+ /// @return array
85
+ ///
86
+ {%~ if method .type == " webAuth" %}
87
+ @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
88
+ {%~ endif %}
89
+ open func {{ method .name | caseCamel }}(
90
+ {%~ for parameter in method .parameters .all %}
91
+ {{ parameter .name | caseCamel | escapeKeyword }}: {{ parameter | typeName | raw }}{% if not parameter .required %}? = nil{% endif %}{% if not loop .last or ' multipart/form-data' in method .consumes %},{% endif %}
70
92
71
- {# {% for method in service.methods %}#}
72
- {# ///#}
73
- {# /// {{ method.title }}#}
74
- {# ///#}
75
- {# {% if method.description %}#}
76
- {# {{ method.description | swiftComment }}#}
77
- {# ///#}
78
- {# {% endif %}#}
79
- {# {% for parameter in method.parameters.all %}#}
80
- {# /// @param {{ parameter | typeName | raw}} {{ parameter.name | caseCamel }}#}
81
- {# {% endfor %}#}
82
- {# /// @throws Exception#}
83
- {# /// @return array#}
84
- {# ///#}
85
- {# @available(*, deprecated, message: "Use the async overload instead")#}
86
- {# {% if method.type == "webAuth" %}#}
87
- {# @available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)#}
88
- {# {% endif %}#}
89
- {# open func {{ method.name | caseCamel }}(#}
90
- {# {% for parameter in method.parameters.all %}#}
91
- {# {{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter | typeName | raw }}{% if not parameter.required %}? = nil{% endif %},#}
92
- {# {% endfor %}#}
93
- {# {% if 'multipart/form-data' in method.consumes %}#}
94
- {# onProgress: ((UploadProgress) -> Void)? = nil,#}
95
- {# {% endif %}#}
96
- {# completion: ((Result<{{ _self.resultType(spec, method) }}, {{ spec.title | caseUcfirst}}Error>) -> Void)? = nil#}
97
- {# ) {#}
98
- {# Task {#}
99
- {# do {#}
100
- {# let result = try await {{ method.name | caseCamel }}(#}
101
- {# {% for parameter in method.parameters.all %}#}
102
- {# {{ parameter.name | caseCamel | escapeKeyword }}: {{ parameter.name | caseCamel | escapeKeyword }}{% if not loop.last or 'multipart/form-data' in method.consumes %},{% endif %}#}
93
+ {%~ endfor %}
94
+ {%~ if ' multipart/form-data' in method .consumes %}
95
+ onProgress: ((UploadProgress) -> Void)? = nil
96
+ {%~ endif %}
97
+ ) async throws -> {{ method | returnType(spec , ' [String: AnyCodable]' ) | raw }} {
98
+ return try await {{ method .name | caseCamel }}(
99
+ {%~ for parameter in method .parameters .all %}
100
+ {{ parameter .name | caseCamel | escapeKeyword }}: {{ parameter .name | caseCamel | escapeKeyword }}{% if not loop .last %},{% endif %}
103
101
104
- {# {% endfor %}#}
105
- {# {% if 'multipart/form-data' in method.consumes %}#}
106
- {# onProgress: onProgress#}
107
- {# {% endif %}#}
108
- {# )#}
109
- {# completion?(.success(result))#}
110
- {# } catch {#}
111
- {# completion?(.failure(error as! {{ spec.title | caseUcfirst}}Error))#}
112
- {# }#}
113
- {# }#}
114
- {# }#}
102
+ {%~ endfor %}
103
+ {%~ if ' multipart/form-data' in method .consumes %}
104
+ onProgress: onProgress
105
+ {%~ endif %}
106
+ )
107
+ }
108
+ {%~ endif %}
109
+
110
+ {% endfor %}
115
111
116
- {# {% endfor %}#}
117
- }
112
+ }
0 commit comments