@@ -21,7 +21,8 @@ extension {{projectName}}API {
21
21
{ {/description} }
22
22
open class { {classname} } {
23
23
{{#operation} }
24
- { {#allParams} }
24
+ { {#contents} }
25
+ { {#parameters} }
25
26
{ {#isEnum} }
26
27
/**
27
28
* enum for parameter { {paramName} }
@@ -31,19 +32,19 @@ open class {{classname}} {
31
32
}
32
33
33
34
{ {/isEnum} }
34
- { {/allParams } }
35
+ { {/parameters } }
35
36
/**
36
37
{ {#summary} }
37
38
{ {{summary} }}
38
39
{ {/summary} }
39
40
40
- { {#allParams } }
41
+ { {#parameters } }
41
42
- parameter { {paramName} }: ({ {#isFormParam} }form{ {/isFormParam} }{ {#isQueryParam} }query{ {/isQueryParam} }{ {#isPathParam} }path{ {/isPathParam} }{ {#isHeaderParam} }header{ {/isHeaderParam} }{ {#isBodyParam} }body{ {/isBodyParam} }) { {description} } { {^required} }(optional{ {#defaultValue} }, default to { {{.} }}{ {/defaultValue} }){ {/required} }
42
- { {/allParams } }
43
+ { {/parameters } }
43
44
- parameter completion: completion handler to receive the data and the error objects
44
45
*/
45
- open class func { {operationId} }({ {#allParams } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }{ {#hasParams} }, { {/hasParams} }completion: @escaping ((_ data: { {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }?,_ error: Error?) -> Void)) {
46
- {{operationId} }WithRequestBuilder({ {#allParams } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }).execute { (response, error) -> Void in
46
+ open class func { {operationId} }({ {#parameters } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }{ {#hasParams} }, { {/hasParams} }completion: @escaping ((_ data: { {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }?,_ error: Error?) -> Void)) {
47
+ {{operationId} }WithRequestBuilder({ {#parameters } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }).execute { (response, error) -> Void in
47
48
{{#returnType} }
48
49
completion(response?.body, error)
49
50
{ {/returnType} }
@@ -62,14 +63,14 @@ open class {{classname}} {
62
63
{ {#summary} }
63
64
{ {{summary} }}
64
65
{ {/summary} }
65
- { {#allParams } }
66
+ { {#parameters } }
66
67
- parameter { {paramName} }: ({ {#isFormParam} }form{ {/isFormParam} }{ {#isQueryParam} }query{ {/isQueryParam} }{ {#isPathParam} }path{ {/isPathParam} }{ {#isHeaderParam} }header{ {/isHeaderParam} }{ {#isBodyParam} }body{ {/isBodyParam} }) { {description} } { {^required} }(optional{ {#defaultValue} }, default to { {{.} }}{ {/defaultValue} }){ {/required} }
67
- { {/allParams } }
68
+ { {/parameters } }
68
69
- returns: Promise<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }>
69
70
*/
70
- open class func { {operationId} }({ {#allParams } } { {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }) -> Promise<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
71
+ open class func { {operationId} }({ {#parameters } } { {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }) -> Promise<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
71
72
let deferred = Promise< {{#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }>.pending()
72
- { {operationId} }({ {#allParams } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }) { data, error in
73
+ { {operationId} }({ {#parameters } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }) { data, error in
73
74
if let error = error {
74
75
deferred.reject(error)
75
76
} else {
@@ -84,14 +85,14 @@ open class {{classname}} {
84
85
{ {#summary} }
85
86
{ {{summary} }}
86
87
{ {/summary} }
87
- { {#allParams } }
88
+ { {#parameters } }
88
89
- parameter { {paramName} }: ({ {#isFormParam} }form{ {/isFormParam} }{ {#isQueryParam} }query{ {/isQueryParam} }{ {#isPathParam} }path{ {/isPathParam} }{ {#isHeaderParam} }header{ {/isHeaderParam} }{ {#isBodyParam} }body{ {/isBodyParam} }) { {description} } { {^required} }(optional{ {#defaultValue} }, default to { {{.} }}{ {/defaultValue} }){ {/required} }
89
- { {/allParams } }
90
+ { {/parameters } }
90
91
- returns: Observable<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }>
91
92
*/
92
- open class func { {operationId} }({ {#allParams } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }) -> Observable<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
93
+ open class func { {operationId} }({ {#parameters } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }) -> Observable<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
93
94
return Observable.create { observer -> Disposable in
94
- {{operationId} }({ {#allParams } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }) { data, error in
95
+ {{operationId} }({ {#parameters } }{ {paramName} }: { {paramName} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }) { data, error in
95
96
if let error = error {
96
97
observer.on(.error(error))
97
98
} else {
@@ -119,13 +120,13 @@ open class {{classname}} {
119
120
- responseHeaders: { {responseHeaders} }{ {/responseHeaders} }{ {#examples} }
120
121
- examples: { {{examples} }}{ {/examples} }{ {#externalDocs} }
121
122
- externalDocs: { {externalDocs} }{ {/externalDocs} }
122
- { {#allParams } }
123
+ { {#parameters } }
123
124
- parameter { {paramName} }: ({ {#isFormParam} }form{ {/isFormParam} }{ {#isQueryParam} }query{ {/isQueryParam} }{ {#isPathParam} }path{ {/isPathParam} }{ {#isHeaderParam} }header{ {/isHeaderParam} }{ {#isBodyParam} }body{ {/isBodyParam} }) { {description} } { {^required} }(optional{ {#defaultValue} }, default to { {{.} }}{ {/defaultValue} }){ {/required} }
124
- { {/allParams } }
125
+ { {/parameters } }
125
126
126
127
- returns: RequestBuilder<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> { {description} }
127
128
*/
128
- open class func { {operationId} }WithRequestBuilder({ {#allParams } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/allParams } }) -> RequestBuilder<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
129
+ open class func { {operationId} }WithRequestBuilder({ {#parameters } }{ {paramName} }: { {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }{ {{datatypeWithEnum} }}_{ {operationId} }{ {/isContainer} }{ {/isEnum} }{ {^isEnum} }{ {{dataType} }}{ {/isEnum} }{ {^required} }? = nil{ {/required} }{ {#hasMore} }, { {/hasMore} }{ {/parameters } }) -> RequestBuilder<{ {#returnType} }{ {{returnType} }}{ {/returnType} }{ {^returnType} }Void{ {/returnType} }> {
129
130
{{^pathParams} }let{ {/pathParams} }{ {#pathParams} }{ {^secondaryParam} }var{ {/secondaryParam} }{ {/pathParams} } path = "{ {{path} }}"{ {#pathParams} }
130
131
let { {paramName} }PreEscape = "\({ {paramName} }{ {#isEnum} }{ {#isContainer} }{ {{dataType} }}{ {/isContainer} }{ {^isContainer} }.rawValue{ {/isContainer} }{ {/isEnum} })"
131
132
let { {paramName} }PostEscape = { {paramName} }PreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
@@ -144,18 +145,25 @@ open class {{classname}} {
144
145
145
146
let nonNullParameters = APIHelper.rejectNil(formParams)
146
147
let parameters = APIHelper.convertBoolToString(nonNullParameters)
147
- { {/hasFormParams} }
148
- { {^hasFormParams} }
148
+ { {/hasFormParams} }
149
+ { {^hasFormParams} }
149
150
let parameters: [String:Any]? = nil
150
- { {/hasFormParams} }
151
- { {/bodyParam} }{ {#hasQueryParams} }
151
+ { {/hasFormParams} }
152
+ { {/bodyParam} }
153
+ { {#queryParams} }
154
+ { {#@first} }
152
155
var url = URLComponents(string: URLString)
153
156
url?.queryItems = APIHelper.mapValuesToQueryItems([
154
- { {#queryParams } }
157
+ { {/@first } }
155
158
{ {> _param} }{ {#hasMore} }, { {/hasMore} }
156
- { {/queryParams} }
157
- ]){ {/hasQueryParams} }{ {^hasQueryParams} }
158
- let url = URLComponents(string: URLString){ {/hasQueryParams} }{ {#headerParams} }{ {^secondaryParam} }
159
+ { {#@last} }
160
+ ])
161
+ { {/@last} }
162
+ { {/queryParams} }
163
+ { {^queryParams} }
164
+ let url = URLComponents(string: URLString)
165
+ { {/queryParams} }
166
+ { {#headerParams} }{ {^secondaryParam} }
159
167
let nillableHeaders: [String: Any?] = [{ {/secondaryParam} }
160
168
{ {> _param} }{ {#hasMore} },{ {/hasMore} }{ {^hasMore} }
161
169
]
@@ -165,7 +173,7 @@ open class {{classname}} {
165
173
166
174
return requestBuilder.init(method: "{ {httpMethod} }", URLString: (url?.string ?? URLString), parameters: parameters, isBody: { {hasBodyParam} }{ {#headerParams} }{ {^secondaryParam} }, headers: headerParameters{ {/secondaryParam} }{ {/headerParams} })
167
175
}
168
-
176
+ { {/contents } }
169
177
{ {/operation} }
170
178
}
171
179
{ {#swiftUseApiNamespace} }
0 commit comments