forked from loafle/openapi-generator-original
[Swift] Use thread safe manager dictionary
This commit is contained in:
parent
fa12cd3787
commit
9e54dce92f
@ -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
|
// Store manager to retain its reference
|
||||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||||
|
|
||||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cleanupRequest = {
|
let cleanupRequest = {
|
||||||
managerStore.removeValueForKey(managerId)
|
managerStore[managerId] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let validatedRequest = request.validate()
|
let validatedRequest = request.validate()
|
||||||
|
@ -108,13 +108,13 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"name" : "Puma",
|
"name" : "Puma",
|
||||||
"type" : "Dog",
|
"type" : "Dog",
|
||||||
"color" : "Black",
|
"color" : "Black",
|
||||||
"gender" : "Female",
|
"gender" : "Female",
|
||||||
"breed" : "Mixed"
|
"breed" : "Mixed"
|
||||||
}, contentType=application/json}]
|
}}]
|
||||||
|
|
||||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -179,21 +179,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -202,7 +202,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter tags: (query) Tags to filter by (optional)
|
- parameter tags: (query) Tags to filter by (optional)
|
||||||
|
|
||||||
@ -242,26 +242,26 @@ public class PetAPI: APIBase {
|
|||||||
Find pet by ID
|
Find pet by ID
|
||||||
- GET /pet/{petId}
|
- GET /pet/{petId}
|
||||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- API Key:
|
||||||
"tags" : [ {
|
- type: apiKey api_key
|
||||||
"id" : 123456789,
|
- name: api_key
|
||||||
"name" : "aeiou"
|
- examples: [{contentType=application/json, example={
|
||||||
} ],
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -270,21 +270,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -293,7 +293,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -67,12 +67,12 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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]>
|
- returns: RequestBuilder<[String:Int32]>
|
||||||
*/
|
*/
|
||||||
@ -108,36 +108,36 @@ public class StoreAPI: APIBase {
|
|||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
- GET /store/order/{orderId}
|
- GET /store/order/{orderId}
|
||||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
- 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
|
Place an order for a pet
|
||||||
- POST /store/order
|
- POST /store/order
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
- 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 by user name
|
||||||
- GET /user/{username}
|
- GET /user/{username}
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -185,17 +185,17 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -204,7 +204,7 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
|
|
||||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
- 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
|
Logs user into the system
|
||||||
- GET /user/login
|
- GET /user/login
|
||||||
-
|
-
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
|
|
||||||
- parameter username: (query) The user name for login (optional)
|
- parameter username: (query) The user name for login (optional)
|
||||||
- parameter password: (query) The password for login in clear text (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
|
// Store manager to retain its reference
|
||||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||||
|
|
||||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cleanupRequest = {
|
let cleanupRequest = {
|
||||||
managerStore.removeValueForKey(managerId)
|
managerStore[managerId] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let validatedRequest = request.validate()
|
let validatedRequest = request.validate()
|
||||||
|
@ -160,13 +160,13 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"name" : "Puma",
|
"name" : "Puma",
|
||||||
"type" : "Dog",
|
"type" : "Dog",
|
||||||
"color" : "Black",
|
"color" : "Black",
|
||||||
"gender" : "Female",
|
"gender" : "Female",
|
||||||
"breed" : "Mixed"
|
"breed" : "Mixed"
|
||||||
}, contentType=application/json}]
|
}}]
|
||||||
|
|
||||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -248,21 +248,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -271,7 +271,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter tags: (query) Tags to filter by (optional)
|
- parameter tags: (query) Tags to filter by (optional)
|
||||||
|
|
||||||
@ -328,26 +328,26 @@ public class PetAPI: APIBase {
|
|||||||
Find pet by ID
|
Find pet by ID
|
||||||
- GET /pet/{petId}
|
- GET /pet/{petId}
|
||||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- API Key:
|
||||||
"tags" : [ {
|
- type: apiKey api_key
|
||||||
"id" : 123456789,
|
- name: api_key
|
||||||
"name" : "aeiou"
|
- examples: [{contentType=application/json, example={
|
||||||
} ],
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -356,21 +356,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -379,7 +379,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -101,12 +101,12 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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]>
|
- returns: RequestBuilder<[String:Int32]>
|
||||||
*/
|
*/
|
||||||
@ -159,36 +159,36 @@ public class StoreAPI: APIBase {
|
|||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
- GET /store/order/{orderId}
|
- GET /store/order/{orderId}
|
||||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
- 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
|
Place an order for a pet
|
||||||
- POST /store/order
|
- POST /store/order
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
- 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 by user name
|
||||||
- GET /user/{username}
|
- GET /user/{username}
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -271,17 +271,17 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -290,7 +290,7 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
|
|
||||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
- 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
|
Logs user into the system
|
||||||
- GET /user/login
|
- GET /user/login
|
||||||
-
|
-
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
|
|
||||||
- parameter username: (query) The user name for login (optional)
|
- parameter username: (query) The user name for login (optional)
|
||||||
- parameter password: (query) The password for login in clear text (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
|
// Store manager to retain its reference
|
||||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||||
|
|
||||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cleanupRequest = {
|
let cleanupRequest = {
|
||||||
managerStore.removeValueForKey(managerId)
|
managerStore[managerId] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let validatedRequest = request.validate()
|
let validatedRequest = request.validate()
|
||||||
|
@ -166,13 +166,13 @@ public class PetAPI: APIBase {
|
|||||||
- OAuth:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"name" : "Puma",
|
"name" : "Puma",
|
||||||
"type" : "Dog",
|
"type" : "Dog",
|
||||||
"color" : "Black",
|
"color" : "Black",
|
||||||
"gender" : "Female",
|
"gender" : "Female",
|
||||||
"breed" : "Mixed"
|
"breed" : "Mixed"
|
||||||
}, contentType=application/json}]
|
}}]
|
||||||
|
|
||||||
- parameter status: (query) Status values that need to be considered for filter (optional, default to available)
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -256,21 +256,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example=[ {
|
- examples: [{contentType=application/json, example=[ {
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
} ], contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
} ]}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -279,7 +279,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter tags: (query) Tags to filter by (optional)
|
- parameter tags: (query) Tags to filter by (optional)
|
||||||
|
|
||||||
@ -338,26 +338,26 @@ public class PetAPI: APIBase {
|
|||||||
Find pet by ID
|
Find pet by ID
|
||||||
- GET /pet/{petId}
|
- GET /pet/{petId}
|
||||||
- Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions
|
- 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:
|
- OAuth:
|
||||||
- type: oauth2
|
- type: oauth2
|
||||||
- name: petstore_auth
|
- name: petstore_auth
|
||||||
- examples: [{example={
|
- API Key:
|
||||||
"tags" : [ {
|
- type: apiKey api_key
|
||||||
"id" : 123456789,
|
- name: api_key
|
||||||
"name" : "aeiou"
|
- examples: [{contentType=application/json, example={
|
||||||
} ],
|
"photoUrls" : [ "aeiou" ],
|
||||||
|
"name" : "doggie",
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -366,21 +366,21 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"tags" : [ {
|
"photoUrls" : [ "aeiou" ],
|
||||||
"id" : 123456789,
|
"name" : "doggie",
|
||||||
"name" : "aeiou"
|
|
||||||
} ],
|
|
||||||
"id" : 123456789,
|
"id" : 123456789,
|
||||||
"category" : {
|
"category" : {
|
||||||
"id" : 123456789,
|
"name" : "aeiou",
|
||||||
"name" : "aeiou"
|
"id" : 123456789
|
||||||
},
|
},
|
||||||
"status" : "aeiou",
|
"tags" : [ {
|
||||||
"name" : "doggie",
|
"name" : "aeiou",
|
||||||
"photoUrls" : [ "aeiou" ]
|
"id" : 123456789
|
||||||
}, contentType=application/json}, {example=<Pet>
|
} ],
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Pet>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<name>doggie</name>
|
<name>doggie</name>
|
||||||
<photoUrls>
|
<photoUrls>
|
||||||
@ -389,7 +389,7 @@ public class PetAPI: APIBase {
|
|||||||
<tags>
|
<tags>
|
||||||
</tags>
|
</tags>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
</Pet>, contentType=application/xml}]
|
</Pet>}]
|
||||||
|
|
||||||
- parameter petId: (path) ID of pet that needs to be fetched
|
- parameter petId: (path) ID of pet that needs to be fetched
|
||||||
|
|
||||||
|
@ -105,12 +105,12 @@ public class StoreAPI: APIBase {
|
|||||||
- API Key:
|
- API Key:
|
||||||
- type: apiKey api_key
|
- type: apiKey api_key
|
||||||
- name: api_key
|
- name: api_key
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"key" : 123
|
"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]>
|
- returns: RequestBuilder<[String:Int32]>
|
||||||
*/
|
*/
|
||||||
@ -165,36 +165,36 @@ public class StoreAPI: APIBase {
|
|||||||
Find purchase order by ID
|
Find purchase order by ID
|
||||||
- GET /store/order/{orderId}
|
- GET /store/order/{orderId}
|
||||||
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
- For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
- 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
|
Place an order for a pet
|
||||||
- POST /store/order
|
- POST /store/order
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"petId" : 123456789,
|
"petId" : 123456789,
|
||||||
"complete" : true,
|
|
||||||
"status" : "aeiou",
|
|
||||||
"quantity" : 123,
|
"quantity" : 123,
|
||||||
"shipDate" : "2000-01-23T04:56:07.000+00:00"
|
"id" : 123456789,
|
||||||
}, contentType=application/json}, {example=<Order>
|
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||||
|
"complete" : true,
|
||||||
|
"status" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<Order>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<petId>123456</petId>
|
<petId>123456</petId>
|
||||||
<quantity>0</quantity>
|
<quantity>0</quantity>
|
||||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||||
<status>string</status>
|
<status>string</status>
|
||||||
<complete>true</complete>
|
<complete>true</complete>
|
||||||
</Order>, contentType=application/xml}]
|
</Order>}]
|
||||||
|
|
||||||
- parameter body: (body) order placed for purchasing the pet (optional)
|
- 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 by user name
|
||||||
- GET /user/{username}
|
- GET /user/{username}
|
||||||
-
|
-
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -281,17 +281,17 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
- examples: [{example={
|
- examples: [{contentType=application/json, example={
|
||||||
"id" : 123456789,
|
|
||||||
"lastName" : "aeiou",
|
|
||||||
"phone" : "aeiou",
|
|
||||||
"username" : "aeiou",
|
|
||||||
"email" : "aeiou",
|
|
||||||
"userStatus" : 123,
|
|
||||||
"firstName" : "aeiou",
|
"firstName" : "aeiou",
|
||||||
"password" : "aeiou"
|
"lastName" : "aeiou",
|
||||||
}, contentType=application/json}, {example=<User>
|
"password" : "aeiou",
|
||||||
|
"userStatus" : 123,
|
||||||
|
"phone" : "aeiou",
|
||||||
|
"id" : 123456789,
|
||||||
|
"email" : "aeiou",
|
||||||
|
"username" : "aeiou"
|
||||||
|
}}, {contentType=application/xml, example=<User>
|
||||||
<id>123456</id>
|
<id>123456</id>
|
||||||
<username>string</username>
|
<username>string</username>
|
||||||
<firstName>string</firstName>
|
<firstName>string</firstName>
|
||||||
@ -300,7 +300,7 @@ public class UserAPI: APIBase {
|
|||||||
<password>string</password>
|
<password>string</password>
|
||||||
<phone>string</phone>
|
<phone>string</phone>
|
||||||
<userStatus>0</userStatus>
|
<userStatus>0</userStatus>
|
||||||
</User>, contentType=application/xml}]
|
</User>}]
|
||||||
|
|
||||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
- 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
|
Logs user into the system
|
||||||
- GET /user/login
|
- GET /user/login
|
||||||
-
|
-
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
- examples: [{example="aeiou", contentType=application/json}, {example=string, contentType=application/xml}]
|
- examples: [{contentType=application/json, example="aeiou"}, {contentType=application/xml, example=string}]
|
||||||
|
|
||||||
- parameter username: (query) The user name for login (optional)
|
- parameter username: (query) The user name for login (optional)
|
||||||
- parameter password: (query) The password for login in clear text (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
|
// Store manager to retain its reference
|
||||||
private var managerStore: [String: Alamofire.Manager] = [:]
|
private var managerStore = SynchronizedDictionary<String, Alamofire.Manager>()
|
||||||
|
|
||||||
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||||
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
required init(method: String, URLString: String, parameters: [String : AnyObject]?, isBody: Bool) {
|
||||||
@ -83,7 +108,7 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let cleanupRequest = {
|
let cleanupRequest = {
|
||||||
managerStore.removeValueForKey(managerId)
|
managerStore[managerId] = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
let validatedRequest = request.validate()
|
let validatedRequest = request.validate()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user