Fixed bug that prevented Objective-C code from compiling when using a Swagger 'map' type

This commit is contained in:
gandrianakis 2015-02-25 19:31:50 +02:00
parent ff94196295
commit d313d4da3f
3 changed files with 23 additions and 8 deletions

View File

@ -519,16 +519,20 @@ public class DefaultCodegen {
property.isPrimitiveType = true; property.isPrimitiveType = true;
} }
else { else {
property.isNotContainer = true; setNonArrayMapProperty(property, type);
if(languageSpecificPrimitives().contains(type))
property.isPrimitiveType = true;
else
property.complexType = property.baseType;
} }
return property; return property;
} }
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation){ protected void setNonArrayMapProperty(CodegenProperty property, String type) {
property.isNotContainer = true;
if(languageSpecificPrimitives().contains(type))
property.isPrimitiveType = true;
else
property.complexType = property.baseType;
}
public CodegenOperation fromOperation(String path, String httpMethod, Operation operation){
CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION); CodegenOperation op = CodegenModelFactory.newInstance(CodegenModelType.OPERATION);
Set<String> imports = new HashSet<String>(); Set<String> imports = new HashSet<String>();

View File

@ -168,7 +168,18 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
} }
} }
@Override @Override
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
super.setNonArrayMapProperty(property, type);
if("NSDictionary".equals(type)) {
property.setter = "initWithDictionary";
}
else {
property.setter = "initWithValues";
}
}
@Override
public String toModelImport(String name) { public String toModelImport(String name) {
if("".equals(modelPackage())) if("".equals(modelPackage()))
return name; return name;

View File

@ -39,7 +39,7 @@
} }
{{/isContainer}}{{#isNotContainer}} {{/isContainer}}{{#isNotContainer}}
if({{name}}_dict != nil) if({{name}}_dict != nil)
_{{name}} = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{complexType}}} {{/instantiationType}} alloc]initWithValues:{{name}}_dict]; _{{name}} = [[{{#instantiationType}}NSClassFromString(@"{{{instantiationType}}}") {{/instantiationType}}{{^instantiationType}}{{{complexType}}} {{/instantiationType}} alloc]{{setter}}:{{name}}_dict];
{{/isNotContainer}} {{/isNotContainer}}
{{/complexType}} {{/complexType}}
{{/vars}}{{newline}} {{/vars}}{{newline}}