@@ -13,34 +13,18 @@ open class SwaggerClientAPI {
1313 open static var requestBuilderFactory : RequestBuilderFactory = AlamofireRequestBuilderFactory ( )
1414}
1515
16- open class APIBase {
17- func toParameters( _ encodable: JSONEncodable ? ) -> [ String : Any ] ? {
18- let encoded : Any ? = encodable? . encodeToJSON ( )
19-
20- if encoded! is [ Any ] {
21- var dictionary = [ String: Any] ( )
22- for (index, item) in ( encoded as! [ Any ] ) . enumerated ( ) {
23- dictionary [ " \( index) " ] = item
24- }
25- return dictionary
26- } else {
27- return encoded as? [ String : Any ]
28- }
29- }
30- }
31-
3216open class RequestBuilder < T> {
3317 var credential : URLCredential ?
3418 var headers : [ String : String ]
35- public let parameters : Any ?
36- public let isBody : Bool
37- public let method : String
38- public let URLString : String
19+ let parameters : [ String : Any ] ?
20+ let isBody : Bool
21+ let method : String
22+ let URLString : String
3923
4024 /// Optional block to obtain a reference to the request's progress instance when available.
4125 public var onProgressReady : ( ( Progress ) -> ( ) ) ?
4226
43- required public init ( method: String , URLString: String , parameters: Any ? , isBody: Bool , headers: [ String : String ] = [ : ] ) {
27+ required public init ( method: String , URLString: String , parameters: [ String : Any ] ? , isBody: Bool , headers: [ String : String ] = [ : ] ) {
4428 self . method = method
4529 self . URLString = URLString
4630 self . parameters = parameters
@@ -52,13 +36,13 @@ open class RequestBuilder<T> {
5236
5337 open func addHeaders( _ aHeaders: [ String : String ] ) {
5438 for (header, value) in aHeaders {
55- addHeader ( name : header, value : value)
39+ headers [ header] = value
5640 }
5741 }
5842
59- open func execute( _ completion: @escaping ( _ response: Response < T > ? , _ error: ErrorResponse ? ) -> Void ) { }
43+ open func execute( _ completion: @escaping ( _ response: Response < T > ? , _ error: Error ? ) -> Void ) { }
6044
61- @ discardableResult public func addHeader( name: String , value: String ) -> Self {
45+ public func addHeader( name: String , value: String ) -> Self {
6246 if !value. isEmpty {
6347 headers [ name] = value
6448 }
@@ -72,6 +56,6 @@ open class RequestBuilder<T> {
7256}
7357
7458public protocol RequestBuilderFactory {
75- func getBuilder< T> ( ) -> RequestBuilder < T > . Type
59+ func getNonDecodableBuilder< T> ( ) -> RequestBuilder < T > . Type
60+ func getBuilder< T: Decodable > ( ) -> RequestBuilder < T > . Type
7661}
77-
0 commit comments