diff --git a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala index 0bc2d9c14bc..81435d8f434 100644 --- a/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala +++ b/src/main/scala/com/wordnik/swagger/codegen/Codegen.scala @@ -309,7 +309,7 @@ class Codegen(config: CodegenConfig) { val ComplexTypeMatcher(basePart) = operation.responseClass properties += "returnType" -> config.processResponseDeclaration(operation.responseClass.replaceAll(basePart, config.processResponseClass(basePart).get)) - properties += "returnContainer" -> (operation.responseClass.substring(0, n)) + properties += "returnContainer" -> config.processResponseClass(operation.responseClass.substring(0, n)) properties += "returnBaseType" -> config.processResponseClass(basePart) properties += "returnTypeIsPrimitive" -> { (config.languageSpecificPrimitives.contains(basePart) || primitives.contains(basePart)) match { diff --git a/src/test/scala/BasicScalaGeneratorTest.scala b/src/test/scala/BasicScalaGeneratorTest.scala index d2147f78cb4..9bcea0af9d0 100644 --- a/src/test/scala/BasicScalaGeneratorTest.scala +++ b/src/test/scala/BasicScalaGeneratorTest.scala @@ -211,7 +211,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers { m("returnType") should be (Some("List[Pet]")) m("returnTypeIsPrimitive") should be (None) m("pathParams").asInstanceOf[List[_]].size should be (0) - m("returnContainer") should be ("List") + m("returnContainer") should be (Some("List")) m("requiredParamCount") should be ("1") val queryParams = m("queryParams").asInstanceOf[List[_]] @@ -248,7 +248,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers { m("returnType") should be (Some("List[Pet]")) m("returnTypeIsPrimitive") should be (None) m("pathParams").asInstanceOf[List[_]].size should be (0) - m("returnContainer") should be ("List") + m("returnContainer") should be (Some("List")) m("requiredParamCount") should be ("1") val queryParams = m("queryParams").asInstanceOf[List[_]] diff --git a/src/test/scala/CodegenTest.scala b/src/test/scala/CodegenTest.scala new file mode 100644 index 00000000000..26156bb8eb5 --- /dev/null +++ b/src/test/scala/CodegenTest.scala @@ -0,0 +1,55 @@ +/** + * Copyright 2014 Wordnik, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import com.wordnik.swagger.codegen.Codegen +import com.wordnik.swagger.codegen.BasicJavaGenerator +import com.wordnik.swagger.codegen.model._ + +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner +import org.scalatest.FlatSpec +import org.scalatest.matchers.ShouldMatchers + +import scala.reflect.BeanProperty + +@RunWith(classOf[JUnitRunner]) +class CodegenTest extends FlatSpec with ShouldMatchers { + + val subject = new Codegen(new BasicJavaGenerator) + + val testOp = new Operation("GET", + "List All Contacts", + "", + "Array[ContactData]", + "listContacts", + 0, + List.empty, + List.empty, + List.empty, + List.empty, + List.empty, + List.empty, + None) + + behavior of "Codegen" + /* + * A return specified as "Array" should map to "List" + */ + it should "recognize the returnContainer as a List" in { + val map = subject.apiToMap("/contacts", testOp) + map("returnContainer") should be (Some("List")) + } +}