Skip to content

Commit a5e837f

Browse files
authored
issue with NoClassDefFoundError (#193)
1 parent 894814c commit a5e837f

File tree

4 files changed

+28
-3
lines changed

4 files changed

+28
-3
lines changed

project/plugins.sbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.5")
1+
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.4")
22

33
addSbtPlugin("org.typelevel" % "sbt-typelevel-sonatype-ci-release" % "0.5.0-M5")
44

src/main/scala-2/com/github/swagger/scala/converter/ErasureHelper.scala

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ private[converter] object ErasureHelper {
4242
// use this form because of Scala 2.11 & 2.12 compile issue
4343
logger.debug(s"Unable to get type info ${Option(cls.getName).getOrElse("null")}", t)
4444
} else {
45-
logger.info("Unable to get type info {}", Option(cls.getName).getOrElse("null"))
45+
logger.info(s"Unable to get type info ${Option(cls.getName).getOrElse("null")}: $t")
46+
}
47+
Map.empty[String, Class[_]]
48+
}
49+
case err: NoClassDefFoundError => {
50+
if (logger.isDebugEnabled) {
51+
// use this form because of Scala 2.11 & 2.12 compile issue
52+
logger.debug(s"Unable to get type info ${Option(cls.getName).getOrElse("null")}", err)
53+
} else {
54+
logger.info(s"Unable to get type info ${Option(cls.getName).getOrElse("null")}: $err")
4655
}
4756
Map.empty[String, Class[_]]
4857
}

src/test/scala/com/github/swagger/scala/converter/ModelPropertyParserTest.scala

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,12 +570,19 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
570570
}
571571

572572
it should "process case class with Duration field" in new PropertiesScope[ModelWDuration] {
573-
model.value.getRequired.asScala shouldEqual Seq("duration")
573+
nullSafeSeq(model.value.getRequired) shouldEqual Seq("duration")
574574
val props = nullSafeMap(model.value.getProperties)
575575
props should have size 1
576576
props("duration") shouldBe a[Schema[_]]
577577
}
578578

579+
it should "process DataExampleClass" in new PropertiesScope[DataExampleClass] {
580+
nullSafeSeq(model.value.getRequired) shouldEqual Seq("data")
581+
val props = nullSafeMap(model.value.getProperties)
582+
props should have size 1
583+
props("data") shouldBe a[Schema[_]]
584+
}
585+
579586
it should "process sealed abstract class" in new TestScope {
580587
val schemas = converter.readAll(classOf[Animal]).asScala.toMap
581588
val catModel = findModel(schemas, "Cat")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package models
2+
3+
final case class DataExampleClass(data: CustomCollection[ExampleProperties])
4+
5+
final case class CustomCollection[T](features: Seq[FeatureExample[T]])
6+
7+
final case class FeatureExample[T](geometry: Option[T])
8+
9+
final case class ExampleProperties(p1: Int, p2: Double)

0 commit comments

Comments
 (0)