mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-21 14:17:07 +00:00
[Swift] Adding Swift3 generator
* This address #3788 * Contains all changes made in #3823 * Also contains many changes made by @ewanmellor, thanks!
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// 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
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user