forked from loafle/openapi-generator-original
[Swift] Add support for NSUUID
This commit is contained in:
@@ -88,6 +88,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
Arrays.asList(
|
||||
"NSDate",
|
||||
"NSURL", // for file
|
||||
"NSUUID",
|
||||
"Array",
|
||||
"Dictionary",
|
||||
"Set",
|
||||
@@ -131,6 +132,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("UUID", "NSUUID");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
|
||||
|
||||
@@ -73,6 +73,12 @@ extension NSDate: JSONEncodable {
|
||||
}
|
||||
}
|
||||
|
||||
extension NSUUID: JSONEncodable {
|
||||
func encodeToJSON() -> AnyObject {
|
||||
return self.UUIDString
|
||||
}
|
||||
}
|
||||
|
||||
{{#usePromiseKit}}extension RequestBuilder {
|
||||
public func execute() -> Promise<Response<T>> {
|
||||
let deferred = Promise<Response<T>>.pendingPromise()
|
||||
|
||||
@@ -62,6 +62,9 @@ class Decoders {
|
||||
if T.self is Int64.Type && source is NSNumber {
|
||||
return source.longLongValue as! T;
|
||||
}
|
||||
if T.self is NSUUID.Type && source is String {
|
||||
return NSUUID(UUIDString: source as! String) as! T
|
||||
}
|
||||
if source is T {
|
||||
return source as! T
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user