forked from loafle/openapi-generator-original
[Swift 5] deprecate retry hook since its no longer needed (#8303)
* [Swift 5] deprecated retry hook since its no longer needed * [Swift 5] deprecated retry hook since its no longer needed * [swift] fix generator code formatting
This commit is contained in:
parent
caf52641f0
commit
d2aa40a935
@ -22,8 +22,8 @@ import Foundation
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} 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?> {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map{ "\($0!)" }.joined(separator: ",")
|
||||
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,16 +46,16 @@ import Foundation
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? Array<Any?> {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} 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?> {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
if let collection = item.value as? [Any?] {
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
@ -69,4 +69,3 @@ import Foundation
|
||||
return destination
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ import Foundation
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.{{#useURLSession}}
|
||||
/// With the URLSession http client the request's progress only works on iOS 11.0, macOS 10.13, macCatalyst 13.0, tvOS 11.0, watchOS 4.0.
|
||||
/// If you need to get the request's progress in older OS versions, please use Alamofire http client.{{/useURLSession}}
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var onProgressReady: ((Progress) -> ())?
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
self.method = method
|
||||
|
@ -149,7 +149,7 @@ extension KeyedDecodingContainerProtocol {
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T: Decodable {
|
||||
var tmpArray: [T]? = nil
|
||||
var tmpArray: [T]?
|
||||
|
||||
if contains(key) {
|
||||
tmpArray = try decodeArray(T.self, forKey: key)
|
||||
@ -177,9 +177,9 @@ extension HTTPURLResponse {
|
||||
var isStatusCodeSuccessful: Bool {
|
||||
return Array(200 ..< 300).contains(statusCode)
|
||||
}
|
||||
}
|
||||
}{{#usePromiseKit}}
|
||||
|
||||
{{#usePromiseKit}}extension RequestBuilder {
|
||||
extension RequestBuilder {
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} func execute() -> Promise<Response<T>> {
|
||||
let deferred = Promise<Response<T>>.pending()
|
||||
self.execute { result in
|
||||
|
@ -41,7 +41,7 @@ import Foundation
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} static func encodingParameters(jsonData: Data?) -> [String: Any]? {
|
||||
var returnedParams: [String: Any]? = nil
|
||||
var returnedParams: [String: Any]?
|
||||
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||
var params: [String: Any] = [:]
|
||||
params[jsonDataKey] = jsonData
|
||||
|
@ -10,7 +10,7 @@ import Foundation
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class JSONEncodingHelper {
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> [String: Any]? {
|
||||
var params: [String: Any]? = nil
|
||||
var params: [String: Any]?
|
||||
|
||||
// Encode the Encodable object
|
||||
if let encodableObj = encodableObj {
|
||||
@ -27,7 +27,7 @@ import Foundation
|
||||
}
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class func encodingParameters(forEncodableObject encodableObj: Any?) -> [String: Any]? {
|
||||
var params: [String: Any]? = nil
|
||||
var params: [String: Any]?
|
||||
|
||||
if let encodableObj = encodableObj {
|
||||
do {
|
||||
|
@ -30,7 +30,6 @@ protocol JSONEncodable {
|
||||
case generalError(Error)
|
||||
}
|
||||
|
||||
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class Response<T> {
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let statusCode: Int
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} let header: [String: String]
|
||||
|
@ -44,6 +44,7 @@ private var urlSessionStore = SynchronizedDictionary<String, URLSession>()
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
{{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,7 @@ internal struct APIHelper {
|
||||
internal static func rejectNilHeaders(_ source: [String: Any?]) -> [String: String] {
|
||||
return source.reduce(into: [String: String]()) { (result, item) in
|
||||
if let collection = item.value as? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ internal struct APIHelper {
|
||||
|
||||
internal static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,7 @@ internal struct APIHelper {
|
||||
internal 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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ internal class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
internal var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required internal init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
@ -23,7 +23,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? [Any?] {
|
||||
result[item.key] = collection.filter({ $0 != nil }).map { "\($0!)" }.joined(separator: ",")
|
||||
result[item.key] = collection.filter { $0 != nil }.map { "\($0!)" }.joined(separator: ",")
|
||||
} else if let value: Any = item.value {
|
||||
result[item.key] = "\(value)"
|
||||
}
|
||||
@ -47,7 +47,7 @@ public struct APIHelper {
|
||||
|
||||
public static func mapValueToPathItem(_ source: Any) -> Any {
|
||||
if let collection = source as? [Any?] {
|
||||
return collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
return collection.filter { $0 != nil }.map {"\($0!)"}.joined(separator: ",")
|
||||
}
|
||||
return source
|
||||
}
|
||||
@ -55,7 +55,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? [Any?] {
|
||||
collection.filter({ $0 != nil }).map({"\($0!)"}).forEach { value in
|
||||
collection.filter { $0 != nil }.map {"\($0!)"}.forEach { value in
|
||||
result.append(URLQueryItem(name: item.key, value: value))
|
||||
}
|
||||
} else if let value = item.value {
|
||||
|
@ -44,6 +44,7 @@ open class URLSessionRequestBuilder<T>: RequestBuilder<T> {
|
||||
- intercept and handle errors like authorization
|
||||
- retry the request.
|
||||
*/
|
||||
@available(*, deprecated, message: "Please override execute() method to intercept and handle errors like authorization or retry the request. Check the Wiki for more info. https://github.com/OpenAPITools/openapi-generator/wiki/FAQ#how-do-i-implement-bearer-token-authentication-with-urlsession-on-the-swift-api-client")
|
||||
public var taskCompletionShouldRetry: ((Data?, URLResponse?, Error?, @escaping (Bool) -> Void) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user