forked from loafle/openapi-generator-original
Added code to templates to ensure correct generation of code for Swift3 (#5390)
* Added code to templates to ensure generation of code for Swift3 that builds on both Apple platforms and Linux. Fixed a bug in the Model decoders that prevented code from building for Linux * Ran the script to generate the PetStore API
This commit is contained in:
parent
f5f3dbd94a
commit
409638676e
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire{{#usePromiseKit}}
|
import Alamofire{{#usePromiseKit}}
|
||||||
import PromiseKit{{/usePromiseKit}}
|
import PromiseKit{{/usePromiseKit}}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class Decoders {
|
|||||||
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
||||||
initialize()
|
initialize()
|
||||||
if T.self is Int32.Type && source is NSNumber {
|
if T.self is Int32.Type && source is NSNumber {
|
||||||
return source.int32Value as! T;
|
return (source as! NSNumber).int32Value as! T;
|
||||||
}
|
}
|
||||||
if T.self is Int64.Type && source is NSNumber {
|
if T.self is Int64.Type && source is NSNumber {
|
||||||
return source.int64Value as! T;
|
return source.int64Value as! T;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire{{#usePromiseKit}}
|
import Alamofire{{#usePromiseKit}}
|
||||||
import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
|
import PromiseKit{{/usePromiseKit}}{{#useRxSwift}}
|
||||||
import RxSwift{{/useRxSwift}}
|
import RxSwift{{/useRxSwift}}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
extension Bool: JSONEncodable {
|
extension Bool: JSONEncodable {
|
||||||
|
@ -70,7 +70,7 @@ class Decoders {
|
|||||||
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
||||||
initialize()
|
initialize()
|
||||||
if T.self is Int32.Type && source is NSNumber {
|
if T.self is Int32.Type && source is NSNumber {
|
||||||
return source.int32Value as! T;
|
return (source as! NSNumber).int32Value as! T;
|
||||||
}
|
}
|
||||||
if T.self is Int64.Type && source is NSNumber {
|
if T.self is Int64.Type && source is NSNumber {
|
||||||
return source.int64Value as! T;
|
return source.int64Value as! T;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import PromiseKit
|
import PromiseKit
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class Decoders {
|
|||||||
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
||||||
initialize()
|
initialize()
|
||||||
if T.self is Int32.Type && source is NSNumber {
|
if T.self is Int32.Type && source is NSNumber {
|
||||||
return source.int32Value as! T;
|
return (source as! NSNumber).int32Value as! T;
|
||||||
}
|
}
|
||||||
if T.self is Int64.Type && source is NSNumber {
|
if T.self is Int64.Type && source is NSNumber {
|
||||||
return source.int64Value as! T;
|
return source.int64Value as! T;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import RxSwift
|
import RxSwift
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import RxSwift
|
import RxSwift
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import RxSwift
|
import RxSwift
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
import RxSwift
|
import RxSwift
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
class AlamofireRequestBuilderFactory: RequestBuilderFactory {
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
// https://github.com/swagger-api/swagger-codegen
|
// https://github.com/swagger-api/swagger-codegen
|
||||||
//
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
import Alamofire
|
import Alamofire
|
||||||
|
|
||||||
extension Bool: JSONEncodable {
|
extension Bool: JSONEncodable {
|
||||||
|
@ -70,7 +70,7 @@ class Decoders {
|
|||||||
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
static func decode<T>(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> T {
|
||||||
initialize()
|
initialize()
|
||||||
if T.self is Int32.Type && source is NSNumber {
|
if T.self is Int32.Type && source is NSNumber {
|
||||||
return source.int32Value as! T;
|
return (source as! NSNumber).int32Value as! T;
|
||||||
}
|
}
|
||||||
if T.self is Int64.Type && source is NSNumber {
|
if T.self is Int64.Type && source is NSNumber {
|
||||||
return source.int64Value as! T;
|
return source.int64Value as! T;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user