From a2acfe3be003ead45f2ce165a8ab7094cc30dcdf Mon Sep 17 00:00:00 2001 From: William Cheng Date: Sun, 2 Sep 2018 15:51:36 +0800 Subject: [PATCH] add default value to swift3,4 podspec (#921) --- .../main/resources/swift3/Podspec.mustache | 42 +++++++++++++------ .../main/resources/swift4/Podspec.mustache | 42 +++++++++++++------ .../swift3/default/.openapi-generator/VERSION | 2 +- .../swift3/default/PetstoreClient.podspec | 2 +- .../objcCompatible/.openapi-generator/VERSION | 2 +- .../objcCompatible/PetstoreClient.podspec | 2 +- .../promisekit/.openapi-generator/VERSION | 2 +- .../swift3/promisekit/PetstoreClient.podspec | 2 +- .../swift3/rxswift/.openapi-generator/VERSION | 2 +- .../swift3/rxswift/PetstoreClient.podspec | 2 +- .../unwraprequired/.openapi-generator/VERSION | 2 +- .../unwraprequired/PetstoreClient.podspec | 2 +- .../swift4/default/.openapi-generator/VERSION | 2 +- .../swift4/default/PetstoreClient.podspec | 2 +- .../objcCompatible/.openapi-generator/VERSION | 2 +- .../objcCompatible/PetstoreClient.podspec | 2 +- .../OpenAPIs/AlamofireImplementations.swift | 35 ++++++++++++++-- .../promisekit/.openapi-generator/VERSION | 2 +- .../swift4/promisekit/PetstoreClient.podspec | 2 +- .../OpenAPIs/AlamofireImplementations.swift | 35 ++++++++++++++-- .../swift4/rxswift/.openapi-generator/VERSION | 2 +- .../swift4/rxswift/PetstoreClient.podspec | 2 +- .../OpenAPIs/AlamofireImplementations.swift | 35 ++++++++++++++-- .../unwrapRequired/.openapi-generator/VERSION | 2 +- .../unwrapRequired/PetstoreClient.podspec | 2 +- .../OpenAPIs/AlamofireImplementations.swift | 35 ++++++++++++++-- 26 files changed, 206 insertions(+), 58 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/swift3/Podspec.mustache b/modules/openapi-generator/src/main/resources/swift3/Podspec.mustache index e92e9f47ae0..958c6459daf 100644 --- a/modules/openapi-generator/src/main/resources/swift3/Podspec.mustache +++ b/modules/openapi-generator/src/main/resources/swift3/Podspec.mustache @@ -5,18 +5,34 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '{{#podVersion}}{{podVersion}}{{/podVersion}}{{^podVersion}}0.0.1{{/podVersion}}' - s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' }{{/podSource}}{{#podAuthors}} - s.authors = '{{podAuthors}}'{{/podAuthors}}{{#podSocialMediaURL}} - s.social_media_url = '{{podSocialMediaURL}}'{{/podSocialMediaURL}}{{#podDocsetURL}} - s.docset_url = '{{podDocsetURL}}'{{/podDocsetURL}} - s.license = {{#podLicense}}{{& podLicense}}{{/podLicense}}{{^podLicense}}'Proprietary'{{/podLicense}}{{#podHomepage}} - s.homepage = '{{podHomepage}}'{{/podHomepage}}{{#podSummary}} - s.summary = '{{podSummary}}'{{/podSummary}}{{#podDescription}} - s.description = '{{podDescription}}'{{/podDescription}}{{#podScreenshots}} - s.screenshots = {{& podScreenshots}}{{/podScreenshots}}{{#podDocumentationURL}} - s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}} - s.source_files = '{{projectName}}/Classes/**/*.swift'{{#usePromiseKit}} - s.dependency 'PromiseKit/CorePromise', '~> 4.4.0'{{/usePromiseKit}}{{#useRxSwift}} - s.dependency 'RxSwift', '3.6.1'{{/useRxSwift}} + s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' }{{/podSource}} + {{#podAuthors}} + s.authors = '{{podAuthors}}' + {{/podAuthors}} + {{#podSocialMediaURL}} + s.social_media_url = '{{podSocialMediaURL}}' + {{/podSocialMediaURL}} + {{#podDocsetURL}} + s.docset_url = '{{podDocsetURL}}' + {{/podDocsetURL}} + s.license = {{#podLicense}}{{& podLicense}}{{/podLicense}}{{^podLicense}}'Proprietary'{{/podLicense}} + s.homepage = '{{podHomepage}}{{^podHomepage}}https://github.com/OpenAPITools/openapi-generator{{/podHomepage}}' + s.summary = '{{podSummary}}{{^podSummary}}{{projectName}} Swift SDK{{/podSummary}}' + {{#podDescription}} + s.description = '{{podDescription}}' + {{/podDescription}} + {{#podScreenshots}} + s.screenshots = {{& podScreenshots}} + {{/podScreenshots}} + {{#podDocumentationURL}} + s.documentation_url = '{{podDocumentationURL}}' + {{/podDocumentationURL}} + s.source_files = '{{projectName}}/Classes/**/*.swift' + {{#usePromiseKit}} + s.dependency 'PromiseKit/CorePromise', '~> 4.4.0' + {{/usePromiseKit}} + {{#useRxSwift}} + s.dependency 'RxSwift', '3.6.1' + {{/useRxSwift}} s.dependency 'Alamofire', '~> 4.5.0' end diff --git a/modules/openapi-generator/src/main/resources/swift4/Podspec.mustache b/modules/openapi-generator/src/main/resources/swift4/Podspec.mustache index cbb15384222..24ffd62bc15 100644 --- a/modules/openapi-generator/src/main/resources/swift4/Podspec.mustache +++ b/modules/openapi-generator/src/main/resources/swift4/Podspec.mustache @@ -5,18 +5,34 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '{{#podVersion}}{{podVersion}}{{/podVersion}}{{^podVersion}}0.0.1{{/podVersion}}' - s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' }{{/podSource}}{{#podAuthors}} - s.authors = '{{podAuthors}}'{{/podAuthors}}{{#podSocialMediaURL}} - s.social_media_url = '{{podSocialMediaURL}}'{{/podSocialMediaURL}}{{#podDocsetURL}} - s.docset_url = '{{podDocsetURL}}'{{/podDocsetURL}} - s.license = {{#podLicense}}{{& podLicense}}{{/podLicense}}{{^podLicense}}'Proprietary'{{/podLicense}}{{#podHomepage}} - s.homepage = '{{podHomepage}}'{{/podHomepage}}{{#podSummary}} - s.summary = '{{podSummary}}'{{/podSummary}}{{#podDescription}} - s.description = '{{podDescription}}'{{/podDescription}}{{#podScreenshots}} - s.screenshots = {{& podScreenshots}}{{/podScreenshots}}{{#podDocumentationURL}} - s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}} - s.source_files = '{{projectName}}/Classes/**/*.swift'{{#usePromiseKit}} - s.dependency 'PromiseKit/CorePromise', '~> 4.4.0'{{/usePromiseKit}}{{#useRxSwift}} - s.dependency 'RxSwift', '~> 4.0'{{/useRxSwift}} + s.source = {{#podSource}}{{& podSource}}{{/podSource}}{{^podSource}}{ :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' }{{/podSource}} + {{#podAuthors}} + s.authors = '{{podAuthors}}' + {{/podAuthors}} + {{#podSocialMediaURL}} + s.social_media_url = '{{podSocialMediaURL}}' + {{/podSocialMediaURL}} + {{#podDocsetURL}} + s.docset_url = '{{podDocsetURL}}' + {{/podDocsetURL}} + s.license = {{#podLicense}}{{& podLicense}}{{/podLicense}}{{^podLicense}}'Proprietary'{{/podLicense}} + s.homepage = '{{podHomepage}}{{^podHomepage}}https://github.com/OpenAPITools/openapi-generator{{/podHomepage}}' + s.summary = '{{podSummary}}{{^podSummary}}{{projectName}} Swift SDK{{/podSummary}}' + {{#podDescription}} + s.description = '{{podDescription}}' + {{/podDescription}} + {{#podScreenshots}} + s.screenshots = {{& podScreenshots}} + {{/podScreenshots}} + {{#podDocumentationURL}} + s.documentation_url = '{{podDocumentationURL}}' + {{/podDocumentationURL}} + s.source_files = '{{projectName}}/Classes/**/*.swift' + {{#usePromiseKit}} + s.dependency 'PromiseKit/CorePromise', '~> 4.4.0' + {{/usePromiseKit}} + {{#useRxSwift}} + s.dependency 'RxSwift', '~> 4.0' + {{/useRxSwift}} s.dependency 'Alamofire', '~> 4.5.0' end diff --git a/samples/client/petstore/swift3/default/.openapi-generator/VERSION b/samples/client/petstore/swift3/default/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift3/default/.openapi-generator/VERSION +++ b/samples/client/petstore/swift3/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/default/PetstoreClient.podspec b/samples/client/petstore/swift3/default/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient.podspec +++ b/samples/client/petstore/swift3/default/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift3/objcCompatible/.openapi-generator/VERSION b/samples/client/petstore/swift3/objcCompatible/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift3/objcCompatible/.openapi-generator/VERSION +++ b/samples/client/petstore/swift3/objcCompatible/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/objcCompatible/PetstoreClient.podspec b/samples/client/petstore/swift3/objcCompatible/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift3/objcCompatible/PetstoreClient.podspec +++ b/samples/client/petstore/swift3/objcCompatible/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift3/promisekit/.openapi-generator/VERSION b/samples/client/petstore/swift3/promisekit/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift3/promisekit/.openapi-generator/VERSION +++ b/samples/client/petstore/swift3/promisekit/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient.podspec b/samples/client/petstore/swift3/promisekit/PetstoreClient.podspec index 34ca76681f8..9b69b145db2 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient.podspec +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift3/rxswift/.openapi-generator/VERSION b/samples/client/petstore/swift3/rxswift/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift3/rxswift/.openapi-generator/VERSION +++ b/samples/client/petstore/swift3/rxswift/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient.podspec b/samples/client/petstore/swift3/rxswift/PetstoreClient.podspec index 83e2df162eb..e556f44d3d4 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient.podspec +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift3/unwraprequired/.openapi-generator/VERSION b/samples/client/petstore/swift3/unwraprequired/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift3/unwraprequired/.openapi-generator/VERSION +++ b/samples/client/petstore/swift3/unwraprequired/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec b/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/default/.openapi-generator/VERSION b/samples/client/petstore/swift4/default/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift4/default/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/default/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/default/PetstoreClient.podspec b/samples/client/petstore/swift4/default/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift4/default/PetstoreClient.podspec +++ b/samples/client/petstore/swift4/default/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/objcCompatible/.openapi-generator/VERSION b/samples/client/petstore/swift4/objcCompatible/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift4/objcCompatible/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/objcCompatible/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/objcCompatible/PetstoreClient.podspec b/samples/client/petstore/swift4/objcCompatible/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift4/objcCompatible/PetstoreClient.podspec +++ b/samples/client/petstore/swift4/objcCompatible/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/objcCompatible/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift4/objcCompatible/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 280b4e53389..2ade78f5a61 100644 --- a/samples/client/petstore/swift4/objcCompatible/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift4/objcCompatible/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -17,8 +17,37 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory { } } +private struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + } + // Store manager to retain its reference -private var managerStore: [String: Alamofire.SessionManager] = [:] +private var managerStore = SynchronizedDictionary() open class AlamofireRequestBuilder: RequestBuilder { required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { @@ -112,7 +141,7 @@ open class AlamofireRequestBuilder: RequestBuilder { } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() @@ -314,7 +343,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilde } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() diff --git a/samples/client/petstore/swift4/promisekit/.openapi-generator/VERSION b/samples/client/petstore/swift4/promisekit/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift4/promisekit/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/promisekit/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/promisekit/PetstoreClient.podspec b/samples/client/petstore/swift4/promisekit/PetstoreClient.podspec index 34ca76681f8..9b69b145db2 100644 --- a/samples/client/petstore/swift4/promisekit/PetstoreClient.podspec +++ b/samples/client/petstore/swift4/promisekit/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/promisekit/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift4/promisekit/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 280b4e53389..2ade78f5a61 100644 --- a/samples/client/petstore/swift4/promisekit/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift4/promisekit/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -17,8 +17,37 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory { } } +private struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + } + // Store manager to retain its reference -private var managerStore: [String: Alamofire.SessionManager] = [:] +private var managerStore = SynchronizedDictionary() open class AlamofireRequestBuilder: RequestBuilder { required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { @@ -112,7 +141,7 @@ open class AlamofireRequestBuilder: RequestBuilder { } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() @@ -314,7 +343,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilde } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() diff --git a/samples/client/petstore/swift4/rxswift/.openapi-generator/VERSION b/samples/client/petstore/swift4/rxswift/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift4/rxswift/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/rxswift/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/rxswift/PetstoreClient.podspec b/samples/client/petstore/swift4/rxswift/PetstoreClient.podspec index 5fd8bc297e7..db166a3290e 100644 --- a/samples/client/petstore/swift4/rxswift/PetstoreClient.podspec +++ b/samples/client/petstore/swift4/rxswift/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/rxswift/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift4/rxswift/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 280b4e53389..2ade78f5a61 100644 --- a/samples/client/petstore/swift4/rxswift/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift4/rxswift/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -17,8 +17,37 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory { } } +private struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + } + // Store manager to retain its reference -private var managerStore: [String: Alamofire.SessionManager] = [:] +private var managerStore = SynchronizedDictionary() open class AlamofireRequestBuilder: RequestBuilder { required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { @@ -112,7 +141,7 @@ open class AlamofireRequestBuilder: RequestBuilder { } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() @@ -314,7 +343,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilde } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() diff --git a/samples/client/petstore/swift4/unwrapRequired/.openapi-generator/VERSION b/samples/client/petstore/swift4/unwrapRequired/.openapi-generator/VERSION index 4395ff59232..c791c986fbb 100644 --- a/samples/client/petstore/swift4/unwrapRequired/.openapi-generator/VERSION +++ b/samples/client/petstore/swift4/unwrapRequired/.openapi-generator/VERSION @@ -1 +1 @@ -3.2.0-SNAPSHOT \ No newline at end of file +3.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/swift4/unwrapRequired/PetstoreClient.podspec b/samples/client/petstore/swift4/unwrapRequired/PetstoreClient.podspec index c8453cdd8e0..1ff9b50b5e0 100644 --- a/samples/client/petstore/swift4/unwrapRequired/PetstoreClient.podspec +++ b/samples/client/petstore/swift4/unwrapRequired/PetstoreClient.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '9.0' s.version = '0.0.1' - s.source = { :git => 'git@github.com:openapitools/openapi-generator.git', :tag => 'v1.0.0' } + s.source = { :git => 'git@github.com:OpenAPITools/openapi-generator.git', :tag => 'v1.0.0' } s.authors = '' s.license = 'Proprietary' s.homepage = 'https://github.com/openapitools/openapi-generator' diff --git a/samples/client/petstore/swift4/unwrapRequired/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift b/samples/client/petstore/swift4/unwrapRequired/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift index 280b4e53389..2ade78f5a61 100644 --- a/samples/client/petstore/swift4/unwrapRequired/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift +++ b/samples/client/petstore/swift4/unwrapRequired/PetstoreClient/Classes/OpenAPIs/AlamofireImplementations.swift @@ -17,8 +17,37 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory { } } +private struct SynchronizedDictionary { + + private var dictionary = [K: V]() + private let queue = DispatchQueue( + label: "SynchronizedDictionary", + qos: DispatchQoS.userInitiated, + attributes: [DispatchQueue.Attributes.concurrent], + autoreleaseFrequency: DispatchQueue.AutoreleaseFrequency.inherit, + target: nil + ) + + public subscript(key: K) -> V? { + get { + var value: V? + + queue.sync { + value = self.dictionary[key] + } + + return value + } + set { + queue.sync(flags: DispatchWorkItemFlags.barrier) { + self.dictionary[key] = newValue + } + } + } + } + // Store manager to retain its reference -private var managerStore: [String: Alamofire.SessionManager] = [:] +private var managerStore = SynchronizedDictionary() open class AlamofireRequestBuilder: RequestBuilder { required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) { @@ -112,7 +141,7 @@ open class AlamofireRequestBuilder: RequestBuilder { } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate() @@ -314,7 +343,7 @@ open class AlamofireDecodableRequestBuilder: AlamofireRequestBuilde } let cleanupRequest = { - _ = managerStore.removeValue(forKey: managerId) + managerStore[managerId] = nil } let validatedRequest = request.validate()