zio-schema
zio-schema copied to clipboard
JSON codec built from auto-derived schema fails for enumeration with intermediate type
//> using scala 3.4.0
//> using dep dev.zio::zio-schema:1.0.1
//> using dep dev.zio::zio-schema-derivation:1.0.1
//> using dep dev.zio::zio-schema-json:1.0.1
sealed trait Animal
object Animal:
sealed trait Mammal extends Animal
case object Bison extends Mammal
given schema: zio.schema.Schema[Animal] = zio.schema.DeriveSchema.gen[Animal]
given jsonCodec: zio.json.JsonCodec[Animal] = zio.schema.codec.JsonCodec.jsonCodec(schema)
@main def main: String =
import zio.json.EncoderOps
val value: Animal = Bison
// Exception in thread "main" java.lang.ClassCastException:
// class zio.schema.Schema$Enum1 cannot be cast to class zio.schema.Schema$CaseClass0
value.toJson
/bounty $75
💎 $75 bounty • ZIO
Steps to solve:
-
Start working: Comment
/attempt #668
with your implementation plan -
Submit work: Create a pull request including
/claim #668
in the PR body to claim the bounty - Receive payment: 100% of the bounty is received 2-5 days post-reward. Make sure you are eligible for payouts
Thank you for contributing to zio/zio-schema!
Add a bounty • Share on socials
Attempt | Started (GMT+0) | Solution |
---|---|---|
🔴 @BijenderKumar1 | Jun 25, 2024, 4:16:56 PM | WIP |
🟢 @pablf | #706 |
/attempt #668
Algora profile | Completed bounties | Tech | Active attempts | Options |
---|---|---|---|---|
@BijenderKumar1 | 1 ZIO bounty | Cancel attempt |
💡 @pablf submitted a pull request that claims the bounty. You can visit your bounty board to reward.
@BijenderKumar1: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏
The bounty is up for grabs! Everyone is welcome to /attempt #668
🙌