Skip to content

Commit 2f2caca

Browse files
committed
test for #770, fixed error message
1 parent 82ee92c commit 2f2caca

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

modules/swagger-core/src/main/scala/com/wordnik/swagger/converter/ModelPropertyParser.scala

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,12 +210,15 @@ class ModelPropertyParser(cls: Class[_], t: Map[String, String] = Map.empty) (im
210210
case ComplexTypeMatcher(containerType, basePart) => {
211211
LOGGER.debug("containerType: " + containerType + ", basePart: " + basePart + ", simpleName: " + simpleName)
212212
paramType = containerType
213-
val ComplexTypeMatcher(t, simpleTypeRef) = simpleName
214-
val typeRef = {
215-
if(simpleTypeRef.indexOf(",") > 0) // it's a map, use the value only
216-
simpleTypeRef.split(",").last
217-
else simpleTypeRef
213+
val typeRef = simpleName match {
214+
case ComplexTypeMatcher(t, simpleTypeRef) => {
215+
if(simpleTypeRef.indexOf(",") > 0) // it's a map, use the value only
216+
simpleTypeRef.split(",").last
217+
else simpleTypeRef
218+
}
219+
case _ => simpleName
218220
}
221+
219222
simpleName = containerType
220223
if(isComplex(typeRef)) {
221224
Some(ModelRef(null, Some(typeRef), Some(basePart)))
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package converter
2+
3+
4+
import com.wordnik.swagger.converter._
5+
import com.wordnik.swagger.model._
6+
7+
import com.wordnik.swagger.annotations._
8+
import com.wordnik.swagger.converter._
9+
import com.wordnik.swagger.core.util._
10+
import com.wordnik.swagger.model._
11+
12+
import scala.beans.BeanProperty
13+
14+
import org.junit.runner.RunWith
15+
import org.scalatest.junit.JUnitRunner
16+
import org.scalatest.FlatSpec
17+
import org.scalatest.Matchers
18+
19+
@RunWith(classOf[JUnitRunner])
20+
class ByteConverterTest extends FlatSpec with Matchers {
21+
val models = ModelConverters.read(classOf[ByteConverterModel])
22+
JsonSerializer.asJson(models) should be ("""{"id":"ByteConverterModel","properties":{"myBytes":{"type":"array","items":{"type":"string"}}}}""")
23+
}
24+
25+
class ByteConverterModel {
26+
@ApiModelProperty(dataType="string")
27+
@BeanProperty var myBytes:Array[Byte] = _
28+
}

0 commit comments

Comments
 (0)