Skip to content

Schema derivation fails for enumeration with empty sub-tree #667

@dubinsky

Description

@dubinsky

Schema derivation fails when intermediate types with no leaf case objects/classes derived from them are present
in the sealed trait (or sealed abstract class) hierarchy.

I can understand failure to derive the schema if the whole hierarchy is empty (no leaf case class/object nodes at all),
even though I think it should still work; but failing for the example below seems wrong:

//> using scala 3.4.0
//> using dep dev.zio::zio-schema:1.0.1
//> using dep dev.zio::zio-schema-derivation:1.0.1
sealed trait Thing
object Thing:
  sealed trait Intermediate1 extends Thing
  case object Object1 extends Intermediate1
  sealed trait Intermediate2 extends Thing
// with the following line commented out: "Deriving schema for Thing is not supported"
//  case object Object2 extends Intermediate2
  given schema: zio.schema.Schema[Thing] = zio.schema.DeriveSchema.gen[Thing]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions