forked from loafle/openapi-generator-original
[Swift] Handle binary data types
This commit is contained in:
@@ -703,6 +703,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
example = "2013-10-20T19:20:30+01:00";
|
||||
}
|
||||
example = "@\"" + escapeText(example) + "\"";
|
||||
} else if ("NSData".equalsIgnoreCase(type)) {
|
||||
example = "1234";
|
||||
} else if (!languageSpecificPrimitives.contains(type)) {
|
||||
// type is a model class, e.g. User
|
||||
type = type.replace("*", "");
|
||||
|
||||
@@ -87,6 +87,7 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
);
|
||||
defaultIncludes = new HashSet<String>(
|
||||
Arrays.asList(
|
||||
"NSData",
|
||||
"NSDate",
|
||||
"NSURL", // for file
|
||||
"NSUUID",
|
||||
@@ -129,10 +130,8 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
typeMapping.put("double", "Double");
|
||||
typeMapping.put("object", "AnyObject");
|
||||
typeMapping.put("file", "NSURL");
|
||||
//TODO binary should be mapped to byte array
|
||||
// mapped to String as a workaround
|
||||
typeMapping.put("binary", "String");
|
||||
typeMapping.put("ByteArray", "String");
|
||||
typeMapping.put("binary", "NSData");
|
||||
typeMapping.put("ByteArray", "NSData");
|
||||
typeMapping.put("UUID", "NSUUID");
|
||||
|
||||
importMapping = new HashMap<String, String>();
|
||||
@@ -258,6 +257,11 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
return toModelName(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDataTypeBinary(final String dataType) {
|
||||
return dataType != null && dataType.equals("NSData");
|
||||
}
|
||||
|
||||
/**
|
||||
* Output the proper model name (capitalized)
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user