diff --git a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache index e8fa94d0e0..f8c312452e 100644 --- a/modules/swagger-codegen/src/main/resources/swift3/Models.mustache +++ b/modules/swagger-codegen/src/main/resources/swift3/Models.mustache @@ -125,11 +125,11 @@ class Decoders { static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { initialize() - if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int32.Type { return .success(value) } - if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { - return .success(value) + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int64.Type { + return .success(value) } if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { return .success(value) diff --git a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift index 1258d5940d..fa325a0e96 100644 --- a/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/default/PetstoreClient/Classes/Swaggers/Models.swift @@ -125,11 +125,11 @@ class Decoders { static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { initialize() - if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int32.Type { return .success(value) } - if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { - return .success(value) + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int64.Type { + return .success(value) } if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { return .success(value) diff --git a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift index 1258d5940d..fa325a0e96 100644 --- a/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/promisekit/PetstoreClient/Classes/Swaggers/Models.swift @@ -125,11 +125,11 @@ class Decoders { static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { initialize() - if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int32.Type { return .success(value) } - if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { - return .success(value) + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int64.Type { + return .success(value) } if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { return .success(value) diff --git a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift index 1258d5940d..fa325a0e96 100644 --- a/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/rxswift/PetstoreClient/Classes/Swaggers/Models.swift @@ -125,11 +125,11 @@ class Decoders { static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { initialize() - if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int32.Type { return .success(value) } - if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { - return .success(value) + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int64.Type { + return .success(value) } if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { return .success(value) diff --git a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift index bcc2197e41..40c6256086 100644 --- a/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift +++ b/samples/client/petstore/swift3/unwraprequired/PetstoreClient/Classes/Swaggers/Models.swift @@ -125,11 +125,11 @@ class Decoders { static func decode(clazz: T.Type, source: AnyObject, instance: AnyObject?) -> Decoded { initialize() - if let value = source.int32Value as? T, source is NSNumber, T.self is Int32.Type { + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int32.Type { return .success(value) } - if let value = source.int32Value as? T, source is NSNumber, T.self is Int64.Type { - return .success(value) + if let sourceNumber = source as? NSNumber, let value = sourceNumber.int32Value as? T, T.self is Int64.Type { + return .success(value) } if let intermediate = source as? String, let value = UUID(uuidString: intermediate) as? T, source is String, T.self is UUID.Type { return .success(value)