From 3cdc1b32947a88c656e97a1e555b329ddfcab738 Mon Sep 17 00:00:00 2001 From: Jean-Michel Douliez Date: Wed, 20 Apr 2016 15:27:51 +0200 Subject: [PATCH] Update APIHelper.mustache This is a fix attempt for : [Swift] Bool value conversion #2446 It is copied from http://stackoverflow.com/questions/36185530/how-to-check-dictionary-value-to-be-exactly-a-bool/36186159#36186159 --- .../main/resources/swift/APIHelper.mustache | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache index 418f1c8512b..9afec9f8067 100644 --- a/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache +++ b/modules/swagger-codegen/src/main/resources/swift/APIHelper.mustache @@ -13,6 +13,24 @@ class APIHelper { } } + if destination.isEmpty { + return nil + } + return destination + } + 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] = "not a bool" + } + } + if destination.isEmpty { return nil }