From 9f19a74123c12e9d5083ef4fb93fac14ac7786e5 Mon Sep 17 00:00:00 2001 From: Jean-Michel Douliez Date: Tue, 10 May 2016 12:45:38 +0200 Subject: [PATCH] Update APIHelper.mustache --- .../src/main/resources/swift/APIHelper.mustache | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache index e562ae92cf4f..7041709f3651 100644 --- a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache @@ -19,16 +19,18 @@ class APIHelper { return destination } - static func convertBoolToString(source: [String: AnyObject]) -> [String:AnyObject] { + static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject] { var destination = [String:AnyObject]() let theTrue = NSNumber(bool: true) let theFalse = NSNumber(bool: false) - for (key, value) in source { - switch value { - case let x where x === theTrue || x === theFalse: - destination[key] = "\(value as! Bool)" - default: - destination[key] = value + if (source != nil) { + for (key, value) in source! { + switch value { + case let x where x === theTrue || x === theFalse: + destination[key] = "\(value as! Bool)" + default: + destination[key] = value + } } } return destination