forked from loafle/openapi-generator-original
Merge pull request #1412 from Edubits/swift-alamofire-3.0
Swift Alamofire 3.0
This commit is contained in:
commit
fe676c83c0
@ -75,29 +75,26 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
request.authenticate(usingCredential: credential)
|
request.authenticate(usingCredential: credential)
|
||||||
}
|
}
|
||||||
|
|
||||||
request.responseJSON(options: .AllowFragments) { (req, res, result) in
|
request.responseJSON(options: .AllowFragments) { response in
|
||||||
managerStore.removeValueForKey(managerId)
|
managerStore.removeValueForKey(managerId)
|
||||||
|
|
||||||
if result.isFailure {
|
if response.result.isFailure {
|
||||||
completion(response: nil, erorr: result.error)
|
completion(response: nil, erorr: response.result.error)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if () is T {
|
if () is T {
|
||||||
let response = Response(response: res!, body: () as! T)
|
completion(response: Response(response: response.response!, body: () as! T), erorr: nil)
|
||||||
completion(response: response, erorr: nil)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if let json: AnyObject = result.value {
|
if let json: AnyObject = response.result.value {
|
||||||
let body = Decoders.decode(clazz: T.self, source: json)
|
let body = Decoders.decode(clazz: T.self, source: json)
|
||||||
let response = Response(response: res!, body: body)
|
completion(response: Response(response: response.response!, body: body), erorr: nil)
|
||||||
completion(response: response, erorr: nil)
|
|
||||||
return
|
return
|
||||||
} else if "" is T {
|
} else if "" is T {
|
||||||
// swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release
|
// swagger-parser currently doesn't support void, which will be fixed in future swagger-parser release
|
||||||
// https://github.com/swagger-api/swagger-parser/pull/34
|
// https://github.com/swagger-api/swagger-parser/pull/34
|
||||||
let response = Response(response: res!, body: "" as! T)
|
completion(response: Response(response: response.response!, body: "" as! T), erorr: nil)
|
||||||
completion(response: response, erorr: nil)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,4 +110,3 @@ class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
|||||||
return httpHeaders
|
return httpHeaders
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,2 +1,2 @@
|
|||||||
github "Alamofire/Alamofire" >= 2.0.0{{#usePromiseKit}}
|
github "Alamofire/Alamofire" >= 3.0.0{{#usePromiseKit}}
|
||||||
github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}}
|
github "mxcl/PromiseKit" >=1.5.3{{/usePromiseKit}}
|
||||||
|
@ -16,5 +16,5 @@ Pod::Spec.new do |s|
|
|||||||
s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}}
|
s.documentation_url = '{{podDocumentationURL}}'{{/podDocumentationURL}}
|
||||||
s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}}
|
s.source_files = '{{projectName}}/Classes/Swaggers/**/*.swift'{{#usePromiseKit}}
|
||||||
s.dependency 'PromiseKit', '~> 2.1'{{/usePromiseKit}}
|
s.dependency 'PromiseKit', '~> 2.1'{{/usePromiseKit}}
|
||||||
s.dependency 'Alamofire', '~> 2.0.0'
|
s.dependency 'Alamofire', '~> 3.0.0'
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user