File tree Expand file tree Collapse file tree 3 files changed +16
-1
lines changed
main/scala-2/com/github/swagger/scala/converter
test/scala/com/github/swagger/scala/converter Expand file tree Collapse file tree 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.github.swagger.scala.converter
22
33import org .slf4j .LoggerFactory
44
5+ import scala .annotation .tailrec
56import scala .reflect .runtime .universe
67import scala .util .Try
78import scala .util .control .NonFatal
@@ -27,7 +28,7 @@ private[converter] object ErasureHelper {
2728 val maybeClass : Option [Class [_]] = prop.typeSignature.typeArgs.headOption.flatMap { signature =>
2829 if (signature.typeSymbol.isClass) {
2930 signature.typeArgs.headOption match {
30- case Some (typeArg) => Option (mirror.runtimeClass(typeArg))
31+ case Some (typeArg) => Option (mirror.runtimeClass(nestedTypeArg( typeArg) ))
3132 case _ => Option (mirror.runtimeClass(signature))
3233 }
3334 } else {
@@ -48,4 +49,12 @@ private[converter] object ErasureHelper {
4849 }
4950 }
5051 }
52+
53+ @ tailrec
54+ private def nestedTypeArg (typeArg : universe.Type ): universe.Type = {
55+ typeArg.typeArgs.headOption match {
56+ case Some (innerArg) => nestedTypeArg(innerArg)
57+ case _ => typeArg
58+ }
59+ }
5160}
Original file line number Diff line number Diff line change @@ -21,4 +21,8 @@ class ErasureHelperTest extends AnyFlatSpec with Matchers {
2121 val expected = if (RuntimeUtil .isScala3()) Map .empty[String , Class [_]] else Map (" values" -> classOf [Long ])
2222 ErasureHelper .erasedOptionalPrimitives(classOf [SeqOptionLong ]) shouldBe expected
2323 }
24+ it should " handle OptionSeqOptionLong" in {
25+ val expected = if (RuntimeUtil .isScala3()) Map .empty[String , Class [_]] else Map (" values" -> classOf [Long ])
26+ ErasureHelper .erasedOptionalPrimitives(classOf [OptionSeqOptionLong ]) shouldBe expected
27+ }
2428}
Original file line number Diff line number Diff line change 11package com .github .swagger .scala .converter
22
33case class SeqOptionLong (values : Seq [Option [Long ]])
4+
5+ case class OptionSeqOptionLong (values : Option [Seq [Option [Long ]]])
You can’t perform that action at this time.
0 commit comments