Skip to content

Commit c6751a3

Browse files
committed
Merge fixes
1 parent 29fd519 commit c6751a3

File tree

2 files changed

+9
-21
lines changed

2 files changed

+9
-21
lines changed

templates/swift/Sources/Client.swift.twig

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ open class Client {
270270
private func execute<T>(
271271
_ request: HTTPClientRequest,
272272
withSink bufferSink: ((ByteBuffer) -> Void)? = nil,
273-
convert: (([String: Any]) -> T)? = nil
273+
converter: (([String: Any]) -> T)? = nil
274274
) async throws -> T {
275275
func complete(with response: HTTPClientResponse) async throws -> T {
276276
switch response.status.code {
@@ -290,7 +290,7 @@ open class Client {
290290
let data = try await response.body.collect(upTo: Int.max)
291291
let dict = try JSONSerialization.jsonObject(with: data) as? [String: Any]
292292

293-
return convert?(dict!) ?? dict! as! T
293+
return converter?(dict!) ?? dict! as! T
294294
}
295295
default:
296296
var message = ""
@@ -354,26 +354,15 @@ open class Client {
354354

355355
if idParamName != nil && params[idParamName!] as! String != "unique()" {
356356
// Make a request to check if a file already exists
357-
group.enter()
358-
call(
357+
let map = try! await call(
359358
method: "GET",
360359
path: path + "/" + (params[idParamName!] as! String),
361360
headers: headers,
362361
params: [:],
363362
converter: { return $0 }
364-
) { response in
365-
switch response {
366-
case let .success(map):
367-
let chunksUploaded = map["chunksUploaded"] as! Int
368-
offset = min(size, (chunksUploaded * Client.chunkSize))
369-
group.leave()
370-
case let .failure(error):
371-
completion?(.failure(error))
372-
group.leave()
373-
return
374-
}
375-
}
376-
group.wait()
363+
)
364+
let chunksUploaded = map["chunksUploaded"] as! Int
365+
offset = min(size, (chunksUploaded * Client.chunkSize))
377366
}
378367

379368
while offset < size {
@@ -392,7 +381,7 @@ open class Client {
392381
path: path,
393382
headers: headers,
394383
params: params,
395-
convert: { return $0 }
384+
converter: { return $0 }
396385
)
397386

398387
offset += Client.chunkSize

templates/swift/Sources/Services/Service.swift.twig

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,8 @@ open class {{ service.name | caseUcfirst }}: Service {
120120
method: "{{ method.method | caseUpper }}",
121121
path: path,
122122
headers: headers,
123-
params: params,
124-
{% if method.responseModel %}
125-
converter: converter,
123+
params: params{% if method.responseModel %},
124+
converter: converter
126125
{% endif %}
127126
)
128127
{% endif %}

0 commit comments

Comments
 (0)