From 77053fa8556c95d5fc15d53191402e64fea165f4 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Tue, 28 Oct 2014 13:21:50 -0700 Subject: [PATCH] added test case, update for #316 --- src/test/scala/Objc/ObjcModelTest.scala | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/test/scala/Objc/ObjcModelTest.scala b/src/test/scala/Objc/ObjcModelTest.scala index 198fc019e84..4dcb003e944 100644 --- a/src/test/scala/Objc/ObjcModelTest.scala +++ b/src/test/scala/Objc/ObjcModelTest.scala @@ -1,7 +1,7 @@ package objc import com.wordnik.swagger.codegen.languages.ObjcClientCodegen -import com.wordnik.swagger.util.Json +import com.wordnik.swagger.util.{ Json, SwaggerLoader } import com.wordnik.swagger.models._ import com.wordnik.swagger.models.properties._ @@ -238,4 +238,23 @@ class ObjcModelTest extends FlatSpec with Matchers { cm.imports.size should be (3) (cm.imports.asScala.toSet & Set("SWGChildren", "NSDictionary", "NSMutableDictionary")).size should be (3) } + + it should "create proper imports per #316" in { + val model = new SwaggerLoader().read("src/test/resources/postBodyTest.json") + val codegen = new ObjcClientCodegen() + + val animalPaths = model.getPaths() + val animalOps = animalPaths.get("/animals") + animalOps.getPost() should not be (null) + val animalCo = codegen.fromOperation("/animals", "POST", animalOps.getPost()) + animalCo.imports.size should be (1) + animalCo.imports.contains("SWGAnimal") should equal (true) + + val insectPaths = model.getPaths() + val insectOps = insectPaths.get("/insects") + insectOps.getPost() should not be (null) + val insectCo = codegen.fromOperation("/insects", "POST", insectOps.getPost()) + insectCo.imports.size should be (1) + insectCo.imports.contains("SWGInsect") should equal (true) + } } \ No newline at end of file