forked from loafle/openapi-generator-original
* issue 3914, removed logic that remove header parameters. update template files to handle header parameters in the same manner as other parameters * update swift and swift3 samples
51 lines
1.4 KiB
Plaintext
51 lines
1.4 KiB
Plaintext
// APIHelper.swift
|
|
//
|
|
// Generated by swagger-codegen
|
|
// https://github.com/swagger-api/swagger-codegen
|
|
//
|
|
|
|
class APIHelper {
|
|
static func rejectNil(source: [String:AnyObject?]) -> [String:AnyObject]? {
|
|
var destination = [String:AnyObject]()
|
|
for (key, nillableValue) in source {
|
|
if let value: AnyObject = nillableValue {
|
|
destination[key] = value
|
|
}
|
|
}
|
|
|
|
if destination.isEmpty {
|
|
return nil
|
|
}
|
|
return destination
|
|
}
|
|
|
|
static func rejectNilHeaders(source: [String:AnyObject?]) -> [String:String] {
|
|
var destination = [String:String]()
|
|
for (key, nillableValue) in source {
|
|
if let value: AnyObject = nillableValue {
|
|
destination[key] = "\(value)"
|
|
}
|
|
}
|
|
return destination
|
|
}
|
|
|
|
static func convertBoolToString(source: [String: AnyObject]?) -> [String:AnyObject]? {
|
|
guard let source = source else {
|
|
return nil
|
|
}
|
|
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
|
|
}
|
|
}
|
|
return destination
|
|
}
|
|
|
|
}
|