Merge pull request #459 from geoand/objc-dictionary-fix-dev2_0

Fixed bug that prevented Objective-C code from compiling when using a Sw...
This commit is contained in:
Tony Tam 2015-03-19 08:52:25 -07:00
commit 8262d30202
6 changed files with 24 additions and 9 deletions

View File

@ -16,7 +16,7 @@ Check out [Swagger-Spec](https://github.com/swagger-api/swagger-spec) for additi
## Compatability
The Swagger Specification has undergone 3 revisions since initial creation in 2010. The swagger-codegen project has the following compatibilies with the swagger specification:
Swagger Codegen Version | Release Date | Swagger Spec compatability | Notes
Swagger Codegen Version | Release Date | Swagger Spec compatibility | Notes
----------------------- | ------------ | -------------------------- | -----
2.1.3-M1-SNAPSHOT | 2015-02-23 | 1.0, 1.1, 1.2, 2.0 | [tag v2.1.0-M1](https://github.com/swagger-api/swagger-codegen)
2.0.17 | 2014-08-22 | 1.1, 1.2 | [tag v2.0.17](https://github.com/swagger-api/swagger-codegen/tree/v2.0.17)

View File

@ -554,14 +554,18 @@ public class DefaultCodegen {
property.isPrimitiveType = true;
}
else {
setNonArrayMapProperty(property, type);
}
return property;
}
protected void setNonArrayMapProperty(CodegenProperty property, String type) {
property.isNotContainer = true;
if(languageSpecificPrimitives().contains(type))
property.isPrimitiveType = true;
else
property.complexType = property.baseType;
}
return property;
}
private Response findMethodResponse(Map<String, Response> responses) {

View File

@ -168,6 +168,17 @@ public class ObjcClientCodegen extends DefaultCodegen implements CodegenConfig {
}
}
@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) {
if("".equals(modelPackage()))

View File

@ -165,12 +165,12 @@ public class ApiInvoker {
Builder builder = client.resource(host + path + querystring).accept("application/json");
for(String key : headerParams.keySet()) {
builder.header(key, headerParams.get(key));
builder = builder.header(key, headerParams.get(key));
}
for(String key : defaultHeaderMap.keySet()) {
if(!headerParams.containsKey(key)) {
builder.header(key, defaultHeaderMap.get(key));
builder = builder.header(key, defaultHeaderMap.get(key));
}
}
ClientResponse response = null;

View File

@ -39,7 +39,7 @@
}
{{/isContainer}}{{#isNotContainer}}
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}}
{{/complexType}}
{{/vars}}{{newline}}

View File

@ -226,7 +226,7 @@ class ApiClient:
subValues.append(self.deserialize(subValue, subClass))
setattr(instance, attr, subValues)
else:
setattr(instance, attr, self.deserialize(value, objClass))
setattr(instance, attr, self.deserialize(value, attrType))
return instance