forked from loafle/openapi-generator-original
Merge pull request #3038 from Landschaft/master
[Swift] #3036 Make APIHelper.convertBoolToString return nil for nil input
This commit is contained in:
commit
6a73f29cef
@ -19,18 +19,19 @@ class APIHelper {
|
|||||||
return destination
|
return destination
|
||||||
}
|
}
|
||||||
|
|
||||||
static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] {
|
static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? {
|
||||||
|
guard let source = source else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
var destination = [String:AnyObject]()
|
var destination = [String:AnyObject]()
|
||||||
let theTrue = NSNumber(bool: true)
|
let theTrue = NSNumber(bool: true)
|
||||||
let theFalse = NSNumber(bool: false)
|
let theFalse = NSNumber(bool: false)
|
||||||
if (source != nil) {
|
for (key, value) in source {
|
||||||
for (key, value) in source! {
|
switch value {
|
||||||
switch value {
|
case let x where x === theTrue || x === theFalse:
|
||||||
case let x where x === theTrue || x === theFalse:
|
destination[key] = "\(value as! Bool)"
|
||||||
destination[key] = "\(value as! Bool)"
|
default:
|
||||||
default:
|
destination[key] = value
|
||||||
destination[key] = value
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return destination
|
return destination
|
||||||
|
Loading…
x
Reference in New Issue
Block a user