From f6019f00a1e6dba499850aa39cdc37af11aef3d3 Mon Sep 17 00:00:00 2001 From: Frank Lehmann <11268968+fl034@users.noreply.github.com> Date: Wed, 27 Jan 2021 04:17:42 +0100 Subject: [PATCH] [swift5] Fix #8511 (request closure not being called) (#8537) * Remove weak self to fix too early deallocations * Update samples * Remove podfile lock * Run pod install on samples/client/test/swift5/default/TestClientApp/ * Revert "Run pod install on samples/client/test/swift5/default/TestClientApp/" This reverts commit 5ad327c70789a6ab50e372a5bbc2cfa3b0a7f883. --- .../urlsession/URLSessionImplementations.mustache | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ .../Classes/OpenAPIs/URLSessionImplementations.swift | 8 ++------ 11 files changed, 22 insertions(+), 66 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache index 896871b8d7e..95733f9d546 100644 --- a/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache +++ b/modules/openapi-generator/src/main/resources/swift5/libraries/urlsession/URLSessionImplementations.mustache @@ -132,15 +132,11 @@ private var urlSessionStore = SynchronizedDictionary() do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/combineLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/default/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/deprecated/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index a2de4751c64..8e6e4d85ec3 100644 --- a/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/nonPublicApi/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ internal class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/promisekitLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/readonlyProperties/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/resultLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/rxswiftLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest() diff --git a/samples/client/petstore/swift5/urlsessionLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift b/samples/client/petstore/swift5/urlsessionLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift index c7804d16e30..eda7e851c9e 100644 --- a/samples/client/petstore/swift5/urlsessionLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift +++ b/samples/client/petstore/swift5/urlsessionLibrary/PetstoreClient/Classes/OpenAPIs/URLSessionImplementations.swift @@ -132,15 +132,11 @@ open class URLSessionRequestBuilder: RequestBuilder { do { let request = try createURLRequest(urlSession: urlSession, method: xMethod, encoding: encoding, headers: headers) - let dataTask = urlSession.dataTask(with: request) { [weak self] data, response, error in - - guard let self = self else { return } + let dataTask = urlSession.dataTask(with: request) { data, response, error in if let taskCompletionShouldRetry = self.taskCompletionShouldRetry { - taskCompletionShouldRetry(data, response, error) { [weak self] shouldRetry in - - guard let self = self else { return } + taskCompletionShouldRetry(data, response, error) { shouldRetry in if shouldRetry { cleanupRequest()