Closed DenisNovac closed 3 years ago
Actually it happens even without multiple traits:
sealed trait Animal {
def name: String
}
object Animal extends AutoDerivation with SchemaDerivation {
implicit val customConfig: CirceConfiguration =
CirceConfiguration.default.withDefaults.withDiscriminator("type")
implicit val codec: Codec[Animal] = deriveConfiguredCodec
implicit val tapirConfig: TapirConfiguration = TapirConfiguration.default.withDiscriminator("type")
// It can't be implicit since recursive derivation fails
val schema: Schema[Animal] = Schema.derived
case class Tiger(name: String) extends Animal
case class Elephant(name: String) extends Animal
case class Dog(name: String, favToy: String, training: Boolean, friends: List[Animal]) extends Animal
case class Cat(name: String, favToy: String, friends: List[Animal]) extends Animal
//Fails:
//case class Mouse(name: String, favToy: String, friends: List[Animal]) extends Animal
//case class Mouse(name: String, favToy: String, friends: List[Animal], flag: Boolean) extends Animal
}
Somehow it even allows to have two same case classes but fails on third.
final case class Tiger(name: String) extends Animal
final case class Elephant(name: String) extends Animal
final case class Dog(name: String, friends: List[Animal]) extends Animal
final case class Cat(name: String, friends: List[Animal]) extends Animal
final case class Mouse(name: String, friends: List[Animal]) extends Animal // it fails only with this line
The derivation cache wasn't cleared at one point. A fix is coming :)
@adamw that's great, thank you
Released in 0.17.5
Tapir version: 0.17.2
Scala version: 2.13.4
Describe the bug
Some strange parts of the code fails with error:
How to reproduce?
Project with example (specific branch in repo for it): https://github.com/DenisNovac/tapir-schema-test/tree/multilevel-traits-adt
Animal (https://github.com/DenisNovac/tapir-schema-test/blob/multilevel-traits-adt/src/main/scala/Animal.scala):