Files
openapi-generator-original/modules/swagger-codegen/src/main/resources/swift3/APIHelper.mustache
Max Stoliar 0838523a35 [Swift] Adding Swift3 generator
* This address #3788
* Contains all changes made in #3823
* Also contains many changes made by @ewanmellor, thanks!
2016-10-14 18:32:47 +03:00

43 lines
1.1 KiB
Plaintext

// APIHelper.swift
//
// Generated by swagger-codegen
// https://github.com/swagger-api/swagger-codegen
//
import Foundation
class APIHelper {
static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
var destination = [String:Any]()
for (key, nillableValue) in source {
if let value: Any = nillableValue {
destination[key] = value
}
}
if destination.isEmpty {
return nil
}
return destination
}
static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
guard let source = source else {
return nil
}
var destination = [String:Any]()
let theTrue = NSNumber(value: true as Bool)
let theFalse = NSNumber(value: false as Bool)
for (key, value) in source {
switch value {
case let x where x as? NSNumber === theTrue || x as? NSNumber === theFalse:
destination[key] = "\(value as! Bool)" as Any?
default:
destination[key] = value
}
}
return destination
}
}