forked from loafle/openapi-generator-original
[Swift4]Update templates for swift 4 (#6921)
* update versions of dependencies on swift4 and swift3 * change syntax for swift4 * run petstore script * change enum case from UpperCamel to lowerCamel * remove unneeded break statements * avoid wrapping conditionals in parentheses * avoid force casting * run pod update on petstore/swift4/rxswift * update project for swift 4 * run swift4-petstore-all.sh * fix compile error * avoid use iso8601 date strategy for encoder / decoder * resolve file references
This commit is contained in:
committed by
William Cheng
parent
b06ccec11e
commit
a5e4abe5ec
@@ -1,2 +1,2 @@
|
||||
github "Alamofire/Alamofire" >= 3.1.0
|
||||
github "mxcl/PromiseKit" >=1.5.3
|
||||
github "Alamofire/Alamofire" ~> 4.5
|
||||
github "mxcl/PromiseKit" ~> 4.4
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// AnotherfakeAPI.swift
|
||||
// AnotherFakeAPI.swift
|
||||
//
|
||||
// Generated by swagger-codegen
|
||||
// https://github.com/swagger-api/swagger-codegen
|
||||
@@ -10,7 +10,7 @@ import Alamofire
|
||||
import PromiseKit
|
||||
|
||||
|
||||
open class AnotherfakeAPI: APIBase {
|
||||
open class AnotherFakeAPI: APIBase {
|
||||
/**
|
||||
To test special tags
|
||||
- parameter body: (body) client model
|
||||
|
||||
@@ -510,6 +510,54 @@ open class FakeAPI: APIBase {
|
||||
return requestBuilder.init(method: "GET", URLString: (url?.string ?? URLString), parameters: parameters, isBody: false, headers: headerParameters)
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- parameter param: (body) request body
|
||||
- parameter completion: completion handler to receive the data and the error objects
|
||||
*/
|
||||
open class func testInlineAdditionalProperties(param: Any, completion: @escaping ((_ error: ErrorResponse?) -> Void)) {
|
||||
testInlineAdditionalPropertiesWithRequestBuilder(param: param).execute { (response, error) -> Void in
|
||||
completion(error)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- parameter param: (body) request body
|
||||
- returns: Promise<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalProperties( param: Any) -> Promise<Void> {
|
||||
let deferred = Promise<Void>.pending()
|
||||
testInlineAdditionalProperties(param: param) { error in
|
||||
if let error = error {
|
||||
deferred.reject(error)
|
||||
} else {
|
||||
deferred.fulfill()
|
||||
}
|
||||
}
|
||||
return deferred.promise
|
||||
}
|
||||
|
||||
/**
|
||||
test inline additionalProperties
|
||||
- POST /fake/inline-additionalProperties
|
||||
-
|
||||
|
||||
- parameter param: (body) request body
|
||||
- returns: RequestBuilder<Void>
|
||||
*/
|
||||
open class func testInlineAdditionalPropertiesWithRequestBuilder(param: Any) -> RequestBuilder<Void> {
|
||||
let path = "/fake/inline-additionalProperties"
|
||||
let URLString = PetstoreClientAPI.basePath + path
|
||||
let parameters = param.encodeToJSON()
|
||||
|
||||
let url = NSURLComponents(string: URLString)
|
||||
|
||||
let requestBuilder: RequestBuilder<Void>.Type = PetstoreClientAPI.requestBuilderFactory.getBuilder()
|
||||
|
||||
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
|
||||
}
|
||||
|
||||
/**
|
||||
test json serialization of form data
|
||||
- parameter param: (form) field1
|
||||
|
||||
@@ -118,16 +118,12 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
else {
|
||||
mpForm.append(fileURL, withName: k)
|
||||
}
|
||||
break
|
||||
case let string as String:
|
||||
mpForm.append(string.data(using: String.Encoding.utf8)!, withName: k)
|
||||
break
|
||||
case let number as NSNumber:
|
||||
mpForm.append(number.stringValue.data(using: String.Encoding.utf8)!, withName: k)
|
||||
break
|
||||
default:
|
||||
fatalError("Unprocessable value \(v) with key \(k)")
|
||||
break
|
||||
}
|
||||
}
|
||||
}, to: URLString, method: xMethod!, headers: nil, encodingCompletion: { encodingResult in
|
||||
@@ -206,7 +202,7 @@ open class AlamofireRequestBuilder<T>: RequestBuilder<T> {
|
||||
validatedRequest.responseData(completionHandler: { (dataResponse) in
|
||||
cleanupRequest()
|
||||
|
||||
if (dataResponse.result.isFailure) {
|
||||
if dataResponse.result.isFailure {
|
||||
completion(
|
||||
nil,
|
||||
ErrorResponse.HttpError(statusCode: dataResponse.response?.statusCode ?? 500, data: dataResponse.data, error: dataResponse.result.error!)
|
||||
|
||||
@@ -54,7 +54,7 @@ extension Dictionary: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
var dictionary = [AnyHashable: Any]()
|
||||
for (key, value) in self {
|
||||
dictionary[key as! NSObject] = encodeIfPossible(value)
|
||||
dictionary[key] = encodeIfPossible(value)
|
||||
}
|
||||
return dictionary as Any
|
||||
}
|
||||
|
||||
@@ -29,8 +29,8 @@ open class Response<T> {
|
||||
public convenience init(response: HTTPURLResponse, body: T?) {
|
||||
let rawHeader = response.allHeaderFields
|
||||
var header = [String:String]()
|
||||
for (key, value) in rawHeader {
|
||||
header[key as! String] = value as? String
|
||||
for case let (key, value) as (String, String) in rawHeader {
|
||||
header[key] = value
|
||||
}
|
||||
self.init(statusCode: response.statusCode, header: header, body: body)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user