Merge branch 'obj/SupportForByteArray' of https://github.com/mateuszmackowiak/swagger-codegen into mateuszmackowiak-obj/SupportForByteArray

This commit is contained in:
wing328 2016-05-09 11:21:21 +08:00
commit f28e2f2a1b
4 changed files with 14 additions and 9 deletions

View File

@ -28,6 +28,9 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
public static final String AUTHOR_EMAIL = "authorEmail";
public static final String GIT_REPO_URL = "gitRepoURL";
public static final String LICENSE = "license";
public static final String BinaryDataType = "ObjcClientCodegenBinaryData";
protected Set<String> foundationClasses = new HashSet<String>();
protected String podName = "SwaggerClient";
protected String podVersion = "1.0.0";
@ -65,6 +68,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
defaultIncludes.add("NSDictionary");
defaultIncludes.add("NSMutableArray");
defaultIncludes.add("NSMutableDictionary");
defaultIncludes.add(BinaryDataType);
languageSpecificPrimitives.clear();
languageSpecificPrimitives.add("NSNumber");
@ -92,10 +97,8 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
typeMapping.put("List", "NSArray");
typeMapping.put("object", "NSObject");
typeMapping.put("file", "NSURL");
//TODO binary should be mapped to byte array
// mapped to String as a workaround
typeMapping.put("binary", "NSString");
typeMapping.put("ByteArray", "NSString");
typeMapping.put("binary", BinaryDataType);
typeMapping.put("ByteArray", BinaryDataType);
// ref: http://www.tutorialspoint.com/objective_c/objective_c_basic_syntax.htm
setReservedWordsLowerCase(
@ -280,11 +283,13 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
String innerType = getSwaggerType(inner);
String innerTypeDeclaration = getTypeDeclaration(inner);
if (innerTypeDeclaration.endsWith("*")) {
innerTypeDeclaration = innerTypeDeclaration.substring(0, innerTypeDeclaration.length() - 1);
}
if(innerTypeDeclaration.equalsIgnoreCase(BinaryDataType)) {
return "NSData*";
}
// In this codition, type of property p is array of primitive,
// return container type with pointer, e.g. `NSArray* /* NSString */'
if (languageSpecificPrimitives.contains(innerType)) {

View File

@ -33,7 +33,7 @@ NSInteger const {{classPrefix}}UnknownResponseObjectErrorCode = 143528;
formatter.numberStyle = NSNumberFormatterDecimalStyle;
_numberFormatter = formatter;
_primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
_basicReturnTypes = @[@"NSObject", @"id"];
_basicReturnTypes = @[@"NSObject", @"id", @"NSData"];
_arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>"
options:NSRegularExpressionCaseInsensitive
error:nil];

View File

@ -6,7 +6,7 @@ This ObjC package is automatically generated by the [Swagger Codegen](https://gi
- API version: 1.0.0
- Package version:
- Build date: 2016-05-06T12:20:47.112+02:00
- Build date: 2016-05-08T12:06:01.121+02:00
- Build package: class io.swagger.codegen.languages.ObjcClientCodegen
## Requirements

View File

@ -33,7 +33,7 @@ NSInteger const SWGUnknownResponseObjectErrorCode = 143528;
formatter.numberStyle = NSNumberFormatterDecimalStyle;
_numberFormatter = formatter;
_primitiveTypes = @[@"NSString", @"NSDate", @"NSNumber"];
_basicReturnTypes = @[@"NSObject", @"id"];
_basicReturnTypes = @[@"NSObject", @"id", @"NSData"];
_arrayOfModelsPatExpression = [NSRegularExpression regularExpressionWithPattern:@"NSArray<(.+)>"
options:NSRegularExpressionCaseInsensitive
error:nil];