forked from loafle/openapi-generator-original
update swift4 samples, update test scripts (#4009)
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
import Foundation
|
||||
|
||||
public struct APIHelper {
|
||||
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||
public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? {
|
||||
let destination = source.reduce(into: [String: Any]()) { (result, item) in
|
||||
if let value = item.value {
|
||||
result[item.key] = value
|
||||
@@ -20,17 +20,17 @@ public struct APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||
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?> {
|
||||
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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? {
|
||||
guard let source = source else {
|
||||
return nil
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public struct APIHelper {
|
||||
return source
|
||||
}
|
||||
|
||||
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
|
||||
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?> {
|
||||
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
@@ -68,4 +68,3 @@ public struct APIHelper {
|
||||
return destination
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,22 +9,22 @@ import Foundation
|
||||
open class PetstoreClientAPI {
|
||||
public static var basePath = "http://petstore.swagger.io:80/v2"
|
||||
public static var credential: URLCredential?
|
||||
public static var customHeaders: [String:String] = [:]
|
||||
public static var customHeaders: [String: String] = [:]
|
||||
public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||
}
|
||||
|
||||
open class RequestBuilder<T> {
|
||||
var credential: URLCredential?
|
||||
var headers: [String:String]
|
||||
public let parameters: [String:Any]?
|
||||
var headers: [String: String]
|
||||
public let parameters: [String: Any]?
|
||||
public let isBody: Bool
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
public var onProgressReady: ((Progress) -> ())?
|
||||
public var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
@@ -34,7 +34,7 @@ open class RequestBuilder<T> {
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders:[String:String]) {
|
||||
open func addHeaders(_ aHeaders: [String: String]) {
|
||||
for (header, value) in aHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
@@ -57,5 +57,5 @@ open class RequestBuilder<T> {
|
||||
|
||||
public protocol RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
@@ -17,7 +15,7 @@ open class AnotherFakeAPI {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func call123testSpecialTags(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func call123testSpecialTags(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
call123testSpecialTagsWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
@@ -8,15 +8,13 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeAPI {
|
||||
/**
|
||||
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?, _ error: Error?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -45,7 +43,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: Error?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -74,7 +72,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?, _ error: Error?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -103,7 +101,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -132,8 +130,8 @@ open class FakeAPI {
|
||||
- parameter body: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -166,8 +164,8 @@ open class FakeAPI {
|
||||
- parameter body: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithQueryParams(query: String, body: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { (response, error) -> Void in
|
||||
open class func testBodyWithQueryParams(query: String, body: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -203,7 +201,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClientModelWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -247,8 +245,8 @@ open class FakeAPI {
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -283,7 +281,7 @@ open class FakeAPI {
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"integer": integer?.encodeToJSON(),
|
||||
"int32": int32?.encodeToJSON(),
|
||||
"int64": int64?.encodeToJSON(),
|
||||
@@ -302,7 +300,7 @@ open class FakeAPI {
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -390,8 +388,8 @@ open class FakeAPI {
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -417,19 +415,19 @@ open class FakeAPI {
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"enum_form_string_array": enumFormStringArray,
|
||||
"enum_form_string": enumFormString?.rawValue
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_double": enumQueryDouble?.rawValue
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
@@ -454,8 +452,8 @@ open class FakeAPI {
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { (response, error) -> Void in
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -479,13 +477,13 @@ open class FakeAPI {
|
||||
open class func testGroupParametersWithRequestBuilder(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"int64_group": int64Group?.encodeToJSON()
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
@@ -505,8 +503,8 @@ open class FakeAPI {
|
||||
- parameter param: (body) request body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(param: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (response, error) -> Void in
|
||||
open class func testInlineAdditionalProperties(param: [String: String], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -521,7 +519,7 @@ open class FakeAPI {
|
||||
- parameter param: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String:String]) -> RequestBuilder<Void> {
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String: String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param)
|
||||
@@ -540,8 +538,8 @@ open class FakeAPI {
|
||||
- parameter param2: (form) field2
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -560,14 +558,14 @@ open class FakeAPI {
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||
let path = "/fake/jsonFormData"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"param": param,
|
||||
"param2": param2
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
@@ -17,7 +15,7 @@ open class FakeClassnameTags123API {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class PetAPI {
|
||||
/**
|
||||
Add a new pet to the store
|
||||
@@ -17,8 +15,8 @@ open class PetAPI {
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func addPet(body: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func addPet(body: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -55,8 +53,8 @@ open class PetAPI {
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -81,8 +79,8 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey
|
||||
@@ -109,7 +107,7 @@ open class PetAPI {
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -128,8 +126,8 @@ open class PetAPI {
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByStatus"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status
|
||||
@@ -146,7 +144,7 @@ open class PetAPI {
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -165,8 +163,8 @@ open class PetAPI {
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags
|
||||
@@ -183,7 +181,7 @@ open class PetAPI {
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: Error?) -> Void)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -205,8 +203,8 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -220,8 +218,8 @@ open class PetAPI {
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePet(body: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func updatePet(body: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -259,8 +257,8 @@ open class PetAPI {
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -286,14 +284,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"name": name,
|
||||
"status": status
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -309,7 +307,7 @@ open class PetAPI {
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -332,14 +330,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"file": file
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -355,7 +353,7 @@ open class PetAPI {
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -378,14 +376,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"requiredFile": requiredFile
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class StoreAPI {
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
@@ -17,8 +15,8 @@ open class StoreAPI {
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -40,8 +38,8 @@ open class StoreAPI {
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -54,7 +52,7 @@ open class StoreAPI {
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) {
|
||||
open class func getInventory(completion: @escaping ((_ data: [String: Int]?, _ error: Error?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -69,14 +67,14 @@ open class StoreAPI {
|
||||
- name: api_key
|
||||
- returns: RequestBuilder<[String:Int]>
|
||||
*/
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String: Int]> {
|
||||
let path = "/store/inventory"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
let requestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
@@ -87,7 +85,7 @@ open class StoreAPI {
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -106,8 +104,8 @@ open class StoreAPI {
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -121,7 +119,7 @@ open class StoreAPI {
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class UserAPI {
|
||||
/**
|
||||
Create user
|
||||
@@ -17,8 +15,8 @@ open class UserAPI {
|
||||
- parameter body: (body) Created user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUser(body: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUserWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func createUser(body: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUserWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -52,8 +50,8 @@ open class UserAPI {
|
||||
- parameter body: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithArrayInput(body: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func createUsersWithArrayInput(body: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUsersWithArrayInputWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -86,8 +84,8 @@ open class UserAPI {
|
||||
- parameter body: (body) List of user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createUsersWithListInput(body: [User], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func createUsersWithListInput(body: [User], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createUsersWithListInputWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -120,8 +118,8 @@ open class UserAPI {
|
||||
- parameter username: (path) The name that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
open class func deleteUser(username: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deleteUserWithRequestBuilder(username: username).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -143,8 +141,8 @@ open class UserAPI {
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -158,7 +156,7 @@ open class UserAPI {
|
||||
- parameter username: (path) The name that needs to be fetched. Use user1 for testing.
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getUserByName(username: String, completion: @escaping ((_ data: User?,_ error: Error?) -> Void)) {
|
||||
open class func getUserByName(username: String, completion: @escaping ((_ data: User?, _ error: Error?) -> Void)) {
|
||||
getUserByNameWithRequestBuilder(username: username).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -176,8 +174,8 @@ open class UserAPI {
|
||||
let usernamePostEscape = usernamePreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{username}", with: usernamePostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<User>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -192,7 +190,7 @@ open class UserAPI {
|
||||
- parameter password: (query) The password for login in clear text
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
open class func loginUser(username: String, password: String, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
|
||||
loginUserWithRequestBuilder(username: username, password: password).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -209,11 +207,11 @@ open class UserAPI {
|
||||
open class func loginUserWithRequestBuilder(username: String, password: String) -> RequestBuilder<String> {
|
||||
let path = "/user/login"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"username": username,
|
||||
"username": username,
|
||||
"password": password
|
||||
])
|
||||
|
||||
@@ -227,8 +225,8 @@ open class UserAPI {
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func logoutUser(completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute { (response, error) -> Void in
|
||||
open class func logoutUser(completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
logoutUserWithRequestBuilder().execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -245,8 +243,8 @@ open class UserAPI {
|
||||
open class func logoutUserWithRequestBuilder() -> RequestBuilder<Void> {
|
||||
let path = "/user/logout"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -261,8 +259,8 @@ open class UserAPI {
|
||||
- parameter body: (body) Updated user object
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updateUser(username: String, body: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updateUserWithRequestBuilder(username: username, body: body).execute { (response, error) -> Void in
|
||||
open class func updateUser(username: String, body: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updateUserWithRequestBuilder(username: username, body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
|
||||
@@ -12,7 +12,7 @@ class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||
return AlamofireRequestBuilder<T>.self
|
||||
}
|
||||
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type {
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type {
|
||||
return AlamofireDecodableRequestBuilder<T>.self
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ private struct SynchronizedDictionary<K: Hashable, V> {
|
||||
private var managerStore = SynchronizedDictionary<String, Alamofire.SessionManager>()
|
||||
|
||||
open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
required public init(method: String, URLString: String, parameters: [String : Any]?, isBody: Bool, headers: [String : String] = [:]) {
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
super.init(method: method, URLString: URLString, parameters: parameters, isBody: isBody, headers: headers)
|
||||
}
|
||||
|
||||
@@ -88,17 +88,17 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
May be overridden by a subclass if you want to control the request
|
||||
configuration (e.g. to override the cache policy).
|
||||
*/
|
||||
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String:String]) -> DataRequest {
|
||||
open func makeRequest(manager: SessionManager, method: HTTPMethod, encoding: ParameterEncoding, headers: [String: String]) -> DataRequest {
|
||||
return manager.request(URLString, method: method, parameters: parameters, encoding: encoding, headers: headers)
|
||||
}
|
||||
|
||||
override open func execute(_ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
let managerId:String = UUID().uuidString
|
||||
let managerId: String = UUID().uuidString
|
||||
// Create a new manager for each request to customize its request header
|
||||
let manager = createSessionManager()
|
||||
managerStore[managerId] = manager
|
||||
|
||||
let encoding:ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
|
||||
let encoding: ParameterEncoding = isBody ? JSONDataEncoding() : URLEncoding()
|
||||
|
||||
let xMethod = Alamofire.HTTPMethod(rawValue: method)
|
||||
let fileKeys = parameters == nil ? [] : parameters!.filter { $1 is NSURL }
|
||||
@@ -111,8 +111,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
case let fileURL as URL:
|
||||
if let mimeType = self.contentTypeForFormPart(fileURL: fileURL) {
|
||||
mpForm.append(fileURL, withName: k, fileName: fileURL.lastPathComponent, mimeType: mimeType)
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
mpForm.append(fileURL, withName: k)
|
||||
}
|
||||
case let string as String:
|
||||
@@ -276,7 +275,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
return httpHeaders
|
||||
}
|
||||
|
||||
fileprivate func getFileName(fromContentDisposition contentDisposition : String?) -> String? {
|
||||
fileprivate func getFileName(fromContentDisposition contentDisposition: String?) -> String? {
|
||||
|
||||
guard let contentDisposition = contentDisposition else {
|
||||
return nil
|
||||
@@ -284,7 +283,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
let items = contentDisposition.components(separatedBy: ";")
|
||||
|
||||
var filename : String? = nil
|
||||
var filename: String?
|
||||
|
||||
for contentItem in items {
|
||||
|
||||
@@ -295,7 +294,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
filename = contentItem
|
||||
return filename?
|
||||
.replacingCharacters(in: range, with:"")
|
||||
.replacingCharacters(in: range, with: "")
|
||||
.replacingOccurrences(of: "\"", with: "")
|
||||
.trimmingCharacters(in: .whitespacesAndNewlines)
|
||||
}
|
||||
@@ -304,7 +303,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getPath(from url : URL) throws -> String {
|
||||
fileprivate func getPath(from url: URL) throws -> String {
|
||||
|
||||
guard var path = URLComponents(url: url, resolvingAgainstBaseURL: true)?.path else {
|
||||
throw DownloadException.requestMissingPath
|
||||
@@ -318,7 +317,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
}
|
||||
|
||||
fileprivate func getURL(from urlRequest : URLRequest) throws -> URL {
|
||||
fileprivate func getURL(from urlRequest: URLRequest) throws -> URL {
|
||||
|
||||
guard let url = urlRequest.url else {
|
||||
throw DownloadException.requestMissingURL
|
||||
@@ -329,7 +328,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
|
||||
}
|
||||
|
||||
fileprivate enum DownloadException : Error {
|
||||
private enum DownloadException: Error {
|
||||
case responseDataMissing
|
||||
case responseFailed
|
||||
case requestMissing
|
||||
@@ -344,7 +343,7 @@ public enum AlamofireDecodableRequestBuilderError: Error {
|
||||
case generalError(Error)
|
||||
}
|
||||
|
||||
open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilder<T> {
|
||||
open class AlamofireDecodableRequestBuilder<T: Decodable>: AlamofireRequestBuilder<T> {
|
||||
|
||||
override fileprivate func processRequest(request: DataRequest, _ managerId: String, _ completion: @escaping (_ response: Response<T>?, _ error: Error?) -> Void) {
|
||||
if let credential = self.credential {
|
||||
@@ -436,7 +435,7 @@ open class AlamofireDecodableRequestBuilder<T:Decodable>: AlamofireRequestBuilde
|
||||
return
|
||||
}
|
||||
|
||||
var responseObj: Response<T>? = nil
|
||||
var responseObj: Response<T>?
|
||||
|
||||
let decodeResult: (decodableObj: T?, error: Error?) = CodableHelper.decode(T.self, from: data)
|
||||
if decodeResult.error == nil {
|
||||
|
||||
@@ -13,9 +13,9 @@ open class CodableHelper {
|
||||
|
||||
public static var dateformatter: DateFormatter?
|
||||
|
||||
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T : Decodable {
|
||||
var returnedDecodable: T? = nil
|
||||
var returnedError: Error? = nil
|
||||
open class func decode<T>(_ type: T.Type, from data: Data) -> (decodableObj: T?, error: Error?) where T: Decodable {
|
||||
var returnedDecodable: T?
|
||||
var returnedError: Error?
|
||||
|
||||
let decoder = JSONDecoder()
|
||||
if let df = self.dateformatter {
|
||||
@@ -39,9 +39,9 @@ open class CodableHelper {
|
||||
return (returnedDecodable, returnedError)
|
||||
}
|
||||
|
||||
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T : Encodable {
|
||||
open class func encode<T>(_ value: T, prettyPrint: Bool = false) -> EncodeResult where T: Encodable {
|
||||
var returnedData: Data?
|
||||
var returnedError: Error? = nil
|
||||
var returnedError: Error?
|
||||
|
||||
let encoder = JSONEncoder()
|
||||
if prettyPrint {
|
||||
|
||||
@@ -7,9 +7,9 @@
|
||||
import Foundation
|
||||
|
||||
open class Configuration {
|
||||
|
||||
|
||||
// This value is used to configure the date formatter that is used to serialize dates into JSON format.
|
||||
// You must set it prior to encoding any dates, and it will only be read once.
|
||||
public static var dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ"
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -112,24 +112,24 @@ extension String: CodingKey {
|
||||
|
||||
extension KeyedEncodingContainerProtocol {
|
||||
|
||||
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T : Encodable {
|
||||
public mutating func encodeArray<T>(_ values: [T], forKey key: Self.Key) throws where T: Encodable {
|
||||
var arrayContainer = nestedUnkeyedContainer(forKey: key)
|
||||
try arrayContainer.encode(contentsOf: values)
|
||||
}
|
||||
|
||||
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T : Encodable {
|
||||
public mutating func encodeArrayIfPresent<T>(_ values: [T]?, forKey key: Self.Key) throws where T: Encodable {
|
||||
if let values = values {
|
||||
try encodeArray(values, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T : Encodable {
|
||||
public mutating func encodeMap<T>(_ pairs: [Self.Key: T]) throws where T: Encodable {
|
||||
for (key, value) in pairs {
|
||||
try encode(value, forKey: key)
|
||||
}
|
||||
}
|
||||
|
||||
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T : Encodable {
|
||||
public mutating func encodeMapIfPresent<T>(_ pairs: [Self.Key: T]?) throws where T: Encodable {
|
||||
if let pairs = pairs {
|
||||
try encodeMap(pairs)
|
||||
}
|
||||
@@ -139,7 +139,7 @@ extension KeyedEncodingContainerProtocol {
|
||||
|
||||
extension KeyedDecodingContainerProtocol {
|
||||
|
||||
public func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T : Decodable {
|
||||
public func decodeArray<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T] where T: Decodable {
|
||||
var tmpArray = [T]()
|
||||
|
||||
var nestedContainer = try nestedUnkeyedContainer(forKey: key)
|
||||
@@ -151,8 +151,8 @@ extension KeyedDecodingContainerProtocol {
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T : Decodable {
|
||||
var tmpArray: [T]? = nil
|
||||
public func decodeArrayIfPresent<T>(_ type: T.Type, forKey key: Self.Key) throws -> [T]? where T: Decodable {
|
||||
var tmpArray: [T]?
|
||||
|
||||
if contains(key) {
|
||||
tmpArray = try decodeArray(T.self, forKey: key)
|
||||
@@ -161,8 +161,8 @@ extension KeyedDecodingContainerProtocol {
|
||||
return tmpArray
|
||||
}
|
||||
|
||||
public func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T : Decodable {
|
||||
var map: [Self.Key : T] = [:]
|
||||
public func decodeMap<T>(_ type: T.Type, excludedKeys: Set<Self.Key>) throws -> [Self.Key: T] where T: Decodable {
|
||||
var map: [Self.Key: T] = [:]
|
||||
|
||||
for key in allKeys {
|
||||
if !excludedKeys.contains(key) {
|
||||
@@ -175,5 +175,3 @@ extension KeyedDecodingContainerProtocol {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@ public struct JSONDataEncoding: ParameterEncoding {
|
||||
}
|
||||
|
||||
public static func encodingParameters(jsonData: Data?) -> Parameters? {
|
||||
var returnedParams: Parameters? = nil
|
||||
var returnedParams: Parameters?
|
||||
if let jsonData = jsonData, !jsonData.isEmpty {
|
||||
var params = Parameters()
|
||||
params[jsonDataKey] = jsonData
|
||||
|
||||
@@ -10,8 +10,8 @@ import Alamofire
|
||||
|
||||
open class JSONEncodingHelper {
|
||||
|
||||
open class func encodingParameters<T:Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
|
||||
var params: Parameters? = nil
|
||||
open class func encodingParameters<T: Encodable>(forEncodableObject encodableObj: T?) -> Parameters? {
|
||||
var params: Parameters?
|
||||
|
||||
// Encode the Encodable object
|
||||
if let encodableObj = encodableObj {
|
||||
@@ -25,7 +25,7 @@ open class JSONEncodingHelper {
|
||||
}
|
||||
|
||||
open class func encodingParameters(forEncodableObject encodableObj: Any?) -> Parameters? {
|
||||
var params: Parameters? = nil
|
||||
var params: Parameters?
|
||||
|
||||
if let encodableObj = encodableObj {
|
||||
do {
|
||||
@@ -39,5 +39,5 @@ open class JSONEncodingHelper {
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ protocol JSONEncodable {
|
||||
func encodeToJSON() -> Any
|
||||
}
|
||||
|
||||
public enum ErrorResponse : Error {
|
||||
public enum ErrorResponse: Error {
|
||||
case error(Int, Data?, Error)
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ open class Response<T> {
|
||||
|
||||
public convenience init(response: HTTPURLResponse, body: T?) {
|
||||
let rawHeader = response.allHeaderFields
|
||||
var header = [String:String]()
|
||||
var header = [String: String]()
|
||||
for case let (key, value) as (String, String) in rawHeader {
|
||||
header[key] = value
|
||||
}
|
||||
|
||||
@@ -7,23 +7,19 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct AdditionalPropertiesClass: Codable {
|
||||
|
||||
public var mapString: [String:String]?
|
||||
public var mapMapString: [String:[String:String]]?
|
||||
public var mapString: [String: String]?
|
||||
public var mapMapString: [String: [String: String]]?
|
||||
|
||||
public init(mapString: [String:String]?, mapMapString: [String:[String:String]]?) {
|
||||
public init(mapString: [String: String]?, mapMapString: [String: [String: String]]?) {
|
||||
self.mapString = mapString
|
||||
self.mapMapString = mapMapString
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapString = "map_string"
|
||||
case mapMapString = "map_map_string"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Animal: Codable {
|
||||
|
||||
public var className: String
|
||||
@@ -19,6 +17,4 @@ public struct Animal: Codable {
|
||||
self.color = color
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,5 +7,4 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public typealias AnimalFarm = [Animal]
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ApiResponse: Codable {
|
||||
|
||||
public var code: Int?
|
||||
@@ -21,6 +19,4 @@ public struct ApiResponse: Codable {
|
||||
self.message = message
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayArrayNumber: [[Double]]?
|
||||
@@ -17,10 +15,8 @@ public struct ArrayOfArrayOfNumberOnly: Codable {
|
||||
self.arrayArrayNumber = arrayArrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayArrayNumber = "ArrayArrayNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayOfNumberOnly: Codable {
|
||||
|
||||
public var arrayNumber: [Double]?
|
||||
@@ -17,10 +15,8 @@ public struct ArrayOfNumberOnly: Codable {
|
||||
self.arrayNumber = arrayNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayNumber = "ArrayNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ArrayTest: Codable {
|
||||
|
||||
public var arrayOfString: [String]?
|
||||
@@ -21,12 +19,10 @@ public struct ArrayTest: Codable {
|
||||
self.arrayArrayOfModel = arrayArrayOfModel
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case arrayOfString = "array_of_string"
|
||||
case arrayArrayOfInteger = "array_array_of_integer"
|
||||
case arrayArrayOfModel = "array_array_of_model"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Capitalization: Codable {
|
||||
|
||||
public var smallCamel: String?
|
||||
@@ -28,7 +26,7 @@ public struct Capitalization: Codable {
|
||||
self.ATT_NAME = ATT_NAME
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case smallCamel
|
||||
case capitalCamel = "CapitalCamel"
|
||||
case smallSnake = "small_Snake"
|
||||
@@ -37,6 +35,4 @@ public struct Capitalization: Codable {
|
||||
case ATT_NAME
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Cat: Codable {
|
||||
|
||||
public var className: String
|
||||
@@ -21,6 +19,4 @@ public struct Cat: Codable {
|
||||
self.declawed = declawed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct CatAllOf: Codable {
|
||||
|
||||
public var declawed: Bool?
|
||||
@@ -17,6 +15,4 @@ public struct CatAllOf: Codable {
|
||||
self.declawed = declawed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Category: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
@@ -19,6 +17,4 @@ public struct Category: Codable {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model with \"_class\" property */
|
||||
|
||||
public struct ClassModel: Codable {
|
||||
@@ -18,6 +17,4 @@ public struct ClassModel: Codable {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Client: Codable {
|
||||
|
||||
public var client: String?
|
||||
@@ -17,6 +15,4 @@ public struct Client: Codable {
|
||||
self.client = client
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Dog: Codable {
|
||||
|
||||
public var className: String
|
||||
@@ -21,6 +19,4 @@ public struct Dog: Codable {
|
||||
self.breed = breed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct DogAllOf: Codable {
|
||||
|
||||
public var breed: String?
|
||||
@@ -17,6 +15,4 @@ public struct DogAllOf: Codable {
|
||||
self.breed = breed
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct EnumArrays: Codable {
|
||||
|
||||
public enum JustSymbol: String, Codable {
|
||||
@@ -27,11 +25,9 @@ public struct EnumArrays: Codable {
|
||||
self.arrayEnum = arrayEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justSymbol = "just_symbol"
|
||||
case arrayEnum = "array_enum"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public enum EnumClass: String, Codable {
|
||||
case abc = "_abc"
|
||||
case efg = "-efg"
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct EnumTest: Codable {
|
||||
|
||||
public enum EnumString: String, Codable {
|
||||
@@ -43,7 +41,7 @@ public struct EnumTest: Codable {
|
||||
self.outerEnum = outerEnum
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case enumString = "enum_string"
|
||||
case enumStringRequired = "enum_string_required"
|
||||
case enumInteger = "enum_integer"
|
||||
@@ -51,6 +49,4 @@ public struct EnumTest: Codable {
|
||||
case outerEnum
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Must be named `File` for test. */
|
||||
|
||||
public struct File: Codable {
|
||||
@@ -19,6 +18,4 @@ public struct File: Codable {
|
||||
self.sourceURI = sourceURI
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct FileSchemaTestClass: Codable {
|
||||
|
||||
public var file: File?
|
||||
@@ -19,6 +17,4 @@ public struct FileSchemaTestClass: Codable {
|
||||
self.files = files
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct FormatTest: Codable {
|
||||
|
||||
public var integer: Int?
|
||||
@@ -41,6 +39,4 @@ public struct FormatTest: Codable {
|
||||
self.password = password
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct HasOnlyReadOnly: Codable {
|
||||
|
||||
public var bar: String?
|
||||
@@ -19,6 +17,4 @@ public struct HasOnlyReadOnly: Codable {
|
||||
self.foo = foo
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct List: Codable {
|
||||
|
||||
public var _123list: String?
|
||||
@@ -17,10 +15,8 @@ public struct List: Codable {
|
||||
self._123list = _123list
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _123list = "123-list"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,33 +7,29 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct MapTest: Codable {
|
||||
|
||||
public enum MapOfEnumString: String, Codable {
|
||||
case upper = "UPPER"
|
||||
case lower = "lower"
|
||||
}
|
||||
public var mapMapOfString: [String:[String:String]]?
|
||||
public var mapOfEnumString: [String:String]?
|
||||
public var directMap: [String:Bool]?
|
||||
public var mapMapOfString: [String: [String: String]]?
|
||||
public var mapOfEnumString: [String: String]?
|
||||
public var directMap: [String: Bool]?
|
||||
public var indirectMap: StringBooleanMap?
|
||||
|
||||
public init(mapMapOfString: [String:[String:String]]?, mapOfEnumString: [String:String]?, directMap: [String:Bool]?, indirectMap: StringBooleanMap?) {
|
||||
public init(mapMapOfString: [String: [String: String]]?, mapOfEnumString: [String: String]?, directMap: [String: Bool]?, indirectMap: StringBooleanMap?) {
|
||||
self.mapMapOfString = mapMapOfString
|
||||
self.mapOfEnumString = mapOfEnumString
|
||||
self.directMap = directMap
|
||||
self.indirectMap = indirectMap
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case mapMapOfString = "map_map_of_string"
|
||||
case mapOfEnumString = "map_of_enum_string"
|
||||
case directMap = "direct_map"
|
||||
case indirectMap = "indirect_map"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,20 +7,16 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct MixedPropertiesAndAdditionalPropertiesClass: Codable {
|
||||
|
||||
public var uuid: UUID?
|
||||
public var dateTime: Date?
|
||||
public var map: [String:Animal]?
|
||||
public var map: [String: Animal]?
|
||||
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String:Animal]?) {
|
||||
public init(uuid: UUID?, dateTime: Date?, map: [String: Animal]?) {
|
||||
self.uuid = uuid
|
||||
self.dateTime = dateTime
|
||||
self.map = map
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model name starting with number */
|
||||
|
||||
public struct Model200Response: Codable {
|
||||
@@ -20,11 +19,9 @@ public struct Model200Response: Codable {
|
||||
self._class = _class
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case _class = "class"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing model name same as property name */
|
||||
|
||||
public struct Name: Codable {
|
||||
@@ -24,13 +23,11 @@ public struct Name: Codable {
|
||||
self._123number = _123number
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case name
|
||||
case snakeCase = "snake_case"
|
||||
case property
|
||||
case _123number = "123Number"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct NumberOnly: Codable {
|
||||
|
||||
public var justNumber: Double?
|
||||
@@ -17,10 +15,8 @@ public struct NumberOnly: Codable {
|
||||
self.justNumber = justNumber
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case justNumber = "JustNumber"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Order: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
@@ -33,6 +31,4 @@ public struct Order: Codable {
|
||||
self.complete = complete
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct OuterComposite: Codable {
|
||||
|
||||
public var myNumber: Double?
|
||||
@@ -21,12 +19,10 @@ public struct OuterComposite: Codable {
|
||||
self.myBoolean = myBoolean
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case myNumber = "my_number"
|
||||
case myString = "my_string"
|
||||
case myBoolean = "my_boolean"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
public enum OuterEnum: String, Codable {
|
||||
case placed = "placed"
|
||||
case approved = "approved"
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Pet: Codable {
|
||||
|
||||
public enum Status: String, Codable {
|
||||
@@ -33,6 +31,4 @@ public struct Pet: Codable {
|
||||
self.status = status
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct ReadOnlyFirst: Codable {
|
||||
|
||||
public var bar: String?
|
||||
@@ -19,6 +17,4 @@ public struct ReadOnlyFirst: Codable {
|
||||
self.baz = baz
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
/** Model for testing reserved words */
|
||||
|
||||
public struct Return: Codable {
|
||||
@@ -18,10 +17,8 @@ public struct Return: Codable {
|
||||
self._return = _return
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case _return = "return"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct SpecialModelName: Codable {
|
||||
|
||||
public var specialPropertyName: Int64?
|
||||
@@ -17,10 +15,8 @@ public struct SpecialModelName: Codable {
|
||||
self.specialPropertyName = specialPropertyName
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case specialPropertyName = "$special[property.name]"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,9 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct StringBooleanMap: Codable {
|
||||
|
||||
|
||||
public var additionalProperties: [String:Bool] = [:]
|
||||
public var additionalProperties: [String: Bool] = [:]
|
||||
|
||||
public subscript(key: String) -> Bool? {
|
||||
get {
|
||||
@@ -45,7 +42,4 @@ public struct StringBooleanMap: Codable {
|
||||
additionalProperties = try container.decodeMap(Bool.self, excludedKeys: nonAdditionalPropertyKeys)
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct Tag: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
@@ -19,6 +17,4 @@ public struct Tag: Codable {
|
||||
self.name = name
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct TypeHolderDefault: Codable {
|
||||
|
||||
public var stringItem: String = "what"
|
||||
@@ -25,7 +23,7 @@ public struct TypeHolderDefault: Codable {
|
||||
self.arrayItem = arrayItem
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case stringItem = "string_item"
|
||||
case numberItem = "number_item"
|
||||
case integerItem = "integer_item"
|
||||
@@ -33,6 +31,4 @@ public struct TypeHolderDefault: Codable {
|
||||
case arrayItem = "array_item"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct TypeHolderExample: Codable {
|
||||
|
||||
public var stringItem: String
|
||||
@@ -25,7 +23,7 @@ public struct TypeHolderExample: Codable {
|
||||
self.arrayItem = arrayItem
|
||||
}
|
||||
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
public enum CodingKeys: String, CodingKey {
|
||||
case stringItem = "string_item"
|
||||
case numberItem = "number_item"
|
||||
case integerItem = "integer_item"
|
||||
@@ -33,6 +31,4 @@ public struct TypeHolderExample: Codable {
|
||||
case arrayItem = "array_item"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
|
||||
import Foundation
|
||||
|
||||
|
||||
|
||||
public struct User: Codable {
|
||||
|
||||
public var id: Int64?
|
||||
@@ -32,6 +30,4 @@ public struct User: Codable {
|
||||
self.userStatus = userStatus
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
PODS:
|
||||
- Alamofire (4.7.3)
|
||||
- PetstoreClient (0.0.1):
|
||||
- Alamofire (~> 4.7.0)
|
||||
- Alamofire (4.9.0)
|
||||
- PetstoreClient (1.0.0):
|
||||
- Alamofire (~> 4.9.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- PetstoreClient (from `../`)
|
||||
@@ -15,9 +15,9 @@ EXTERNAL SOURCES:
|
||||
:path: "../"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
|
||||
PetstoreClient: ed26185215a5241fa4e937e806321d611f3d0c30
|
||||
Alamofire: afc3e7c6db61476cb45cdd23fed06bad03bbc321
|
||||
PetstoreClient: e5c71b862a32097342e341f7088805bbfc033a3e
|
||||
|
||||
PODFILE CHECKSUM: cedb3058b02f4776d7c31f6d92ae2f674fdf424d
|
||||
|
||||
COCOAPODS: 1.5.3
|
||||
COCOAPODS: 1.6.1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -67,11 +67,12 @@ In order to keep Alamofire focused specifically on core networking implementatio
|
||||
- [Alamofire 2.0 Migration Guide](https://github.com/Alamofire/Alamofire/blob/master/Documentation/Alamofire%202.0%20Migration%20Guide.md)
|
||||
|
||||
## Communication
|
||||
|
||||
- If you **need help**, use [Stack Overflow](https://stackoverflow.com/questions/tagged/alamofire). (Tag 'alamofire')
|
||||
- If you'd like to **ask a general question**, use [Stack Overflow](https://stackoverflow.com/questions/tagged/alamofire).
|
||||
- If you **found a bug**, open an issue.
|
||||
- If you **have a feature request**, open an issue.
|
||||
- If you **need help with making network requests**, use [Stack Overflow](https://stackoverflow.com/questions/tagged/alamofire) and tag `alamofire`.
|
||||
- If you need to **find or understand an API**, check [our documentation](http://alamofire.github.io/Alamofire/) or [Apple's documentation for `URLSession`](https://developer.apple.com/documentation/foundation/url_loading_system), on top of which Alamofire is built.
|
||||
- If you need **help with an Alamofire feature**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire).
|
||||
- If you'd like to **discuss Alamofire best practices**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire).
|
||||
- If you'd like to **discuss a feature request**, use [our forum on swift.org](https://forums.swift.org/c/related-projects/alamofire).
|
||||
- If you **found a bug**, open an issue and follow the guide. The more detail the better!
|
||||
- If you **want to contribute**, submit a pull request.
|
||||
|
||||
## Installation
|
||||
@@ -84,7 +85,7 @@ In order to keep Alamofire focused specifically on core networking implementatio
|
||||
$ gem install cocoapods
|
||||
```
|
||||
|
||||
> CocoaPods 1.1+ is required to build Alamofire 4.0+.
|
||||
> CocoaPods 1.7+ is required to build Alamofire 4.9+.
|
||||
|
||||
To integrate Alamofire into your Xcode project using CocoaPods, specify it in your `Podfile`:
|
||||
|
||||
@@ -94,7 +95,7 @@ platform :ios, '10.0'
|
||||
use_frameworks!
|
||||
|
||||
target '<Your Target Name>' do
|
||||
pod 'Alamofire', '~> 4.7'
|
||||
pod 'Alamofire', '~> 4.9'
|
||||
end
|
||||
```
|
||||
|
||||
@@ -111,14 +112,13 @@ $ pod install
|
||||
You can install Carthage with [Homebrew](https://brew.sh/) using the following command:
|
||||
|
||||
```bash
|
||||
$ brew update
|
||||
$ brew install carthage
|
||||
```
|
||||
|
||||
To integrate Alamofire into your Xcode project using Carthage, specify it in your `Cartfile`:
|
||||
|
||||
```ogdl
|
||||
github "Alamofire/Alamofire" ~> 4.7
|
||||
github "Alamofire/Alamofire" ~> 4.9
|
||||
```
|
||||
|
||||
Run `carthage update` to build the framework and drag the built `Alamofire.framework` into your Xcode project.
|
||||
@@ -141,7 +141,7 @@ dependencies: [
|
||||
|
||||
```swift
|
||||
dependencies: [
|
||||
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.0.0")
|
||||
.package(url: "https://github.com/Alamofire/Alamofire.git", from: "4.9.0")
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// AFError.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Alamofire.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -135,7 +135,8 @@ public func request(
|
||||
parameters: Parameters? = nil,
|
||||
encoding: ParameterEncoding = URLEncoding.default,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> DataRequest {
|
||||
-> DataRequest
|
||||
{
|
||||
return SessionManager.default.request(
|
||||
url,
|
||||
method: method,
|
||||
@@ -182,7 +183,8 @@ public func download(
|
||||
encoding: ParameterEncoding = URLEncoding.default,
|
||||
headers: HTTPHeaders? = nil,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
return SessionManager.default.download(
|
||||
url,
|
||||
method: method,
|
||||
@@ -207,7 +209,8 @@ public func download(
|
||||
public func download(
|
||||
_ urlRequest: URLRequestConvertible,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
return SessionManager.default.download(urlRequest, to: destination)
|
||||
}
|
||||
|
||||
@@ -236,7 +239,8 @@ public func download(
|
||||
public func download(
|
||||
resumingWith resumeData: Data,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
return SessionManager.default.download(resumingWith: resumeData, to: destination)
|
||||
}
|
||||
|
||||
@@ -259,7 +263,8 @@ public func upload(
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
return SessionManager.default.upload(fileURL, to: url, method: method, headers: headers)
|
||||
}
|
||||
|
||||
@@ -292,7 +297,8 @@ public func upload(
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
return SessionManager.default.upload(data, to: url, method: method, headers: headers)
|
||||
}
|
||||
|
||||
@@ -325,7 +331,8 @@ public func upload(
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
return SessionManager.default.upload(stream, to: url, method: method, headers: headers)
|
||||
}
|
||||
|
||||
@@ -372,7 +379,8 @@ public func upload(
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil,
|
||||
encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) {
|
||||
encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?)
|
||||
{
|
||||
return SessionManager.default.upload(
|
||||
multipartFormData: multipartFormData,
|
||||
usingThreshold: encodingMemoryThreshold,
|
||||
@@ -408,7 +416,8 @@ public func upload(
|
||||
multipartFormData: @escaping (MultipartFormData) -> Void,
|
||||
usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold,
|
||||
with urlRequest: URLRequestConvertible,
|
||||
encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?) {
|
||||
encodingCompletion: ((SessionManager.MultipartFormDataEncodingResult) -> Void)?)
|
||||
{
|
||||
return SessionManager.default.upload(
|
||||
multipartFormData: multipartFormData,
|
||||
usingThreshold: encodingMemoryThreshold,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DispatchQueue+Alamofire.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// MultipartFormData.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -98,7 +98,7 @@ open class MultipartFormData {
|
||||
public var contentLength: UInt64 { return bodyParts.reduce(0) { $0 + $1.bodyContentLength } }
|
||||
|
||||
/// The boundary used to separate the body parts in the encoded form data.
|
||||
public let boundary: String
|
||||
public var boundary: String
|
||||
|
||||
private var bodyParts: [BodyPart]
|
||||
private var bodyPartError: AFError?
|
||||
@@ -275,7 +275,8 @@ open class MultipartFormData {
|
||||
}
|
||||
|
||||
bodyContentLength = fileSize.uint64Value
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
setBodyPartError(withReason: .bodyPartFileSizeQueryFailedWithError(forURL: fileURL, error: error))
|
||||
return
|
||||
}
|
||||
@@ -311,7 +312,8 @@ open class MultipartFormData {
|
||||
withLength length: UInt64,
|
||||
name: String,
|
||||
fileName: String,
|
||||
mimeType: String) {
|
||||
mimeType: String)
|
||||
{
|
||||
let headers = contentHeaders(withName: name, fileName: fileName, mimeType: mimeType)
|
||||
append(stream, withLength: length, headers: headers)
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// NetworkReachabilityManager.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -128,7 +128,9 @@ open class NetworkReachabilityManager {
|
||||
|
||||
private init(reachability: SCNetworkReachability) {
|
||||
self.reachability = reachability
|
||||
self.previousFlags = SCNetworkReachabilityFlags()
|
||||
|
||||
// Set the previous flags to an unreserved value to represent unknown status
|
||||
self.previousFlags = SCNetworkReachabilityFlags(rawValue: 1 << 30)
|
||||
}
|
||||
|
||||
deinit {
|
||||
@@ -146,7 +148,8 @@ open class NetworkReachabilityManager {
|
||||
context.info = Unmanaged.passUnretained(self).toOpaque()
|
||||
|
||||
let callbackEnabled = SCNetworkReachabilitySetCallback(
|
||||
reachability, { (_, flags, info) in
|
||||
reachability,
|
||||
{ (_, flags, info) in
|
||||
let reachability = Unmanaged<NetworkReachabilityManager>.fromOpaque(info!).takeUnretainedValue()
|
||||
reachability.notifyListener(flags)
|
||||
},
|
||||
@@ -156,8 +159,11 @@ open class NetworkReachabilityManager {
|
||||
let queueEnabled = SCNetworkReachabilitySetDispatchQueue(reachability, listenerQueue)
|
||||
|
||||
listenerQueue.async {
|
||||
self.previousFlags = SCNetworkReachabilityFlags()
|
||||
self.notifyListener(self.flags ?? SCNetworkReachabilityFlags())
|
||||
self.previousFlags = SCNetworkReachabilityFlags(rawValue: 1 << 30)
|
||||
|
||||
guard let flags = self.flags else { return }
|
||||
|
||||
self.notifyListener(flags)
|
||||
}
|
||||
|
||||
return callbackEnabled && queueEnabled
|
||||
@@ -215,7 +221,8 @@ extension NetworkReachabilityManager.NetworkReachabilityStatus: Equatable {}
|
||||
public func ==(
|
||||
lhs: NetworkReachabilityManager.NetworkReachabilityStatus,
|
||||
rhs: NetworkReachabilityManager.NetworkReachabilityStatus)
|
||||
-> Bool {
|
||||
-> Bool
|
||||
{
|
||||
switch (lhs, rhs) {
|
||||
case (.unknown, .unknown):
|
||||
return true
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Notifications.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ParameterEncoding.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -435,7 +435,8 @@ public struct PropertyListEncoding: ParameterEncoding {
|
||||
/// - returns: The new `PropertyListEncoding` instance.
|
||||
public init(
|
||||
format: PropertyListSerialization.PropertyListFormat = .xml,
|
||||
options: PropertyListSerialization.WriteOptions = 0) {
|
||||
options: PropertyListSerialization.WriteOptions = 0)
|
||||
{
|
||||
self.format = format
|
||||
self.options = options
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Request.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -161,7 +161,8 @@ open class Request {
|
||||
user: String,
|
||||
password: String,
|
||||
persistence: URLCredential.Persistence = .forSession)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
let credential = URLCredential(user: user, password: password, persistence: persistence)
|
||||
return authenticate(usingCredential: credential)
|
||||
}
|
||||
@@ -319,21 +320,16 @@ extension Request: CustomDebugStringConvertible {
|
||||
|
||||
var headers: [AnyHashable: Any] = [:]
|
||||
|
||||
if let additionalHeaders = session.configuration.httpAdditionalHeaders {
|
||||
for (field, value) in additionalHeaders where field != AnyHashable("Cookie") {
|
||||
headers[field] = value
|
||||
}
|
||||
}
|
||||
session.configuration.httpAdditionalHeaders?.filter { $0.0 != AnyHashable("Cookie") }
|
||||
.forEach { headers[$0.0] = $0.1 }
|
||||
|
||||
if let headerFields = request.allHTTPHeaderFields {
|
||||
for (field, value) in headerFields where field != "Cookie" {
|
||||
headers[field] = value
|
||||
}
|
||||
}
|
||||
request.allHTTPHeaderFields?.filter { $0.0 != "Cookie" }
|
||||
.forEach { headers[$0.0] = $0.1 }
|
||||
|
||||
for (field, value) in headers {
|
||||
let escapedValue = String(describing: value).replacingOccurrences(of: "\"", with: "\\\"")
|
||||
components.append("-H \"\(field): \(escapedValue)\"")
|
||||
components += headers.map {
|
||||
let escapedValue = String(describing: $0.value).replacingOccurrences(of: "\"", with: "\\\"")
|
||||
|
||||
return "-H \"\($0.key): \(escapedValue)\""
|
||||
}
|
||||
|
||||
if let httpBodyData = request.httpBody, let httpBody = String(data: httpBodyData, encoding: .utf8) {
|
||||
@@ -501,8 +497,19 @@ open class DownloadRequest: Request {
|
||||
// MARK: State
|
||||
|
||||
/// Cancels the request.
|
||||
open override func cancel() {
|
||||
downloadDelegate.downloadTask.cancel { self.downloadDelegate.resumeData = $0 }
|
||||
override open func cancel() {
|
||||
cancel(createResumeData: true)
|
||||
}
|
||||
|
||||
/// Cancels the request.
|
||||
///
|
||||
/// - parameter createResumeData: Determines whether resume data is created via the underlying download task or not.
|
||||
open func cancel(createResumeData: Bool) {
|
||||
if createResumeData {
|
||||
downloadDelegate.downloadTask.cancel { self.downloadDelegate.resumeData = $0 }
|
||||
} else {
|
||||
downloadDelegate.downloadTask.cancel()
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(
|
||||
name: Notification.Name.Task.DidCancel,
|
||||
@@ -537,7 +544,8 @@ open class DownloadRequest: Request {
|
||||
open class func suggestedDownloadDestination(
|
||||
for directory: FileManager.SearchPathDirectory = .documentDirectory,
|
||||
in domain: FileManager.SearchPathDomainMask = .userDomainMask)
|
||||
-> DownloadFileDestination {
|
||||
-> DownloadFileDestination
|
||||
{
|
||||
return { temporaryURL, response in
|
||||
let directoryURLs = FileManager.default.urls(for: directory, in: domain)
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Response.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -58,7 +58,8 @@ public struct DefaultDataResponse {
|
||||
data: Data?,
|
||||
error: Error?,
|
||||
timeline: Timeline = Timeline(),
|
||||
metrics: AnyObject? = nil) {
|
||||
metrics: AnyObject? = nil)
|
||||
{
|
||||
self.request = request
|
||||
self.response = response
|
||||
self.data = data
|
||||
@@ -108,7 +109,8 @@ public struct DataResponse<Value> {
|
||||
response: HTTPURLResponse?,
|
||||
data: Data?,
|
||||
result: Result<Value>,
|
||||
timeline: Timeline = Timeline()) {
|
||||
timeline: Timeline = Timeline())
|
||||
{
|
||||
self.request = request
|
||||
self.response = response
|
||||
self.data = data
|
||||
@@ -294,7 +296,8 @@ public struct DefaultDownloadResponse {
|
||||
resumeData: Data?,
|
||||
error: Error?,
|
||||
timeline: Timeline = Timeline(),
|
||||
metrics: AnyObject? = nil) {
|
||||
metrics: AnyObject? = nil)
|
||||
{
|
||||
self.request = request
|
||||
self.response = response
|
||||
self.temporaryURL = temporaryURL
|
||||
@@ -356,7 +359,8 @@ public struct DownloadResponse<Value> {
|
||||
destinationURL: URL?,
|
||||
resumeData: Data?,
|
||||
result: Result<Value>,
|
||||
timeline: Timeline = Timeline()) {
|
||||
timeline: Timeline = Timeline())
|
||||
{
|
||||
self.request = request
|
||||
self.response = response
|
||||
self.temporaryURL = temporaryURL
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ResponseSerialization.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -144,7 +144,8 @@ extension DataRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
responseSerializer: T,
|
||||
completionHandler: @escaping (DataResponse<T.SerializedObject>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
delegate.queue.addOperation {
|
||||
let result = responseSerializer.serializeResponse(
|
||||
self.request,
|
||||
@@ -181,7 +182,8 @@ extension DownloadRequest {
|
||||
public func response(
|
||||
queue: DispatchQueue? = nil,
|
||||
completionHandler: @escaping (DefaultDownloadResponse) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
delegate.queue.addOperation {
|
||||
(queue ?? DispatchQueue.main).async {
|
||||
var downloadResponse = DefaultDownloadResponse(
|
||||
@@ -216,7 +218,8 @@ extension DownloadRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
responseSerializer: T,
|
||||
completionHandler: @escaping (DownloadResponse<T.SerializedObject>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
delegate.queue.addOperation {
|
||||
let result = responseSerializer.serializeResponse(
|
||||
self.request,
|
||||
@@ -286,7 +289,8 @@ extension DataRequest {
|
||||
public func responseData(
|
||||
queue: DispatchQueue? = nil,
|
||||
completionHandler: @escaping (DataResponse<Data>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DataRequest.dataResponseSerializer(),
|
||||
@@ -325,7 +329,8 @@ extension DownloadRequest {
|
||||
public func responseData(
|
||||
queue: DispatchQueue? = nil,
|
||||
completionHandler: @escaping (DownloadResponse<Data>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DownloadRequest.dataResponseSerializer(),
|
||||
@@ -351,7 +356,8 @@ extension Request {
|
||||
response: HTTPURLResponse?,
|
||||
data: Data?,
|
||||
error: Error?)
|
||||
-> Result<String> {
|
||||
-> Result<String>
|
||||
{
|
||||
guard error == nil else { return .failure(error!) }
|
||||
|
||||
if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success("") }
|
||||
@@ -405,7 +411,8 @@ extension DataRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
encoding: String.Encoding? = nil,
|
||||
completionHandler: @escaping (DataResponse<String>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DataRequest.stringResponseSerializer(encoding: encoding),
|
||||
@@ -452,7 +459,8 @@ extension DownloadRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
encoding: String.Encoding? = nil,
|
||||
completionHandler: @escaping (DownloadResponse<String>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DownloadRequest.stringResponseSerializer(encoding: encoding),
|
||||
@@ -478,7 +486,8 @@ extension Request {
|
||||
response: HTTPURLResponse?,
|
||||
data: Data?,
|
||||
error: Error?)
|
||||
-> Result<Any> {
|
||||
-> Result<Any>
|
||||
{
|
||||
guard error == nil else { return .failure(error!) }
|
||||
|
||||
if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) }
|
||||
@@ -505,7 +514,8 @@ extension DataRequest {
|
||||
/// - returns: A JSON object response serializer.
|
||||
public static func jsonResponseSerializer(
|
||||
options: JSONSerialization.ReadingOptions = .allowFragments)
|
||||
-> DataResponseSerializer<Any> {
|
||||
-> DataResponseSerializer<Any>
|
||||
{
|
||||
return DataResponseSerializer { _, response, data, error in
|
||||
return Request.serializeResponseJSON(options: options, response: response, data: data, error: error)
|
||||
}
|
||||
@@ -522,7 +532,8 @@ extension DataRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
options: JSONSerialization.ReadingOptions = .allowFragments,
|
||||
completionHandler: @escaping (DataResponse<Any>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DataRequest.jsonResponseSerializer(options: options),
|
||||
@@ -540,7 +551,8 @@ extension DownloadRequest {
|
||||
/// - returns: A JSON object response serializer.
|
||||
public static func jsonResponseSerializer(
|
||||
options: JSONSerialization.ReadingOptions = .allowFragments)
|
||||
-> DownloadResponseSerializer<Any> {
|
||||
-> DownloadResponseSerializer<Any>
|
||||
{
|
||||
return DownloadResponseSerializer { _, response, fileURL, error in
|
||||
guard error == nil else { return .failure(error!) }
|
||||
|
||||
@@ -568,7 +580,8 @@ extension DownloadRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
options: JSONSerialization.ReadingOptions = .allowFragments,
|
||||
completionHandler: @escaping (DownloadResponse<Any>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DownloadRequest.jsonResponseSerializer(options: options),
|
||||
@@ -594,7 +607,8 @@ extension Request {
|
||||
response: HTTPURLResponse?,
|
||||
data: Data?,
|
||||
error: Error?)
|
||||
-> Result<Any> {
|
||||
-> Result<Any>
|
||||
{
|
||||
guard error == nil else { return .failure(error!) }
|
||||
|
||||
if let response = response, emptyDataStatusCodes.contains(response.statusCode) { return .success(NSNull()) }
|
||||
@@ -621,7 +635,8 @@ extension DataRequest {
|
||||
/// - returns: A property list object response serializer.
|
||||
public static func propertyListResponseSerializer(
|
||||
options: PropertyListSerialization.ReadOptions = [])
|
||||
-> DataResponseSerializer<Any> {
|
||||
-> DataResponseSerializer<Any>
|
||||
{
|
||||
return DataResponseSerializer { _, response, data, error in
|
||||
return Request.serializeResponsePropertyList(options: options, response: response, data: data, error: error)
|
||||
}
|
||||
@@ -638,7 +653,8 @@ extension DataRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
options: PropertyListSerialization.ReadOptions = [],
|
||||
completionHandler: @escaping (DataResponse<Any>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DataRequest.propertyListResponseSerializer(options: options),
|
||||
@@ -656,7 +672,8 @@ extension DownloadRequest {
|
||||
/// - returns: A property list object response serializer.
|
||||
public static func propertyListResponseSerializer(
|
||||
options: PropertyListSerialization.ReadOptions = [])
|
||||
-> DownloadResponseSerializer<Any> {
|
||||
-> DownloadResponseSerializer<Any>
|
||||
{
|
||||
return DownloadResponseSerializer { _, response, fileURL, error in
|
||||
guard error == nil else { return .failure(error!) }
|
||||
|
||||
@@ -684,7 +701,8 @@ extension DownloadRequest {
|
||||
queue: DispatchQueue? = nil,
|
||||
options: PropertyListSerialization.ReadOptions = [],
|
||||
completionHandler: @escaping (DownloadResponse<Any>) -> Void)
|
||||
-> Self {
|
||||
-> Self
|
||||
{
|
||||
return response(
|
||||
queue: queue,
|
||||
responseSerializer: DownloadRequest.propertyListResponseSerializer(options: options),
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Result.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -253,8 +253,8 @@ extension Result {
|
||||
/// - Parameter closure: A closure that takes the success value of this instance.
|
||||
/// - Returns: This `Result` instance, unmodified.
|
||||
@discardableResult
|
||||
public func withValue(_ closure: (Value) -> Void) -> Result {
|
||||
if case let .success(value) = self { closure(value) }
|
||||
public func withValue(_ closure: (Value) throws -> Void) rethrows -> Result {
|
||||
if case let .success(value) = self { try closure(value) }
|
||||
|
||||
return self
|
||||
}
|
||||
@@ -266,8 +266,8 @@ extension Result {
|
||||
/// - Parameter closure: A closure that takes the success value of this instance.
|
||||
/// - Returns: This `Result` instance, unmodified.
|
||||
@discardableResult
|
||||
public func withError(_ closure: (Error) -> Void) -> Result {
|
||||
if case let .failure(error) = self { closure(error) }
|
||||
public func withError(_ closure: (Error) throws -> Void) rethrows -> Result {
|
||||
if case let .failure(error) = self { try closure(error) }
|
||||
|
||||
return self
|
||||
}
|
||||
@@ -279,8 +279,8 @@ extension Result {
|
||||
/// - Parameter closure: A `Void` closure.
|
||||
/// - Returns: This `Result` instance, unmodified.
|
||||
@discardableResult
|
||||
public func ifSuccess(_ closure: () -> Void) -> Result {
|
||||
if isSuccess { closure() }
|
||||
public func ifSuccess(_ closure: () throws -> Void) rethrows -> Result {
|
||||
if isSuccess { try closure() }
|
||||
|
||||
return self
|
||||
}
|
||||
@@ -292,8 +292,8 @@ extension Result {
|
||||
/// - Parameter closure: A `Void` closure.
|
||||
/// - Returns: This `Result` instance, unmodified.
|
||||
@discardableResult
|
||||
public func ifFailure(_ closure: () -> Void) -> Result {
|
||||
if isFailure { closure() }
|
||||
public func ifFailure(_ closure: () throws -> Void) rethrows -> Result {
|
||||
if isFailure { try closure() }
|
||||
|
||||
return self
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ServerTrustPolicy.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -249,6 +249,7 @@ public enum ServerTrustPolicy {
|
||||
let unspecified = SecTrustResultType.unspecified
|
||||
let proceed = SecTrustResultType.proceed
|
||||
|
||||
|
||||
isValid = result == unspecified || result == proceed
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SessionDelegate.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -255,7 +255,8 @@ extension SessionDelegate: URLSessionDelegate {
|
||||
open func urlSession(
|
||||
_ session: URLSession,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
|
||||
{
|
||||
guard sessionDidReceiveChallengeWithCompletion == nil else {
|
||||
sessionDidReceiveChallengeWithCompletion?(session, challenge, completionHandler)
|
||||
return
|
||||
@@ -314,7 +315,8 @@ extension SessionDelegate: URLSessionTaskDelegate {
|
||||
task: URLSessionTask,
|
||||
willPerformHTTPRedirection response: HTTPURLResponse,
|
||||
newRequest request: URLRequest,
|
||||
completionHandler: @escaping (URLRequest?) -> Void) {
|
||||
completionHandler: @escaping (URLRequest?) -> Void)
|
||||
{
|
||||
guard taskWillPerformHTTPRedirectionWithCompletion == nil else {
|
||||
taskWillPerformHTTPRedirectionWithCompletion?(session, task, response, request, completionHandler)
|
||||
return
|
||||
@@ -340,7 +342,8 @@ extension SessionDelegate: URLSessionTaskDelegate {
|
||||
_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
|
||||
{
|
||||
guard taskDidReceiveChallengeWithCompletion == nil else {
|
||||
taskDidReceiveChallengeWithCompletion?(session, task, challenge, completionHandler)
|
||||
return
|
||||
@@ -369,7 +372,8 @@ extension SessionDelegate: URLSessionTaskDelegate {
|
||||
open func urlSession(
|
||||
_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) {
|
||||
needNewBodyStream completionHandler: @escaping (InputStream?) -> Void)
|
||||
{
|
||||
guard taskNeedNewBodyStreamWithCompletion == nil else {
|
||||
taskNeedNewBodyStreamWithCompletion?(session, task, completionHandler)
|
||||
return
|
||||
@@ -394,7 +398,8 @@ extension SessionDelegate: URLSessionTaskDelegate {
|
||||
task: URLSessionTask,
|
||||
didSendBodyData bytesSent: Int64,
|
||||
totalBytesSent: Int64,
|
||||
totalBytesExpectedToSend: Int64) {
|
||||
totalBytesExpectedToSend: Int64)
|
||||
{
|
||||
if let taskDidSendBodyData = taskDidSendBodyData {
|
||||
taskDidSendBodyData(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend)
|
||||
} else if let delegate = self[task]?.delegate as? UploadTaskDelegate {
|
||||
@@ -507,7 +512,8 @@ extension SessionDelegate: URLSessionDataDelegate {
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
didReceive response: URLResponse,
|
||||
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
|
||||
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)
|
||||
{
|
||||
guard dataTaskDidReceiveResponseWithCompletion == nil else {
|
||||
dataTaskDidReceiveResponseWithCompletion?(session, dataTask, response, completionHandler)
|
||||
return
|
||||
@@ -530,7 +536,8 @@ extension SessionDelegate: URLSessionDataDelegate {
|
||||
open func urlSession(
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
didBecome downloadTask: URLSessionDownloadTask) {
|
||||
didBecome downloadTask: URLSessionDownloadTask)
|
||||
{
|
||||
if let dataTaskDidBecomeDownloadTask = dataTaskDidBecomeDownloadTask {
|
||||
dataTaskDidBecomeDownloadTask(session, dataTask, downloadTask)
|
||||
} else {
|
||||
@@ -566,7 +573,8 @@ extension SessionDelegate: URLSessionDataDelegate {
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
willCacheResponse proposedResponse: CachedURLResponse,
|
||||
completionHandler: @escaping (CachedURLResponse?) -> Void) {
|
||||
completionHandler: @escaping (CachedURLResponse?) -> Void)
|
||||
{
|
||||
guard dataTaskWillCacheResponseWithCompletion == nil else {
|
||||
dataTaskWillCacheResponseWithCompletion?(session, dataTask, proposedResponse, completionHandler)
|
||||
return
|
||||
@@ -600,7 +608,8 @@ extension SessionDelegate: URLSessionDownloadDelegate {
|
||||
open func urlSession(
|
||||
_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didFinishDownloadingTo location: URL) {
|
||||
didFinishDownloadingTo location: URL)
|
||||
{
|
||||
if let downloadTaskDidFinishDownloadingToURL = downloadTaskDidFinishDownloadingToURL {
|
||||
downloadTaskDidFinishDownloadingToURL(session, downloadTask, location)
|
||||
} else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate {
|
||||
@@ -623,7 +632,8 @@ extension SessionDelegate: URLSessionDownloadDelegate {
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didWriteData bytesWritten: Int64,
|
||||
totalBytesWritten: Int64,
|
||||
totalBytesExpectedToWrite: Int64) {
|
||||
totalBytesExpectedToWrite: Int64)
|
||||
{
|
||||
if let downloadTaskDidWriteData = downloadTaskDidWriteData {
|
||||
downloadTaskDidWriteData(session, downloadTask, bytesWritten, totalBytesWritten, totalBytesExpectedToWrite)
|
||||
} else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate {
|
||||
@@ -651,7 +661,8 @@ extension SessionDelegate: URLSessionDownloadDelegate {
|
||||
_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didResumeAtOffset fileOffset: Int64,
|
||||
expectedTotalBytes: Int64) {
|
||||
expectedTotalBytes: Int64)
|
||||
{
|
||||
if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset {
|
||||
downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes)
|
||||
} else if let delegate = self[downloadTask]?.delegate as? DownloadTaskDelegate {
|
||||
@@ -705,7 +716,8 @@ extension SessionDelegate: URLSessionStreamDelegate {
|
||||
_ session: URLSession,
|
||||
streamTask: URLSessionStreamTask,
|
||||
didBecome inputStream: InputStream,
|
||||
outputStream: OutputStream) {
|
||||
outputStream: OutputStream)
|
||||
{
|
||||
streamTaskDidBecomeInputAndOutputStreams?(session, streamTask, inputStream, outputStream)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SessionManager.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -166,7 +166,8 @@ open class SessionManager {
|
||||
public init(
|
||||
configuration: URLSessionConfiguration = URLSessionConfiguration.default,
|
||||
delegate: SessionDelegate = SessionDelegate(),
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager? = nil) {
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager? = nil)
|
||||
{
|
||||
self.delegate = delegate
|
||||
self.session = URLSession(configuration: configuration, delegate: delegate, delegateQueue: nil)
|
||||
|
||||
@@ -184,7 +185,8 @@ open class SessionManager {
|
||||
public init?(
|
||||
session: URLSession,
|
||||
delegate: SessionDelegate,
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager? = nil) {
|
||||
serverTrustPolicyManager: ServerTrustPolicyManager? = nil)
|
||||
{
|
||||
guard delegate === session.delegate else { return nil }
|
||||
|
||||
self.delegate = delegate
|
||||
@@ -227,7 +229,8 @@ open class SessionManager {
|
||||
parameters: Parameters? = nil,
|
||||
encoding: ParameterEncoding = URLEncoding.default,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> DataRequest {
|
||||
-> DataRequest
|
||||
{
|
||||
var originalRequest: URLRequest?
|
||||
|
||||
do {
|
||||
@@ -317,7 +320,8 @@ open class SessionManager {
|
||||
encoding: ParameterEncoding = URLEncoding.default,
|
||||
headers: HTTPHeaders? = nil,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
do {
|
||||
let urlRequest = try URLRequest(url: url, method: method, headers: headers)
|
||||
let encodedURLRequest = try encoding.encode(urlRequest, with: parameters)
|
||||
@@ -343,7 +347,8 @@ open class SessionManager {
|
||||
open func download(
|
||||
_ urlRequest: URLRequestConvertible,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
do {
|
||||
let urlRequest = try urlRequest.asURLRequest()
|
||||
return download(.request(urlRequest), to: destination)
|
||||
@@ -379,7 +384,8 @@ open class SessionManager {
|
||||
open func download(
|
||||
resumingWith resumeData: Data,
|
||||
to destination: DownloadRequest.DownloadFileDestination? = nil)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
return download(.resumeData(resumeData), to: destination)
|
||||
}
|
||||
|
||||
@@ -388,7 +394,8 @@ open class SessionManager {
|
||||
private func download(
|
||||
_ downloadable: DownloadRequest.Downloadable,
|
||||
to destination: DownloadRequest.DownloadFileDestination?)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
do {
|
||||
let task = try downloadable.task(session: session, adapter: adapter, queue: queue)
|
||||
let download = DownloadRequest(session: session, requestTask: .download(downloadable, task))
|
||||
@@ -409,7 +416,8 @@ open class SessionManager {
|
||||
_ downloadable: DownloadRequest.Downloadable?,
|
||||
to destination: DownloadRequest.DownloadFileDestination?,
|
||||
failedWith error: Error)
|
||||
-> DownloadRequest {
|
||||
-> DownloadRequest
|
||||
{
|
||||
var downloadTask: Request.RequestTask = .download(nil, nil)
|
||||
|
||||
if let downloadable = downloadable {
|
||||
@@ -450,7 +458,8 @@ open class SessionManager {
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
do {
|
||||
let urlRequest = try URLRequest(url: url, method: method, headers: headers)
|
||||
return upload(fileURL, with: urlRequest)
|
||||
@@ -495,7 +504,8 @@ open class SessionManager {
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
do {
|
||||
let urlRequest = try URLRequest(url: url, method: method, headers: headers)
|
||||
return upload(data, with: urlRequest)
|
||||
@@ -540,7 +550,8 @@ open class SessionManager {
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil)
|
||||
-> UploadRequest {
|
||||
-> UploadRequest
|
||||
{
|
||||
do {
|
||||
let urlRequest = try URLRequest(url: url, method: method, headers: headers)
|
||||
return upload(stream, with: urlRequest)
|
||||
@@ -600,7 +611,9 @@ open class SessionManager {
|
||||
to url: URLConvertible,
|
||||
method: HTTPMethod = .post,
|
||||
headers: HTTPHeaders? = nil,
|
||||
encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) {
|
||||
queue: DispatchQueue? = nil,
|
||||
encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?)
|
||||
{
|
||||
do {
|
||||
let urlRequest = try URLRequest(url: url, method: method, headers: headers)
|
||||
|
||||
@@ -608,10 +621,11 @@ open class SessionManager {
|
||||
multipartFormData: multipartFormData,
|
||||
usingThreshold: encodingMemoryThreshold,
|
||||
with: urlRequest,
|
||||
queue: queue,
|
||||
encodingCompletion: encodingCompletion
|
||||
)
|
||||
} catch {
|
||||
DispatchQueue.main.async { encodingCompletion?(.failure(error)) }
|
||||
(queue ?? DispatchQueue.main).async { encodingCompletion?(.failure(error)) }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +656,9 @@ open class SessionManager {
|
||||
multipartFormData: @escaping (MultipartFormData) -> Void,
|
||||
usingThreshold encodingMemoryThreshold: UInt64 = SessionManager.multipartFormDataEncodingMemoryThreshold,
|
||||
with urlRequest: URLRequestConvertible,
|
||||
encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?) {
|
||||
queue: DispatchQueue? = nil,
|
||||
encodingCompletion: ((MultipartFormDataEncodingResult) -> Void)?)
|
||||
{
|
||||
DispatchQueue.global(qos: .utility).async {
|
||||
let formData = MultipartFormData()
|
||||
multipartFormData(formData)
|
||||
@@ -664,7 +680,7 @@ open class SessionManager {
|
||||
streamFileURL: nil
|
||||
)
|
||||
|
||||
DispatchQueue.main.async { encodingCompletion?(encodingResult) }
|
||||
(queue ?? DispatchQueue.main).async { encodingCompletion?(encodingResult) }
|
||||
} else {
|
||||
let fileManager = FileManager.default
|
||||
let tempDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory())
|
||||
@@ -700,7 +716,7 @@ open class SessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async {
|
||||
(queue ?? DispatchQueue.main).async {
|
||||
let encodingResult = MultipartFormDataEncodingResult.success(
|
||||
request: upload,
|
||||
streamingFromDisk: true,
|
||||
@@ -720,7 +736,7 @@ open class SessionManager {
|
||||
}
|
||||
}
|
||||
|
||||
DispatchQueue.main.async { encodingCompletion?(.failure(error)) }
|
||||
(queue ?? DispatchQueue.main).async { encodingCompletion?(.failure(error)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// TaskDelegate.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -94,7 +94,8 @@ open class TaskDelegate: NSObject {
|
||||
task: URLSessionTask,
|
||||
willPerformHTTPRedirection response: HTTPURLResponse,
|
||||
newRequest request: URLRequest,
|
||||
completionHandler: @escaping (URLRequest?) -> Void) {
|
||||
completionHandler: @escaping (URLRequest?) -> Void)
|
||||
{
|
||||
var redirectRequest: URLRequest? = request
|
||||
|
||||
if let taskWillPerformHTTPRedirection = taskWillPerformHTTPRedirection {
|
||||
@@ -109,7 +110,8 @@ open class TaskDelegate: NSObject {
|
||||
_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
didReceive challenge: URLAuthenticationChallenge,
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void) {
|
||||
completionHandler: @escaping (URLSession.AuthChallengeDisposition, URLCredential?) -> Void)
|
||||
{
|
||||
var disposition: URLSession.AuthChallengeDisposition = .performDefaultHandling
|
||||
var credential: URLCredential?
|
||||
|
||||
@@ -148,7 +150,8 @@ open class TaskDelegate: NSObject {
|
||||
func urlSession(
|
||||
_ session: URLSession,
|
||||
task: URLSessionTask,
|
||||
needNewBodyStream completionHandler: @escaping (InputStream?) -> Void) {
|
||||
needNewBodyStream completionHandler: @escaping (InputStream?) -> Void)
|
||||
{
|
||||
var bodyStream: InputStream?
|
||||
|
||||
if let taskNeedNewBodyStream = taskNeedNewBodyStream {
|
||||
@@ -234,7 +237,8 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
didReceive response: URLResponse,
|
||||
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void) {
|
||||
completionHandler: @escaping (URLSession.ResponseDisposition) -> Void)
|
||||
{
|
||||
var disposition: URLSession.ResponseDisposition = .allow
|
||||
|
||||
expectedContentLength = response.expectedContentLength
|
||||
@@ -249,7 +253,8 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
|
||||
func urlSession(
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
didBecome downloadTask: URLSessionDownloadTask) {
|
||||
didBecome downloadTask: URLSessionDownloadTask)
|
||||
{
|
||||
dataTaskDidBecomeDownloadTask?(session, dataTask, downloadTask)
|
||||
}
|
||||
|
||||
@@ -282,7 +287,8 @@ class DataTaskDelegate: TaskDelegate, URLSessionDataDelegate {
|
||||
_ session: URLSession,
|
||||
dataTask: URLSessionDataTask,
|
||||
willCacheResponse proposedResponse: CachedURLResponse,
|
||||
completionHandler: @escaping (CachedURLResponse?) -> Void) {
|
||||
completionHandler: @escaping (CachedURLResponse?) -> Void)
|
||||
{
|
||||
var cachedResponse: CachedURLResponse? = proposedResponse
|
||||
|
||||
if let dataTaskWillCacheResponse = dataTaskWillCacheResponse {
|
||||
@@ -337,7 +343,8 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
|
||||
func urlSession(
|
||||
_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didFinishDownloadingTo location: URL) {
|
||||
didFinishDownloadingTo location: URL)
|
||||
{
|
||||
temporaryURL = location
|
||||
|
||||
guard
|
||||
@@ -372,7 +379,8 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didWriteData bytesWritten: Int64,
|
||||
totalBytesWritten: Int64,
|
||||
totalBytesExpectedToWrite: Int64) {
|
||||
totalBytesExpectedToWrite: Int64)
|
||||
{
|
||||
if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() }
|
||||
|
||||
if let downloadTaskDidWriteData = downloadTaskDidWriteData {
|
||||
@@ -397,7 +405,8 @@ class DownloadTaskDelegate: TaskDelegate, URLSessionDownloadDelegate {
|
||||
_ session: URLSession,
|
||||
downloadTask: URLSessionDownloadTask,
|
||||
didResumeAtOffset fileOffset: Int64,
|
||||
expectedTotalBytes: Int64) {
|
||||
expectedTotalBytes: Int64)
|
||||
{
|
||||
if let downloadTaskDidResumeAtOffset = downloadTaskDidResumeAtOffset {
|
||||
downloadTaskDidResumeAtOffset(session, downloadTask, fileOffset, expectedTotalBytes)
|
||||
} else {
|
||||
@@ -439,7 +448,8 @@ class UploadTaskDelegate: DataTaskDelegate {
|
||||
task: URLSessionTask,
|
||||
didSendBodyData bytesSent: Int64,
|
||||
totalBytesSent: Int64,
|
||||
totalBytesExpectedToSend: Int64) {
|
||||
totalBytesExpectedToSend: Int64)
|
||||
{
|
||||
if initialResponseTime == nil { initialResponseTime = CFAbsoluteTimeGetCurrent() }
|
||||
|
||||
if let taskDidSendBodyData = taskDidSendBodyData {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Timeline.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -64,7 +64,8 @@ public struct Timeline {
|
||||
requestStartTime: CFAbsoluteTime = 0.0,
|
||||
initialResponseTime: CFAbsoluteTime = 0.0,
|
||||
requestCompletedTime: CFAbsoluteTime = 0.0,
|
||||
serializationCompletedTime: CFAbsoluteTime = 0.0) {
|
||||
serializationCompletedTime: CFAbsoluteTime = 0.0)
|
||||
{
|
||||
self.requestStartTime = requestStartTime
|
||||
self.initialResponseTime = initialResponseTime
|
||||
self.requestCompletedTime = requestCompletedTime
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Validation.swift
|
||||
//
|
||||
// Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
// Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
@@ -94,7 +94,8 @@ extension Request {
|
||||
statusCode acceptableStatusCodes: S,
|
||||
response: HTTPURLResponse)
|
||||
-> ValidationResult
|
||||
where S.Iterator.Element == Int {
|
||||
where S.Iterator.Element == Int
|
||||
{
|
||||
if acceptableStatusCodes.contains(response.statusCode) {
|
||||
return .success
|
||||
} else {
|
||||
@@ -110,7 +111,8 @@ extension Request {
|
||||
response: HTTPURLResponse,
|
||||
data: Data?)
|
||||
-> ValidationResult
|
||||
where S.Iterator.Element == String {
|
||||
where S.Iterator.Element == String
|
||||
{
|
||||
guard let data = data, data.count > 0 else { return .success }
|
||||
|
||||
guard
|
||||
@@ -217,7 +219,10 @@ extension DataRequest {
|
||||
/// - returns: The request.
|
||||
@discardableResult
|
||||
public func validate() -> Self {
|
||||
return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes)
|
||||
let contentTypes = { [unowned self] in
|
||||
self.acceptableContentTypes
|
||||
}
|
||||
return validate(statusCode: acceptableStatusCodes).validate(contentType: contentTypes())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,6 +313,9 @@ extension DownloadRequest {
|
||||
/// - returns: The request.
|
||||
@discardableResult
|
||||
public func validate() -> Self {
|
||||
return validate(statusCode: self.acceptableStatusCodes).validate(contentType: self.acceptableContentTypes)
|
||||
let contentTypes = { [unowned self] in
|
||||
self.acceptableContentTypes
|
||||
}
|
||||
return validate(statusCode: acceptableStatusCodes).validate(contentType: contentTypes())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
"osx": "10.11",
|
||||
"tvos": "9.0"
|
||||
},
|
||||
"version": "0.0.1",
|
||||
"version": "1.0.0",
|
||||
"source": {
|
||||
"git": "git@github.com:OpenAPITools/openapi-generator.git",
|
||||
"tag": "v1.0.0"
|
||||
@@ -17,7 +17,7 @@
|
||||
"source_files": "PetstoreClient/Classes/**/*.swift",
|
||||
"dependencies": {
|
||||
"Alamofire": [
|
||||
"~> 4.7.0"
|
||||
"~> 4.9.0"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
PODS:
|
||||
- Alamofire (4.7.3)
|
||||
- PetstoreClient (0.0.1):
|
||||
- Alamofire (~> 4.7.0)
|
||||
- Alamofire (4.9.0)
|
||||
- PetstoreClient (1.0.0):
|
||||
- Alamofire (~> 4.9.0)
|
||||
|
||||
DEPENDENCIES:
|
||||
- PetstoreClient (from `../`)
|
||||
@@ -15,9 +15,9 @@ EXTERNAL SOURCES:
|
||||
:path: "../"
|
||||
|
||||
SPEC CHECKSUMS:
|
||||
Alamofire: c7287b6e5d7da964a70935e5db17046b7fde6568
|
||||
PetstoreClient: ed26185215a5241fa4e937e806321d611f3d0c30
|
||||
Alamofire: afc3e7c6db61476cb45cdd23fed06bad03bbc321
|
||||
PetstoreClient: e5c71b862a32097342e341f7088805bbfc033a3e
|
||||
|
||||
PODFILE CHECKSUM: cedb3058b02f4776d7c31f6d92ae2f674fdf424d
|
||||
|
||||
COCOAPODS: 1.5.3
|
||||
COCOAPODS: 1.6.1
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -15,7 +15,7 @@
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>4.4.0</string>
|
||||
<string>4.9.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
@@ -1,6 +1,6 @@
|
||||
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/Alamofire
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,7 +1,7 @@
|
||||
CONFIGURATION_BUILD_DIR = ${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_ROOT = ${SRCROOT}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -3,7 +3,7 @@ This application makes use of the following third party libraries:
|
||||
|
||||
## Alamofire
|
||||
|
||||
Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
</dict>
|
||||
<dict>
|
||||
<key>FooterText</key>
|
||||
<string>Copyright (c) 2014-2018 Alamofire Software Foundation (http://alamofire.org/)
|
||||
<string>Copyright (c) 2014 Alamofire Software Foundation (http://alamofire.org/)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -3,10 +3,15 @@ set -e
|
||||
set -u
|
||||
set -o pipefail
|
||||
|
||||
function on_error {
|
||||
echo "$(realpath -mq "${0}"):$1: error: Unexpected failure"
|
||||
}
|
||||
trap 'on_error $LINENO' ERR
|
||||
|
||||
if [ -z ${FRAMEWORKS_FOLDER_PATH+x} ]; then
|
||||
# If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
|
||||
# frameworks to, so exit 0 (signalling the script phase was successful).
|
||||
exit 0
|
||||
# If FRAMEWORKS_FOLDER_PATH is not set, then there's nowhere for us to copy
|
||||
# frameworks to, so exit 0 (signalling the script phase was successful).
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
@@ -36,8 +41,8 @@ install_framework()
|
||||
local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}"
|
||||
|
||||
if [ -L "${source}" ]; then
|
||||
echo "Symlinked..."
|
||||
source="$(readlink "${source}")"
|
||||
echo "Symlinked..."
|
||||
source="$(readlink "${source}")"
|
||||
fi
|
||||
|
||||
# Use filter instead of exclude so missing patterns don't throw errors.
|
||||
@@ -47,8 +52,13 @@ install_framework()
|
||||
local basename
|
||||
basename="$(basename -s .framework "$1")"
|
||||
binary="${destination}/${basename}.framework/${basename}"
|
||||
|
||||
if ! [ -r "$binary" ]; then
|
||||
binary="${destination}/${basename}"
|
||||
elif [ -L "${binary}" ]; then
|
||||
echo "Destination binary is symlinked..."
|
||||
dirname="$(dirname "${binary}")"
|
||||
binary="${dirname}/$(readlink "${binary}")"
|
||||
fi
|
||||
|
||||
# Strip invalid architectures so "fat" simulator / device frameworks work on device
|
||||
@@ -62,7 +72,7 @@ install_framework()
|
||||
# Embed linked Swift runtime libraries. No longer necessary as of Xcode 7.
|
||||
if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then
|
||||
local swift_runtime_libs
|
||||
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]})
|
||||
swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u)
|
||||
for lib in $swift_runtime_libs; do
|
||||
echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\""
|
||||
rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}"
|
||||
@@ -101,8 +111,8 @@ install_dsym() {
|
||||
|
||||
# Signs a framework with the provided identity
|
||||
code_sign_if_enabled() {
|
||||
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
|
||||
# Use the current code_sign_identitiy
|
||||
if [ -n "${EXPANDED_CODE_SIGN_IDENTITY:-}" -a "${CODE_SIGNING_REQUIRED:-}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then
|
||||
# Use the current code_sign_identity
|
||||
echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}"
|
||||
local code_sign_cmd="/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS:-} --preserve-metadata=identifier,entitlements '$1'"
|
||||
|
||||
@@ -131,7 +141,7 @@ strip_invalid_archs() {
|
||||
for arch in $binary_archs; do
|
||||
if ! [[ "${ARCHS}" == *"$arch"* ]]; then
|
||||
# Strip non-valid architectures in-place
|
||||
lipo -remove "$arch" -output "$binary" "$binary" || exit 1
|
||||
lipo -remove "$arch" -output "$binary" "$binary"
|
||||
stripped="$stripped $arch"
|
||||
fi
|
||||
done
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "PetstoreClient"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "PetstoreClient"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS"
|
||||
OTHER_SWIFT_FLAGS = $(inherited) -D COCOAPODS
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>${EXECUTABLE_NAME}</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>${PRODUCT_BUNDLE_IDENTIFIER}</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleName</key>
|
||||
<string>${PRODUCT_NAME}</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0.0</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>${CURRENT_PROJECT_VERSION}</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string></string>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,7 +1,8 @@
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "PetstoreClient"
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
FRAMEWORK_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient"
|
||||
GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1
|
||||
HEADER_SEARCH_PATHS = $(inherited) "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks'
|
||||
OTHER_CFLAGS = $(inherited) -iquote "${PODS_CONFIGURATION_BUILD_DIR}/Alamofire/Alamofire.framework/Headers" -iquote "${PODS_CONFIGURATION_BUILD_DIR}/PetstoreClient/PetstoreClient.framework/Headers"
|
||||
OTHER_LDFLAGS = $(inherited) -framework "Alamofire" -framework "PetstoreClient"
|
||||
PODS_BUILD_DIR = ${BUILD_DIR}
|
||||
PODS_CONFIGURATION_BUILD_DIR = ${PODS_BUILD_DIR}/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)
|
||||
PODS_PODFILE_DIR_PATH = ${SRCROOT}/.
|
||||
|
||||
@@ -293,7 +293,7 @@
|
||||
inputFileListPaths = (
|
||||
);
|
||||
inputPaths = (
|
||||
"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-frameworks.sh",
|
||||
"${PODS_ROOT}/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-frameworks.sh",
|
||||
"${BUILT_PRODUCTS_DIR}/Alamofire/Alamofire.framework",
|
||||
"${BUILT_PRODUCTS_DIR}/PetstoreClient/PetstoreClient.framework",
|
||||
);
|
||||
@@ -306,7 +306,7 @@
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
shellPath = /bin/sh;
|
||||
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-frameworks.sh\"\n";
|
||||
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-SwaggerClient/Pods-SwaggerClient-frameworks.sh\"\n";
|
||||
showEnvVarsInLog = 0;
|
||||
};
|
||||
/* End PBXShellScriptBuildPhase section */
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
xcodebuild clean build build-for-testing -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -destination "platform=iOS Simulator,name=iPhone 8,OS=12.2" && xcodebuild test-without-building -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -destination "platform=iOS Simulator,name=iPhone 8,OS=12.2" | xcpretty && exit ${PIPESTATUS[0]}
|
||||
xcodebuild clean build build-for-testing -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -destination "platform=iOS Simulator,name=iPhone 8,OS=13.0" && xcodebuild test-without-building -workspace "SwaggerClient.xcworkspace" -scheme "SwaggerClient" -destination "platform=iOS Simulator,name=iPhone 8,OS=13.0" | xcpretty && exit ${PIPESTATUS[0]}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
import Foundation
|
||||
|
||||
public struct APIHelper {
|
||||
public static func rejectNil(_ source: [String:Any?]) -> [String:Any]? {
|
||||
public static func rejectNil(_ source: [String: Any?]) -> [String: Any]? {
|
||||
let destination = source.reduce(into: [String: Any]()) { (result, item) in
|
||||
if let value = item.value {
|
||||
result[item.key] = value
|
||||
@@ -20,17 +20,17 @@ public struct APIHelper {
|
||||
return destination
|
||||
}
|
||||
|
||||
public static func rejectNilHeaders(_ source: [String:Any?]) -> [String:String] {
|
||||
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?> {
|
||||
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)"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String:Any]? {
|
||||
public static func convertBoolToString(_ source: [String: Any]?) -> [String: Any]? {
|
||||
guard let source = source else {
|
||||
return nil
|
||||
}
|
||||
@@ -52,7 +52,7 @@ public struct APIHelper {
|
||||
return source
|
||||
}
|
||||
|
||||
public static func mapValuesToQueryItems(_ source: [String:Any?]) -> [URLQueryItem]? {
|
||||
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?> {
|
||||
let value = collection.filter({ $0 != nil }).map({"\($0!)"}).joined(separator: ",")
|
||||
@@ -68,4 +68,3 @@ public struct APIHelper {
|
||||
return destination
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,22 +9,22 @@ import Foundation
|
||||
open class PetstoreClientAPI {
|
||||
public static var basePath = "http://petstore.swagger.io:80/v2"
|
||||
public static var credential: URLCredential?
|
||||
public static var customHeaders: [String:String] = [:]
|
||||
public static var customHeaders: [String: String] = [:]
|
||||
public static var requestBuilderFactory: RequestBuilderFactory = AlamofireRequestBuilderFactory()
|
||||
}
|
||||
|
||||
open class RequestBuilder<T> {
|
||||
var credential: URLCredential?
|
||||
var headers: [String:String]
|
||||
public let parameters: [String:Any]?
|
||||
var headers: [String: String]
|
||||
public let parameters: [String: Any]?
|
||||
public let isBody: Bool
|
||||
public let method: String
|
||||
public let URLString: String
|
||||
|
||||
/// Optional block to obtain a reference to the request's progress instance when available.
|
||||
public var onProgressReady: ((Progress) -> ())?
|
||||
public var onProgressReady: ((Progress) -> Void)?
|
||||
|
||||
required public init(method: String, URLString: String, parameters: [String:Any]?, isBody: Bool, headers: [String:String] = [:]) {
|
||||
required public init(method: String, URLString: String, parameters: [String: Any]?, isBody: Bool, headers: [String: String] = [:]) {
|
||||
self.method = method
|
||||
self.URLString = URLString
|
||||
self.parameters = parameters
|
||||
@@ -34,7 +34,7 @@ open class RequestBuilder<T> {
|
||||
addHeaders(PetstoreClientAPI.customHeaders)
|
||||
}
|
||||
|
||||
open func addHeaders(_ aHeaders:[String:String]) {
|
||||
open func addHeaders(_ aHeaders: [String: String]) {
|
||||
for (header, value) in aHeaders {
|
||||
headers[header] = value
|
||||
}
|
||||
@@ -57,5 +57,5 @@ open class RequestBuilder<T> {
|
||||
|
||||
public protocol RequestBuilderFactory {
|
||||
func getNonDecodableBuilder<T>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T:Decodable>() -> RequestBuilder<T>.Type
|
||||
func getBuilder<T: Decodable>() -> RequestBuilder<T>.Type
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class AnotherFakeAPI {
|
||||
/**
|
||||
To test special tags
|
||||
@@ -17,7 +15,7 @@ open class AnotherFakeAPI {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func call123testSpecialTags(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func call123testSpecialTags(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
call123testSpecialTagsWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeAPI {
|
||||
/**
|
||||
creates an XmlItem
|
||||
@@ -17,8 +15,8 @@ open class FakeAPI {
|
||||
- parameter xmlItem: (body) XmlItem Body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func createXmlItem(xmlItem: XmlItem, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
createXmlItemWithRequestBuilder(xmlItem: xmlItem).execute { (response, error) -> Void in
|
||||
open class func createXmlItem(xmlItem: XmlItem, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
createXmlItemWithRequestBuilder(xmlItem: xmlItem).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -51,7 +49,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input boolean as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterBooleanSerialize(body: Bool? = nil, completion: @escaping ((_ data: Bool?, _ error: Error?) -> Void)) {
|
||||
fakeOuterBooleanSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -80,7 +78,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input composite as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterCompositeSerialize(body: OuterComposite? = nil, completion: @escaping ((_ data: OuterComposite?, _ error: Error?) -> Void)) {
|
||||
fakeOuterCompositeSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -109,7 +107,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input number as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterNumberSerialize(body: Double? = nil, completion: @escaping ((_ data: Double?, _ error: Error?) -> Void)) {
|
||||
fakeOuterNumberSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -138,7 +136,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) Input string as post body (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?,_ error: Error?) -> Void)) {
|
||||
open class func fakeOuterStringSerialize(body: String? = nil, completion: @escaping ((_ data: String?, _ error: Error?) -> Void)) {
|
||||
fakeOuterStringSerializeWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -167,8 +165,8 @@ open class FakeAPI {
|
||||
- parameter body: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func testBodyWithFileSchema(body: FileSchemaTestClass, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithFileSchemaWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -201,8 +199,8 @@ open class FakeAPI {
|
||||
- parameter body: (body)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testBodyWithQueryParams(query: String, body: User, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { (response, error) -> Void in
|
||||
open class func testBodyWithQueryParams(query: String, body: User, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testBodyWithQueryParamsWithRequestBuilder(query: query, body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -238,7 +236,7 @@ open class FakeAPI {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func testClientModel(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClientModelWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -282,8 +280,8 @@ open class FakeAPI {
|
||||
- parameter callback: (form) None (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (response, error) -> Void in
|
||||
open class func testEndpointParameters(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testEndpointParametersWithRequestBuilder(number: number, double: double, patternWithoutDelimiter: patternWithoutDelimiter, byte: byte, integer: integer, int32: int32, int64: int64, float: float, string: string, binary: binary, date: date, dateTime: dateTime, password: password, callback: callback).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -318,7 +316,7 @@ open class FakeAPI {
|
||||
open class func testEndpointParametersWithRequestBuilder(number: Double, double: Double, patternWithoutDelimiter: String, byte: Data, integer: Int? = nil, int32: Int? = nil, int64: Int64? = nil, float: Float? = nil, string: String? = nil, binary: URL? = nil, date: Date? = nil, dateTime: Date? = nil, password: String? = nil, callback: String? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"integer": integer?.encodeToJSON(),
|
||||
"int32": int32?.encodeToJSON(),
|
||||
"int64": int64?.encodeToJSON(),
|
||||
@@ -337,7 +335,7 @@ open class FakeAPI {
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -425,8 +423,8 @@ open class FakeAPI {
|
||||
- parameter enumFormString: (form) Form parameter enum test (string) (optional, default to .-efg)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (response, error) -> Void in
|
||||
open class func testEnumParameters(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testEnumParametersWithRequestBuilder(enumHeaderStringArray: enumHeaderStringArray, enumHeaderString: enumHeaderString, enumQueryStringArray: enumQueryStringArray, enumQueryString: enumQueryString, enumQueryInteger: enumQueryInteger, enumQueryDouble: enumQueryDouble, enumFormStringArray: enumFormStringArray, enumFormString: enumFormString).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -452,19 +450,19 @@ open class FakeAPI {
|
||||
open class func testEnumParametersWithRequestBuilder(enumHeaderStringArray: [String]? = nil, enumHeaderString: EnumHeaderString_testEnumParameters? = nil, enumQueryStringArray: [String]? = nil, enumQueryString: EnumQueryString_testEnumParameters? = nil, enumQueryInteger: EnumQueryInteger_testEnumParameters? = nil, enumQueryDouble: EnumQueryDouble_testEnumParameters? = nil, enumFormStringArray: [String]? = nil, enumFormString: EnumFormString_testEnumParameters? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"enum_form_string_array": enumFormStringArray,
|
||||
"enum_form_string": enumFormString?.rawValue
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_string_array": enumQueryStringArray,
|
||||
"enum_query_string": enumQueryString?.rawValue,
|
||||
"enum_query_integer": enumQueryInteger?.rawValue,
|
||||
"enum_query_double": enumQueryDouble?.rawValue
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
@@ -489,8 +487,8 @@ open class FakeAPI {
|
||||
- parameter int64Group: (query) Integer in group parameters (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { (response, error) -> Void in
|
||||
open class func testGroupParameters(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testGroupParametersWithRequestBuilder(requiredStringGroup: requiredStringGroup, requiredBooleanGroup: requiredBooleanGroup, requiredInt64Group: requiredInt64Group, stringGroup: stringGroup, booleanGroup: booleanGroup, int64Group: int64Group).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -514,13 +512,13 @@ open class FakeAPI {
|
||||
open class func testGroupParametersWithRequestBuilder(requiredStringGroup: Int, requiredBooleanGroup: Bool, requiredInt64Group: Int64, stringGroup: Int? = nil, booleanGroup: Bool? = nil, int64Group: Int64? = nil) -> RequestBuilder<Void> {
|
||||
let path = "/fake"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"required_string_group": requiredStringGroup.encodeToJSON(),
|
||||
"required_int64_group": requiredInt64Group.encodeToJSON(),
|
||||
"string_group": stringGroup?.encodeToJSON(),
|
||||
"int64_group": int64Group?.encodeToJSON()
|
||||
])
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
@@ -540,8 +538,8 @@ open class FakeAPI {
|
||||
- parameter param: (body) request body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(param: [String:String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (response, error) -> Void in
|
||||
open class func testInlineAdditionalProperties(param: [String: String], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -556,7 +554,7 @@ open class FakeAPI {
|
||||
- parameter param: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String:String]) -> RequestBuilder<Void> {
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: [String: String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: param)
|
||||
@@ -575,8 +573,8 @@ open class FakeAPI {
|
||||
- parameter param2: (form) field2
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (response, error) -> Void in
|
||||
open class func testJsonFormData(param: String, param2: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testJsonFormDataWithRequestBuilder(param: param, param2: param2).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -595,14 +593,14 @@ open class FakeAPI {
|
||||
open class func testJsonFormDataWithRequestBuilder(param: String, param2: String) -> RequestBuilder<Void> {
|
||||
let path = "/fake/jsonFormData"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"param": param,
|
||||
"param2": param2
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -619,8 +617,8 @@ open class FakeAPI {
|
||||
- parameter context: (query)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testQueryParameterCollectionFormat(pipe: [String], ioutil: [String], http: [String], url: [String], context: [String], completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
testQueryParameterCollectionFormatWithRequestBuilder(pipe: pipe, ioutil: ioutil, http: http, url: url, context: context).execute { (response, error) -> Void in
|
||||
open class func testQueryParameterCollectionFormat(pipe: [String], ioutil: [String], http: [String], url: [String], context: [String], completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
testQueryParameterCollectionFormatWithRequestBuilder(pipe: pipe, ioutil: ioutil, http: http, url: url, context: context).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -642,14 +640,14 @@ open class FakeAPI {
|
||||
open class func testQueryParameterCollectionFormatWithRequestBuilder(pipe: [String], ioutil: [String], http: [String], url: [String], context: [String]) -> RequestBuilder<Void> {
|
||||
let path = "/fake/test-query-paramters"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"pipe": pipe,
|
||||
"ioutil": ioutil,
|
||||
"http": http,
|
||||
"url": url,
|
||||
"pipe": pipe,
|
||||
"ioutil": ioutil,
|
||||
"http": http,
|
||||
"url": url,
|
||||
"context": context
|
||||
])
|
||||
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class FakeClassnameTags123API {
|
||||
/**
|
||||
To test class name in snake case
|
||||
@@ -17,7 +15,7 @@ open class FakeClassnameTags123API {
|
||||
- parameter body: (body) client model
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?,_ error: Error?) -> Void)) {
|
||||
open class func testClassname(body: Client, completion: @escaping ((_ data: Client?, _ error: Error?) -> Void)) {
|
||||
testClassnameWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class PetAPI {
|
||||
/**
|
||||
Add a new pet to the store
|
||||
@@ -17,8 +15,8 @@ open class PetAPI {
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func addPet(body: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func addPet(body: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
addPetWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -55,8 +53,8 @@ open class PetAPI {
|
||||
- parameter apiKey: (header) (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (response, error) -> Void in
|
||||
open class func deletePet(petId: Int64, apiKey: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deletePetWithRequestBuilder(petId: petId, apiKey: apiKey).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -81,8 +79,8 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
let nillableHeaders: [String: Any?] = [
|
||||
"api_key": apiKey
|
||||
@@ -109,7 +107,7 @@ open class PetAPI {
|
||||
- parameter status: (query) Status values that need to be considered for filter
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
open class func findPetsByStatus(status: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByStatusWithRequestBuilder(status: status).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -128,8 +126,8 @@ open class PetAPI {
|
||||
open class func findPetsByStatusWithRequestBuilder(status: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByStatus"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"status": status
|
||||
@@ -146,7 +144,7 @@ open class PetAPI {
|
||||
- parameter tags: (query) Tags to filter by
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?,_ error: Error?) -> Void)) {
|
||||
open class func findPetsByTags(tags: [String], completion: @escaping ((_ data: [Pet]?, _ error: Error?) -> Void)) {
|
||||
findPetsByTagsWithRequestBuilder(tags: tags).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -165,8 +163,8 @@ open class PetAPI {
|
||||
open class func findPetsByTagsWithRequestBuilder(tags: [String]) -> RequestBuilder<[Pet]> {
|
||||
let path = "/pet/findByTags"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
var url = URLComponents(string: URLString)
|
||||
url?.queryItems = APIHelper.mapValuesToQueryItems([
|
||||
"tags": tags
|
||||
@@ -183,7 +181,7 @@ open class PetAPI {
|
||||
- parameter petId: (path) ID of pet to return
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?,_ error: Error?) -> Void)) {
|
||||
open class func getPetById(petId: Int64, completion: @escaping ((_ data: Pet?, _ error: Error?) -> Void)) {
|
||||
getPetByIdWithRequestBuilder(petId: petId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -205,8 +203,8 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Pet>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -220,8 +218,8 @@ open class PetAPI {
|
||||
- parameter body: (body) Pet object that needs to be added to the store
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePet(body: Pet, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
open class func updatePet(body: Pet, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithRequestBuilder(body: body).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -259,8 +257,8 @@ open class PetAPI {
|
||||
- parameter status: (form) Updated status of the pet (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (response, error) -> Void in
|
||||
open class func updatePetWithForm(petId: Int64, name: String? = nil, status: String? = nil, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
updatePetWithFormWithRequestBuilder(petId: petId, name: name, status: status).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -286,14 +284,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"name": name,
|
||||
"status": status
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -309,7 +307,7 @@ open class PetAPI {
|
||||
- parameter file: (form) file to upload (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
open class func uploadFile(petId: Int64, additionalMetadata: String? = nil, file: URL? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequestBuilder(petId: petId, additionalMetadata: additionalMetadata, file: file).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -332,14 +330,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"file": file
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -355,7 +353,7 @@ open class PetAPI {
|
||||
- parameter additionalMetadata: (form) Additional data to pass to server (optional)
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?,_ error: Error?) -> Void)) {
|
||||
open class func uploadFileWithRequiredFile(petId: Int64, requiredFile: URL, additionalMetadata: String? = nil, completion: @escaping ((_ data: ApiResponse?, _ error: Error?) -> Void)) {
|
||||
uploadFileWithRequiredFileWithRequestBuilder(petId: petId, requiredFile: requiredFile, additionalMetadata: additionalMetadata).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -378,14 +376,14 @@ open class PetAPI {
|
||||
let petIdPostEscape = petIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{petId}", with: petIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let formParams: [String:Any?] = [
|
||||
let formParams: [String: Any?] = [
|
||||
"additionalMetadata": additionalMetadata,
|
||||
"requiredFile": requiredFile
|
||||
]
|
||||
|
||||
let nonNullParameters = APIHelper.rejectNil(formParams)
|
||||
let parameters = APIHelper.convertBoolToString(nonNullParameters)
|
||||
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<ApiResponse>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
import Foundation
|
||||
import Alamofire
|
||||
|
||||
|
||||
|
||||
open class StoreAPI {
|
||||
/**
|
||||
Delete purchase order by ID
|
||||
@@ -17,8 +15,8 @@ open class StoreAPI {
|
||||
- parameter orderId: (path) ID of the order that needs to be deleted
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?,_ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
open class func deleteOrder(orderId: String, completion: @escaping ((_ data: Void?, _ error: Error?) -> Void)) {
|
||||
deleteOrderWithRequestBuilder(orderId: orderId).execute { (_, error) -> Void in
|
||||
if error == nil {
|
||||
completion((), error)
|
||||
} else {
|
||||
@@ -40,8 +38,8 @@ open class StoreAPI {
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getNonDecodableBuilder()
|
||||
@@ -54,7 +52,7 @@ open class StoreAPI {
|
||||
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getInventory(completion: @escaping ((_ data: [String:Int]?,_ error: Error?) -> Void)) {
|
||||
open class func getInventory(completion: @escaping ((_ data: [String: Int]?, _ error: Error?) -> Void)) {
|
||||
getInventoryWithRequestBuilder().execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -69,14 +67,14 @@ open class StoreAPI {
|
||||
- name: api_key
|
||||
- returns: RequestBuilder<[String:Int]>
|
||||
*/
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String:Int]> {
|
||||
open class func getInventoryWithRequestBuilder() -> RequestBuilder<[String: Int]> {
|
||||
let path = "/store/inventory"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<[String:Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
let requestBuilder: RequestBuilder<[String: Int]>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false)
|
||||
}
|
||||
@@ -87,7 +85,7 @@ open class StoreAPI {
|
||||
- parameter orderId: (path) ID of pet that needs to be fetched
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
open class func getOrderById(orderId: Int64, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
getOrderByIdWithRequestBuilder(orderId: orderId).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
@@ -106,8 +104,8 @@ open class StoreAPI {
|
||||
let orderIdPostEscape = orderIdPreEscape.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""
|
||||
path = path.replacingOccurrences(of: "{order_id}", with: orderIdPostEscape, options: .literal, range: nil)
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters: [String:Any]? = nil
|
||||
|
||||
let parameters: [String: Any]? = nil
|
||||
|
||||
let url = URLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Order>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
@@ -121,7 +119,7 @@ open class StoreAPI {
|
||||
- parameter body: (body) order placed for purchasing the pet
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?,_ error: Error?) -> Void)) {
|
||||
open class func placeOrder(body: Order, completion: @escaping ((_ data: Order?, _ error: Error?) -> Void)) {
|
||||
placeOrderWithRequestBuilder(body: body).execute { (response, error) -> Void in
|
||||
completion(response?.body, error)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user