mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 16:40:56 +00:00
Add extension methods for primitives
This commit is contained in:
parent
5dfa753f5c
commit
0b7d758077
@ -43,9 +43,34 @@ extension Request {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
extension Bool: JSONDecodable {
|
||||
static func decode(source: AnyObject) -> Bool? {
|
||||
return source as? Bool
|
||||
}
|
||||
}
|
||||
|
||||
extension Float: JSONDecodable {
|
||||
static func decode(source: AnyObject) -> Float? {
|
||||
return source as? Float
|
||||
}
|
||||
}
|
||||
|
||||
extension Int: JSONDecodable {
|
||||
static func decode(source: AnyObject) -> Int? {
|
||||
return source as? Int
|
||||
}
|
||||
}
|
||||
|
||||
extension Double: JSONDecodable {
|
||||
static func decode(source: AnyObject) -> Double? {
|
||||
return source as? Double
|
||||
}
|
||||
}
|
||||
|
||||
extension String: JSONDecodable {
|
||||
static func decode(source: AnyObject) -> String? {
|
||||
return source.description
|
||||
return source as? String
|
||||
}
|
||||
}
|
||||
|
||||
@ -59,11 +84,7 @@ extension Array: JSONEncodable {
|
||||
}
|
||||
}
|
||||
|
||||
extension Dictionary: JSONEncodable, JSONDecodable {
|
||||
static func decode(source: AnyObject) -> [Key:Value]? {
|
||||
return nil
|
||||
}
|
||||
|
||||
extension Dictionary: JSONEncodable {
|
||||
func encode() -> AnyObject {
|
||||
var dictionary = [NSObject:AnyObject]()
|
||||
for (key, value) in self {
|
||||
|
Loading…
x
Reference in New Issue
Block a user