Skip to content

Commit 1b3667f

Browse files
Merge pull request #47 from themooks/iOSFix
[DEVTOOLING-1076] Fixing iOS SDK
2 parents 8d2ebf4 + f73c41d commit 1b3667f

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PureCloudSwift4ClientCodegen.java

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,50 @@ public void postProcessModelProperty(CodegenModel model, CodegenProperty propert
193193
property.enumName = property.datatypeWithEnum;
194194

195195
property.allowableValues = property.items.allowableValues;
196+
} else if (property.isContainer &&
197+
property.isArray &&
198+
property.containerType != null && property.containerType.equals("array") &&
199+
property.items != null && !property.items.isEnum && !(property.complexType == null) &&
200+
(!property.dataType.contains("[Dictionary]") || !property.datatypeWithEnum.contains("[Dictionary]"))) {
201+
202+
property.dataType = "[" + property.items.dataType + "]";;
203+
property.datatypeWithEnum = "[" + property.items.datatypeWithEnum + "]";;
204+
property.complexType = "[" + property.items.complexType + "]";;
205+
property.containerType = property.items.containerType;
196206
}
197207
property.dataType = property.dataType.replace("[Dictionary]", "[[String:JSON]]");
198208
property.datatypeWithEnum = property.datatypeWithEnum.replace("[Dictionary]", "[[String:JSON]]");
199209

200210
if (property.baseType.equals("StringJSON") && !(property.complexType == null)) {
201-
if (!property.datatypeWithEnum.contains("[[String:JSON]]") || !property.dataType.contains("[[String:JSON]]")) {
202-
boolean startsWithThing = property.dataType.startsWith("[") || property.datatypeWithEnum.startsWith("[");
211+
if ((!property.datatypeWithEnum.contains("[[String:JSON]]") && !property.datatypeWithEnum.contains("[[String]]")) ||
212+
(!property.dataType.contains("[[String:JSON]]") && !property.dataType.contains("[[String]]"))) {
213+
boolean startsWithArray = property.dataType.startsWith("[") || property.datatypeWithEnum.startsWith("[");
203214
property.dataType = toModelName(property.dataType);
204215
property.datatypeWithEnum = toModelName(property.datatypeWithEnum);
205216

206-
if (startsWithThing && !property.dataType.startsWith("[") || !property.datatypeWithEnum.startsWith("[")) {
217+
if (startsWithArray && (!property.dataType.startsWith("[") || !property.datatypeWithEnum.startsWith("["))) {
207218
property.dataType = "[" + property.dataType + "]";
208219
property.datatypeWithEnum = "[" + property.datatypeWithEnum + "]";
209220
}
210221
}
222+
} else if (!property.baseType.equals("StringJSON") && !(property.complexType == null)) {
223+
boolean startsWithArray = property.dataType.startsWith("[") || property.datatypeWithEnum.startsWith("[");
224+
boolean startsWithStringMap = property.dataType.startsWith("[String:") || property.datatypeWithEnum.startsWith("[String:");
225+
boolean startsWithStringMapArray = property.dataType.startsWith("[String:[") || property.datatypeWithEnum.startsWith("[String:[");
226+
property.dataType = toModelName(property.dataType);
227+
property.datatypeWithEnum = toModelName(property.datatypeWithEnum);
228+
229+
if (startsWithArray && (!property.dataType.startsWith("[") || !property.datatypeWithEnum.startsWith("["))) {
230+
property.dataType = "[" + property.dataType + "]";
231+
property.datatypeWithEnum = "[" + property.datatypeWithEnum + "]";
232+
if (startsWithStringMapArray && (!property.dataType.startsWith("[String:[") || !property.datatypeWithEnum.startsWith("[String:["))) {
233+
property.dataType = property.dataType.replace("[String", "[String:[") + "]";;
234+
property.datatypeWithEnum = property.datatypeWithEnum.replace("[String", "[String:[") + "]";;
235+
} else if (startsWithStringMap && (!property.dataType.startsWith("[String:") || !property.datatypeWithEnum.startsWith("[String:"))) {
236+
property.dataType = property.dataType.replace("[String", "[String:");
237+
property.datatypeWithEnum = property.datatypeWithEnum.replace("[String", "[String:");
238+
}
239+
}
211240
}
212241
}
213242
}

0 commit comments

Comments
 (0)