(Scala 2)
type WsTag = WsTag.Type
object WsTag extends NewtypeWrapped[Option[Long]] with DerivedCirceCodec
case class A(wsTag: WsTag, i: Int)
implicit val decoder: Decoder[A] = io.circe.generic.semiauto.deriveDecoder
println(io.circe.parser.parse("""{"i" : 1}""").value.as[A])
results in
Left(DecodingFailure at .wsTag: Missing required field)
Replacing WsTag with the underlying type Option[Long] in A gets rid of the error:
case class A(wsTag: Option[Long], i: Int)
println(io.circe.parser.parse("""{"i" : 1}""").value.as[A])
> Right(A(None,1))
(Scala 2)
results in
Replacing
WsTagwith the underlying typeOption[Long]inAgets rid of the error: