[swift] Introduce result type (#4511)

* [swift] introduce result type as response library

* iOS - run petstore samples

* [swift4] add result sample to testing pipeline

* [swift] update docs with result type

* [swift] update result visibility

* [swift] update docs
This commit is contained in:
Bruno Coelho
2019-11-26 09:01:26 +00:00
committed by William Cheng
parent 2f26812982
commit 6bf5741fd1
180 changed files with 7695 additions and 87 deletions

View File

@@ -22,7 +22,7 @@ public struct APIHelper {
public static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] {
return source.reduce(into: [String: String]()) { (result, item) in
if let collection = item.value as? Array<Any?> {
if let collection = item.value as? [Any?] {
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
} else if let value: Any = item.value {
result[item.key] = "\(value)"
@@ -46,7 +46,7 @@ public struct APIHelper {
}
public static func mapValueToPathItem(_ source: Any) -> Any {
if let collection = source as? Array<Any?> {
if let collection = source as? [Any?] {
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
}
return source
@@ -54,7 +54,7 @@ public struct APIHelper {
public static func mapValuesToQueryItems(_ source: [String: Any?]) -> [URLQueryItem]? {
let destination = source.filter({ $0.value != nil}).reduce(into: [URLQueryItem]()) { (result, item) in
if let collection = item.value as? Array<Any?> {
if let collection = item.value as? [Any?] {
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
result.append(URLQueryItem(name: item.key, value: value))
} else if let value = item.value {

View File

@@ -6,7 +6,6 @@
//
import Foundation
import Alamofire
open class Swift4TestAPI {
/**

View File

@@ -5,7 +5,6 @@
//
import Foundation
import Alamofire
extension Bool: JSONEncodable {
func encodeToJSON() -> Any { return self as Any }