github zio/zio-config v4.0.0-RC14

latest releases: v4.0.2, v4.0.1, v4.0.0...
18 months ago

Updates

  • Add type-discriminator support for scala-3 auto derivation. Note that this support already existed in scala-2 auto derivation
import zio.config._, magnolia._, typesafe._

@nameWithLabel("type")
sealed trait FooBar

case class Foo(name: String) extends FooBar
case class Bar() extends FooBar

case class MyConfig(a: FooBar, b: FooBar)

val hocon = 
 s"""
   {
     a : {
       type : Foo
       name : baz
     },

     # Bar is just name since it has no fields, and therefore no need of type descriminator 
     b : Bar
   }

 """

ConfigProvder.fromHoconString(hocon).load(deriveConfig[MyConfig])

Find more examples here:

https://github.com/zio/zio-config/tree/series/4.x/magnolia/shared/src/main/scala-dotty/zio/config/magnolia/examples

https://github.com/zio/zio-config/blob/series/4.x/examples/shared/src/main/scala/zio/config/examples/autoderivation/AutoDerivationPureConfig.scala

Don't miss a new zio-config release

NewReleases is sending notifications on new releases.