Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON codec built from auto-derived schema fails for enumeration with intermediate type #668

Open
dubinsky opened this issue Mar 11, 2024 · 6 comments · May be fixed by #706
Open

JSON codec built from auto-derived schema fails for enumeration with intermediate type #668

dubinsky opened this issue Mar 11, 2024 · 6 comments · May be fixed by #706

Comments

@dubinsky
Copy link

//> 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
@jdegoes
Copy link
Member

jdegoes commented Jun 8, 2024

/bounty $75

Copy link

algora-pbc bot commented Jun 8, 2024

💎 $75 bounty • ZIO

Steps to solve:

  1. Start working: Comment /attempt #668 with your implementation plan
  2. Submit work: Create a pull request including /claim #668 in the PR body to claim the bounty
  3. 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 bountyShare on socials

Attempt Started (GMT+0) Solution
🔴 @BijenderKumar1 Jun 25, 2024, 4:16:56 PM WIP
🟢 @pablf #706

@BijenderKumar1
Copy link

BijenderKumar1 commented Jun 25, 2024

/attempt #668

Algora profile Completed bounties Tech Active attempts Options
@BijenderKumar1 1 ZIO bounty
Cancel attempt

Copy link

algora-pbc bot commented Jun 30, 2024

💡 @pablf submitted a pull request that claims the bounty. You can visit your bounty board to reward.

Copy link

algora-pbc bot commented Jul 2, 2024

@BijenderKumar1: Reminder that in 7 days the bounty will become up for grabs, so please submit a pull request before then 🙏

Copy link

algora-pbc bot commented Jul 9, 2024

The bounty is up for grabs! Everyone is welcome to /attempt #668 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants