@@ -22,6 +22,12 @@ object SwaggerScalaModelConverter {
2222class SwaggerScalaModelConverter extends ModelResolver (Json .mapper()) {
2323 SwaggerScalaModelConverter
2424
25+ private val OptionClass = classOf [scala.Option [_]]
26+ private val IterableClass = classOf [scala.collection.Iterable [_]]
27+ private val SetClass = classOf [scala.collection.Set [_]]
28+ private val BigDecimalClass = classOf [BigDecimal ]
29+ private val BigIntClass = classOf [BigInt ]
30+
2531 override def resolve (`type` : AnnotatedType , context : ModelConverterContext , chain : Iterator [ModelConverter ]): Schema [_] = {
2632 val javaType = _mapper.constructType(`type`.getType)
2733 val cls = javaType.getRawClass
@@ -38,6 +44,13 @@ class SwaggerScalaModelConverter extends ModelResolver(Json.mapper()) {
3844 val nextResolved = Option (chain.next().resolve(`type`, context, chain))
3945 nextResolved match {
4046 case Some (property) => {
47+ if (isIterable(cls)) {
48+ // untidy solution for https://github.com/swagger-akka-http/swagger-scala-module/issues/48
49+ property.getRequired.remove(" traversableAgain" )
50+ val props = property.getProperties
51+ props.remove(" traversableAgain" )
52+ props.remove(" empty" )
53+ }
4154 setRequired(`type`)
4255 property
4356 }
@@ -80,11 +93,11 @@ class SwaggerScalaModelConverter extends ModelResolver(Json.mapper()) {
8093 }
8194 case _ => {
8295 Option (nullableClass).flatMap { cls =>
83- if (cls == classOf [ BigDecimal ] ) {
96+ if (cls == BigDecimalClass ) {
8497 val dp = PrimitiveType .DECIMAL .createProperty()
8598 setRequired(`type`)
8699 Some (dp)
87- } else if (cls == classOf [ BigInt ] ) {
100+ } else if (cls == BigIntClass ) {
88101 val ip = PrimitiveType .INT .createProperty()
89102 setRequired(`type`)
90103 Some (ip)
@@ -130,7 +143,7 @@ class SwaggerScalaModelConverter extends ModelResolver(Json.mapper()) {
130143
131144 override def _isSetType (cls : Class [_]): Boolean = {
132145 val setInterfaces = cls.getInterfaces.find { interface =>
133- interface == classOf [scala.collection. Set [_]]
146+ interface == SetClass
134147 }
135148 setInterfaces.isDefined || super ._isSetType(cls)
136149 }
@@ -163,7 +176,8 @@ class SwaggerScalaModelConverter extends ModelResolver(Json.mapper()) {
163176 else None
164177 }
165178
166- private def isOption (cls : Class [_]): Boolean = cls == classOf [scala.Option [_]]
179+ private def isOption (cls : Class [_]): Boolean = cls == OptionClass
180+ private def isIterable (cls : Class [_]): Boolean = IterableClass .isAssignableFrom(cls)
167181
168182 private def nullSafeList [T ](array : Array [T ]): List [T ] = Option (array) match {
169183 case None => List .empty[T ]
0 commit comments