diff --git a/conf/java/sample/lib-test-script.json b/conf/java/sample/lib-test-script.json index 557263818a8..bee986299a2 100644 --- a/conf/java/sample/lib-test-script.json +++ b/conf/java/sample/lib-test-script.json @@ -97,7 +97,21 @@ "httpMethod" : "POST", "path" : "/store.{format}/order", "suggestedMethodName" : "placeOrder" - } + }, + { + "id" : 15, + "name" : "Get users with array input", + "httpMethod" : "POST", + "path" : "/user.{format}/usersWithArray", + "suggestedMethodName" : "getUserByNamesArray" + }, + { + "id" : 16, + "name" : "get users with list", + "httpMethod" : "POST", + "path" : "/user.{format}/usersWithList", + "suggestedMethodName" : "getUserByNamesList" + } ], "testSuites" : [ { @@ -179,9 +193,40 @@ "expectedOutput" : "${input.userList[2].username}" } ] + }, + { + "name" : "Find users with array of user names", + "id" : 6, + "resourceId" : 15, + "input" : { + "postData":"[\"testuser1\", \"testuser2\"]" + }, + "assertions" : [ + { + "actualOutput" : "${output(1.6).size}", + "condition" : "==", + "expectedOutput" : "2" + } + ] + }, + { + "name" : "Find users with list of user names", + "id" : 7, + "resourceId" : 16, + "input" : { + "postData":"[\"testuser1\", \"testuser2\"]" + }, + "assertions" : [ + { + "actualOutput" : "${output(1.7).size}", + "condition" : "==", + "expectedOutput" : "2" + } + ] } + ] }, { diff --git a/src/main/java/com/wordnik/swagger/codegen/config/java/JavaDataTypeMappingProvider.java b/src/main/java/com/wordnik/swagger/codegen/config/java/JavaDataTypeMappingProvider.java index 9cf1479d618..93e94495df1 100644 --- a/src/main/java/com/wordnik/swagger/codegen/config/java/JavaDataTypeMappingProvider.java +++ b/src/main/java/com/wordnik/swagger/codegen/config/java/JavaDataTypeMappingProvider.java @@ -199,13 +199,14 @@ public class JavaDataTypeMappingProvider implements DataTypeMappingProvider { String classShortName = ""; if(type.startsWith("List[")){ classShortName = type.substring(5, type.length()-1); - classShortName = "List<"+ getClassName(classShortName, true)+">"; + classShortName = "List<"+ getClassType(classShortName, true)+">"; }else if (type.startsWith("Map[")) { classShortName = type.substring(4, type.length()-1); - classShortName = "Map<"+ getClassName(classShortName, true) +">"; + String[] mapTypes = classShortName.split(","); + classShortName = "Map<"+ getClassType(mapTypes[0], true) + "," + getClassType(mapTypes[1], true) +">"; }else if (type.startsWith("Set[")) { classShortName = type.substring(4, type.length()-1); - classShortName = "Set<"+ getClassName(classShortName, true) +">"; + classShortName = "Set<"+ getClassType(classShortName, true) +">"; }else if (type.startsWith("Array[")) { classShortName = type.substring(6, type.length()-1); classShortName = getClassName(classShortName, true) +"[]"; diff --git a/src/main/java/com/wordnik/swagger/codegen/config/scala/ScalaDataTypeMappingProvider.scala b/src/main/java/com/wordnik/swagger/codegen/config/scala/ScalaDataTypeMappingProvider.scala index e6b778d9051..d46bb70194f 100644 --- a/src/main/java/com/wordnik/swagger/codegen/config/scala/ScalaDataTypeMappingProvider.scala +++ b/src/main/java/com/wordnik/swagger/codegen/config/scala/ScalaDataTypeMappingProvider.scala @@ -178,13 +178,14 @@ class ScalaDataTypeMappingProvider extends DataTypeMappingProvider { var classShortName = "" if (input.startsWith("List[")) { classShortName = input.substring(5, input.length() - 1); - classShortName = "List[" + getClassName(classShortName, true) + "]"; + classShortName = "List[" + getClassType(classShortName, true) + "]"; } else if (input.startsWith("Map[")) { classShortName = input.substring(4, input.length() - 1); - classShortName = "Map[" + getClassName(classShortName, true) + "]"; + val mapTypes:Array[String] = classShortName.split(","); + classShortName = "Map[" + getClassType(mapTypes(0), true) + "," + getClassType(mapTypes(1), true) + "]"; } else if (input.startsWith("Set[")) { classShortName = input.substring(4, input.length() - 1); - classShortName = "Set[" + getClassName(classShortName, true) + "]"; + classShortName = "Set[" + getClassType(classShortName, true) + "]"; } else if (input.startsWith("Array[")) { classShortName = input.substring(6, input.length() - 1); classShortName = "Array["+getClassName(classShortName, true) + "]";