I took me quite some time to figure out how to parse a json body with jsoniter-scala where one of the fields is a (Scala 3) enum.
This is what works:
enum ColorEnum:
case Green extends ColorEnum
case Pink extends ColorEnum
object ColorEnum:
given JsonValueCodec[ContextSource] = JsonCodecMaker.make(
CodecMakerConfig.withDiscriminatorFieldName(None)
)
given Schema.derivedEnumeration.defaultStringBased
The following issue gave the hint to add the additional config in the JsconCodecMaker: plokhotnyuk/jsoniter-scala#1268.
I would imagine that tapir users would appreciate a hint for this in the docs on tapir's Enumeration support.
Happy to open a PR for this.
I took me quite some time to figure out how to parse a json body with
jsoniter-scalawhere one of the fields is a (Scala 3) enum.This is what works:
The following issue gave the hint to add the additional config in the JsconCodecMaker: plokhotnyuk/jsoniter-scala#1268.
I would imagine that tapir users would appreciate a hint for this in the docs on tapir's Enumeration support.
Happy to open a PR for this.