mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-19 22:17:08 +00:00
* This address #3788 * Contains all changes made in #3823 * Also contains many changes made by @ewanmellor, thanks!
43 lines
1.1 KiB
Plaintext
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
|
|
}
|
|
|
|
}
|