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:
Vincent Coetzee 2017-05-08 12:26:30 +02:00 committed by wing328
parent f5f3dbd94a
commit 409638676e
25 changed files with 25 additions and 4 deletions

View File

@ -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 {

View File

@ -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}}

View File

@ -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;

View File

@ -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}}

View File

@ -5,6 +5,7 @@
// https://github.com/swagger-api/swagger-codegen // https://github.com/swagger-api/swagger-codegen
// //
import Foundation
import Alamofire import Alamofire

View File

@ -5,6 +5,7 @@
// https://github.com/swagger-api/swagger-codegen // https://github.com/swagger-api/swagger-codegen
// //
import Foundation
import Alamofire import Alamofire

View File

@ -5,6 +5,7 @@
// https://github.com/swagger-api/swagger-codegen // https://github.com/swagger-api/swagger-codegen
// //
import Foundation
import Alamofire import Alamofire

View File

@ -5,6 +5,7 @@
// https://github.com/swagger-api/swagger-codegen // https://github.com/swagger-api/swagger-codegen
// //
import Foundation
import Alamofire import Alamofire

View File

@ -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 {

View File

@ -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 {

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 {

View File

@ -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 {

View File

@ -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;