Skip to content

Commit 8556859

Browse files
author
Andrés Pizá
committed
Generated Swift 5 sample files
1 parent b7be602 commit 8556859

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1857
-54
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "Alamofire/Alamofire" ~> 4.5.0
1+
github "Alamofire/Alamofire" ~> 4.9.0

samples/client/petstore/swift5/default/PetstoreClient.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Pod::Spec.new do |s|
1010
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
1111
s.summary = 'PetstoreClient'
1212
s.source_files = 'PetstoreClient/Classes/**/*.swift'
13-
s.dependency 'Alamofire', '~> 4.5.0'
13+
s.dependency 'Alamofire', '~> 4.9.0'
1414
end

samples/client/petstore/swift5/default/PetstoreClient/Classes/Swaggers/APIs/FakeClassnameTags123API.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ open class FakeClassnameTags123API {
4545
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: body)
4646

4747
var url = URLComponents(string: URLString)
48-
url?.queryItems = APIHelper.mapValuesToQueryItems([:])
48+
url?.queryItems = APIHelper.mapValuesToQueryItems([
49+
])
4950

5051
let requestBuilder: RequestBuilder<Client>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
5152

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.4.3-SNAPSHOT
1+
2.4.9-SNAPSHOT
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
github "Alamofire/Alamofire" ~> 4.5.0
1+
github "Alamofire/Alamofire" ~> 4.9.0

samples/client/petstore/swift5/objcCompatible/PetstoreClient.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ Pod::Spec.new do |s|
1010
s.homepage = 'https://github.com/swagger-api/swagger-codegen'
1111
s.summary = 'PetstoreClient'
1212
s.source_files = 'PetstoreClient/Classes/**/*.swift'
13-
s.dependency 'Alamofire', '~> 4.5.0'
13+
s.dependency 'Alamofire', '~> 4.9.0'
1414
end

samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/Swaggers/APIs.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
import Foundation
88

99
open class PetstoreClientAPI {
10-
open static var basePath = "http://petstore.swagger.io:80/v2"
11-
open static var credential: URLCredential?
12-
open static var customHeaders: [String:String] = [:]
13-
open static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
10+
public static var basePath = "http://petstore.swagger.io:80/v2"
11+
public static var credential: URLCredential?
12+
public static var customHeaders: [String:String] = [:]
13+
public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
1414
}
1515

1616
open class RequestBuilder<T> {

samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/Swaggers/AlamofireImplementations.swift

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
2020
// Store manager to retain its reference
2121
private var managerStore: [String: Alamofire.SessionManager] = [:]
2222

23+
// Sync queue to manage safe access to the store manager
24+
private let syncQueue = DispatchQueue(label: "thread-safe-sync-queue", attributes: .concurrent)
25+
2326
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
2427
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
2528
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
@@ -58,7 +61,9 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
5861
let managerId:String = UUID().uuidString
5962
// Create a new manager for each request to customize its request header
6063
let manager = createSessionManager()
61-
managerStore[managerId] = manager
64+
syncQueue.async(flags: .barrier) {
65+
managerStore[managerId] = manager
66+
}
6267

6368
let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
6469

@@ -112,7 +117,9 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
112117
}
113118

114119
let cleanupRequest = {
115-
_ = managerStore.removeValue(forKey: managerId)
120+
syncQueue.async(flags: .barrier) {
121+
_ = managerStore.removeValue(forKey: managerId)
122+
}
116123
}
117124

118125
let validatedRequest = request.validate()
@@ -125,7 +132,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
125132
if stringResponse.result.isFailure {
126133
completion(
127134
nil,
128-
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
135+
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!)
129136
)
130137
return
131138
}
@@ -314,7 +321,9 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
314321
}
315322

316323
let cleanupRequest = {
317-
_ = managerStore.removeValue(forKey: managerId)
324+
syncQueue.async(flags: .barrier) {
325+
_ = managerStore.removeValue(forKey: managerId)
326+
}
318327
}
319328

320329
let validatedRequest = request.validate()
@@ -327,7 +336,7 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
327336
if stringResponse.result.isFailure {
328337
completion(
329338
nil,
330-
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
339+
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error!)
331340
)
332341
return
333342
}

samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/Swaggers/CodableHelper.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public typealias EncodeResult = (data: Data?, error: Error?)
1111

1212
open class CodableHelper {
1313

14-
open static var dateformatter: DateFormatter?
14+
public static var dateformatter: DateFormatter?
1515

1616
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
1717
var returnedDecodable: T? = nil

samples/client/petstore/swift5/objcCompatible/PetstoreClient/Classes/Swaggers/Configuration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ open class Configuration {
1010

1111
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
1212
// You must set it prior to encoding any dates, and it will only be read once.
13-
open static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
13+
public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
1414

1515
}

0 commit comments

Comments
 (0)