Merge pull request #3267 from wing328/swift_npe

[Swift] fix NPE for swift API client due to array of enum
This commit is contained in:
wing328
2016-07-01 17:37:48 +08:00
committed by GitHub
19 changed files with 1355 additions and 89 deletions

View File

@@ -325,9 +325,17 @@ public class SwiftCodegen extends DefaultCodegen implements CodegenConfig {
@Override
public CodegenProperty fromProperty(String name, Property p) {
CodegenProperty codegenProperty = super.fromProperty(name, p);
// TODO skip array/map of enum for the time being,
// we need to add logic here to handle array/map of enum for any
// dimensions
if (Boolean.TRUE.equals(codegenProperty.isContainer)) {
return codegenProperty;
}
if (codegenProperty.isEnum) {
List<Map<String, String>> swiftEnums = new ArrayList<Map<String, String>>();
List<String> values = (List<String>) codegenProperty.allowableValues.get("values");
for (String value : values) {
Map<String, String> map = new HashMap<String, String>();
map.put("enum", toSwiftyEnumName(value));