From 2f2caca0efc1649330acda3d2965ca1b75543071 Mon Sep 17 00:00:00 2001 From: Tony Tam Date: Sat, 20 Dec 2014 23:48:40 -0800 Subject: [PATCH] test for #770, fixed error message --- .../converter/ModelPropertyParser.scala | 13 +++++---- .../scala/converter/ByteConverterTest.scala | 28 +++++++++++++++++++ 2 files changed, 36 insertions(+), 5 deletions(-) create mode 100644 modules/swagger-core/src/test/scala/converter/ByteConverterTest.scala diff --git a/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala b/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala index 1f91528fb5..15a099f27c 100644 --- a/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala +++ b/modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala @@ -210,12 +210,15 @@ class ModelPropertyParser(cls: Class[_], t: Map[String, String] = Map.empty) (im case ComplexTypeMatcher(containerType, basePart) => { LOGGER.debug("containerType: " + containerType + ", basePart: " + basePart + ", simpleName: " + simpleName) paramType = containerType - val ComplexTypeMatcher(t, simpleTypeRef) = simpleName - val typeRef = { - if(simpleTypeRef.indexOf(",") > 0) // it's a map, use the value only - simpleTypeRef.split(",").last - else simpleTypeRef + val typeRef = simpleName match { + case ComplexTypeMatcher(t, simpleTypeRef) => { + if(simpleTypeRef.indexOf(",") > 0) // it's a map, use the value only + simpleTypeRef.split(",").last + else simpleTypeRef + } + case _ => simpleName } + simpleName = containerType if(isComplex(typeRef)) { Some(ModelRef(null, Some(typeRef), Some(basePart))) diff --git a/modules/swagger-core/src/test/scala/converter/ByteConverterTest.scala b/modules/swagger-core/src/test/scala/converter/ByteConverterTest.scala new file mode 100644 index 0000000000..74d536b130 --- /dev/null +++ b/modules/swagger-core/src/test/scala/converter/ByteConverterTest.scala @@ -0,0 +1,28 @@ +package converter + + +import com.wordnik.swagger.converter._ +import com.wordnik.swagger.model._ + +import com.wordnik.swagger.annotations._ +import com.wordnik.swagger.converter._ +import com.wordnik.swagger.core.util._ +import com.wordnik.swagger.model._ + +import scala.beans.BeanProperty + +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner +import org.scalatest.FlatSpec +import org.scalatest.Matchers + +@RunWith(classOf[JUnitRunner]) +class ByteConverterTest extends FlatSpec with Matchers { + val models = ModelConverters.read(classOf[ByteConverterModel]) + JsonSerializer.asJson(models) should be ("""{"id":"ByteConverterModel","properties":{"myBytes":{"type":"array","items":{"type":"string"}}}}""") +} + +class ByteConverterModel { + @ApiModelProperty(dataType="string") + @BeanProperty var myBytes:Array[Byte] = _ +} \ No newline at end of file