mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 19:33:55 +00:00
Merge pull request #3873 from ButterflyNetwork/swift-thread-safe-manager
[Swift] Use thread safe manager dictionary
This commit is contained in:
commit
0f25501746
@ -12,8 +12,33 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public struct SynchronizedDictionary<K: Hashable, V> {
|
||||
|
||||
private var dictionary = [K: V]()
|
||||
private let queue = dispatch_queue_create("SynchronizedDictionary", DISPATCH_QUEUE_CONCURRENT)
|
||||
|
||||
public subscript(key: K) -> V? {
|
||||
get {
|
||||
var value: V?
|
||||
|
||||
dispatch_sync(queue) {
|
||||
value = self.dictionary[key]
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
set {
|
||||
dispatch_barrier_sync(queue) {
|
||||
self.dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
||||
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||
|
||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
managerStore.removeValueForKey(managerId)
|
||||
managerStore[managerId] = nil
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
@ -108,13 +108,13 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"name" : "Puma",
|
||||
"type" : "Dog",
|
||||
"color" : "Black",
|
||||
"gender" : "Female",
|
||||
"breed" : "Mixed"
|
||||
}, contentType=application/json}]
|
||||
}}]
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
||||
|
||||
@ -157,20 +157,20 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -179,21 +179,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -202,7 +202,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter tags: (query) Tags to filter by (optional)
|
||||
|
||||
@ -242,26 +242,26 @@ public class PetAPI: APIBase {
|
||||
Find pet by ID
|
||||
- GET /pet/{petId}
|
||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -270,21 +270,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -293,7 +293,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be fetched
|
||||
|
||||
|
@ -67,12 +67,12 @@ public class StoreAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
|
||||
- returns: RequestBuilder<[String:Int32]>
|
||||
*/
|
||||
@ -108,36 +108,36 @@ public class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{orderId}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
|
||||
@ -176,36 +176,36 @@ public class StoreAPI: APIBase {
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
||||
|
||||
|
@ -167,16 +167,16 @@ public class UserAPI: APIBase {
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -185,17 +185,17 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -204,7 +204,7 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
</User>}]
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
@ -244,8 +244,8 @@ public class UserAPI: APIBase {
|
||||
Logs user into the system
|
||||
- GET /user/login
|
||||
-
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
|
||||
- parameter username: (query) The user name for login (optional)
|
||||
- parameter password: (query) The password for login in clear text (optional)
|
||||
|
@ -12,8 +12,33 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public struct SynchronizedDictionary<K: Hashable, V> {
|
||||
|
||||
private var dictionary = [K: V]()
|
||||
private let queue = dispatch_queue_create("SynchronizedDictionary", DISPATCH_QUEUE_CONCURRENT)
|
||||
|
||||
public subscript(key: K) -> V? {
|
||||
get {
|
||||
var value: V?
|
||||
|
||||
dispatch_sync(queue) {
|
||||
value = self.dictionary[key]
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
set {
|
||||
dispatch_barrier_sync(queue) {
|
||||
self.dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
||||
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||
|
||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
managerStore.removeValueForKey(managerId)
|
||||
managerStore[managerId] = nil
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
@ -160,13 +160,13 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"name" : "Puma",
|
||||
"type" : "Dog",
|
||||
"color" : "Black",
|
||||
"gender" : "Female",
|
||||
"breed" : "Mixed"
|
||||
}, contentType=application/json}]
|
||||
}}]
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
||||
|
||||
@ -226,20 +226,20 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -248,21 +248,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -271,7 +271,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter tags: (query) Tags to filter by (optional)
|
||||
|
||||
@ -328,26 +328,26 @@ public class PetAPI: APIBase {
|
||||
Find pet by ID
|
||||
- GET /pet/{petId}
|
||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -356,21 +356,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -379,7 +379,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be fetched
|
||||
|
||||
|
@ -101,12 +101,12 @@ public class StoreAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
|
||||
- returns: RequestBuilder<[String:Int32]>
|
||||
*/
|
||||
@ -159,36 +159,36 @@ public class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{orderId}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
|
||||
@ -244,36 +244,36 @@ public class StoreAPI: APIBase {
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
||||
|
||||
|
@ -253,16 +253,16 @@ public class UserAPI: APIBase {
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -271,17 +271,17 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -290,7 +290,7 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
</User>}]
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
@ -348,8 +348,8 @@ public class UserAPI: APIBase {
|
||||
Logs user into the system
|
||||
- GET /user/login
|
||||
-
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
|
||||
- parameter username: (query) The user name for login (optional)
|
||||
- parameter password: (query) The password for login in clear text (optional)
|
||||
|
@ -12,8 +12,33 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public struct SynchronizedDictionary<K: Hashable, V> {
|
||||
|
||||
private var dictionary = [K: V]()
|
||||
private let queue = dispatch_queue_create("SynchronizedDictionary", DISPATCH_QUEUE_CONCURRENT)
|
||||
|
||||
public subscript(key: K) -> V? {
|
||||
get {
|
||||
var value: V?
|
||||
|
||||
dispatch_sync(queue) {
|
||||
value = self.dictionary[key]
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
set {
|
||||
dispatch_barrier_sync(queue) {
|
||||
self.dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
||||
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||
|
||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
managerStore.removeValueForKey(managerId)
|
||||
managerStore[managerId] = nil
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
@ -166,13 +166,13 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"name" : "Puma",
|
||||
"type" : "Dog",
|
||||
"color" : "Black",
|
||||
"gender" : "Female",
|
||||
"breed" : "Mixed"
|
||||
}, contentType=application/json}]
|
||||
}}]
|
||||
|
||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
||||
|
||||
@ -234,20 +234,20 @@ public class PetAPI: APIBase {
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -256,21 +256,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example=[ {
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example=[ {
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
} ], contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
} ]}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -279,7 +279,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter tags: (query) Tags to filter by (optional)
|
||||
|
||||
@ -338,26 +338,26 @@ public class PetAPI: APIBase {
|
||||
Find pet by ID
|
||||
- GET /pet/{petId}
|
||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- OAuth:
|
||||
- type: oauth2
|
||||
- name: petstore_auth
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -366,21 +366,21 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"tags" : [ {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
} ],
|
||||
</Pet>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"photoUrls" : [ "aeiou" ],
|
||||
"name" : "doggie",
|
||||
"id" : 123456789,
|
||||
"category" : {
|
||||
"id" : 123456789,
|
||||
"name" : "aeiou"
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
},
|
||||
"status" : "aeiou",
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "aeiou" ]
|
||||
}, contentType=application/json}, {example=<Pet>
|
||||
"tags" : [ {
|
||||
"name" : "aeiou",
|
||||
"id" : 123456789
|
||||
} ],
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Pet>
|
||||
<id>123456</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
@ -389,7 +389,7 @@ public class PetAPI: APIBase {
|
||||
<tags>
|
||||
</tags>
|
||||
<status>string</status>
|
||||
</Pet>, contentType=application/xml}]
|
||||
</Pet>}]
|
||||
|
||||
- parameter petId: (path) ID of pet that needs to be fetched
|
||||
|
||||
|
@ -105,12 +105,12 @@ public class StoreAPI: APIBase {
|
||||
- API Key:
|
||||
- type: apiKey api_key
|
||||
- name: api_key
|
||||
- examples: [{example={
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"key" : 123
|
||||
}, contentType=application/json}, {example=not implemented io.swagger.models.properties.MapProperty@d1e580af, contentType=application/xml}]
|
||||
}}, {contentType=application/xml, example=not implemented io.swagger.models.properties.MapProperty@d1e580af}]
|
||||
|
||||
- returns: RequestBuilder<[String:Int32]>
|
||||
*/
|
||||
@ -165,36 +165,36 @@ public class StoreAPI: APIBase {
|
||||
Find purchase order by ID
|
||||
- GET /store/order/{orderId}
|
||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
|
||||
@ -252,36 +252,36 @@ public class StoreAPI: APIBase {
|
||||
Place an order for a pet
|
||||
- POST /store/order
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
</Order>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"petId" : 123456789,
|
||||
"complete" : true,
|
||||
"status" : "aeiou",
|
||||
"quantity" : 123,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
||||
}, contentType=application/json}, {example=<Order>
|
||||
"id" : 123456789,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : true,
|
||||
"status" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<Order>
|
||||
<id>123456</id>
|
||||
<petId>123456</petId>
|
||||
<quantity>0</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>string</status>
|
||||
<complete>true</complete>
|
||||
</Order>, contentType=application/xml}]
|
||||
</Order>}]
|
||||
|
||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
||||
|
||||
|
@ -263,16 +263,16 @@ public class UserAPI: APIBase {
|
||||
Get user by user name
|
||||
- GET /user/{username}
|
||||
-
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -281,17 +281,17 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
- examples: [{example={
|
||||
"id" : 123456789,
|
||||
"lastName" : "aeiou",
|
||||
"phone" : "aeiou",
|
||||
"username" : "aeiou",
|
||||
"email" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
</User>}]
|
||||
- examples: [{contentType=application/json, example={
|
||||
"firstName" : "aeiou",
|
||||
"password" : "aeiou"
|
||||
}, contentType=application/json}, {example=<User>
|
||||
"lastName" : "aeiou",
|
||||
"password" : "aeiou",
|
||||
"userStatus" : 123,
|
||||
"phone" : "aeiou",
|
||||
"id" : 123456789,
|
||||
"email" : "aeiou",
|
||||
"username" : "aeiou"
|
||||
}}, {contentType=application/xml, example=<User>
|
||||
<id>123456</id>
|
||||
<username>string</username>
|
||||
<firstName>string</firstName>
|
||||
@ -300,7 +300,7 @@ public class UserAPI: APIBase {
|
||||
<password>string</password>
|
||||
<phone>string</phone>
|
||||
<userStatus>0</userStatus>
|
||||
</User>, contentType=application/xml}]
|
||||
</User>}]
|
||||
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
|
||||
@ -360,8 +360,8 @@ public class UserAPI: APIBase {
|
||||
Logs user into the system
|
||||
- GET /user/login
|
||||
-
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||
|
||||
- parameter username: (query) The user name for login (optional)
|
||||
- parameter password: (query) The password for login in clear text (optional)
|
||||
|
@ -12,8 +12,33 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
}
|
||||
}
|
||||
|
||||
public struct SynchronizedDictionary<K: Hashable, V> {
|
||||
|
||||
private var dictionary = [K: V]()
|
||||
private let queue = dispatch_queue_create("SynchronizedDictionary", DISPATCH_QUEUE_CONCURRENT)
|
||||
|
||||
public subscript(key: K) -> V? {
|
||||
get {
|
||||
var value: V?
|
||||
|
||||
dispatch_sync(queue) {
|
||||
value = self.dictionary[key]
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
set {
|
||||
dispatch_barrier_sync(queue) {
|
||||
self.dictionary[key] = newValue
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Store manager to retain its reference
|
||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
||||
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||
|
||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
}
|
||||
|
||||
let cleanupRequest = {
|
||||
managerStore.removeValueForKey(managerId)
|
||||
managerStore[managerId] = nil
|
||||
}
|
||||
|
||||
let validatedRequest = request.validate()
|
||||
|
Loading…
Reference in New Issue
Block a user