You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #203 is completed, then each specified annotation may be implemented for each of the supported codecs for which it makes sense to support the annotation.
This ticket is to implement the @caseName annotation. This annotation, which may be applied to any case (subtype) of a sealed trait (enumeration), means to specify the "serialization" name of the case to which it is applied.
For example, maybe we wish the CreditCard subtype of PaymentMethod to be stored with a name of credit_card, rather than CreditCard, but we do not wish to name our Scala data type credit_card, because it is not idiomatic. This annotation would allow us to apply @caseName("credit_card") to the CreditCard data type, and then, the identity of the case would be credit_card rather than CreditCard (so if used in combination with @discriminatorName, would result in "type": "credit_card" in generated JSON, for example).
The main place where this new annotation should be used is in Schema auto-derivation. Right now, ZIO Schema will generate Schema.Case value together with an identity for the subtype for each case (subtype) of an enumeration (sealed trait). These term ids use the Scala case names (the names of the case classes that extend the sealed trait). But, in the presence of this annotation, they should instead use the specified name.
There are two ways to implement this ticket:
Modifying the Scala 2 / Scala 3 macros to generate a different value for the case names, if this annotation is present.
Post-processing the auto-generated Schema to incorporate changes brought about by annotations such as caseName.
The text was updated successfully, but these errors were encountered:
After #203 is completed, then each specified annotation may be implemented for each of the supported codecs for which it makes sense to support the annotation.
This ticket is to implement the
@caseName
annotation. This annotation, which may be applied to any case (subtype) of asealed trait
(enumeration), means to specify the "serialization" name of the case to which it is applied.For example, maybe we wish the
CreditCard
subtype ofPaymentMethod
to be stored with a name ofcredit_card
, rather thanCreditCard
, but we do not wish to name our Scala data typecredit_card
, because it is not idiomatic. This annotation would allow us to apply@caseName("credit_card")
to theCreditCard
data type, and then, the identity of the case would becredit_card
rather thanCreditCard
(so if used in combination with@discriminatorName
, would result in"type": "credit_card"
in generated JSON, for example).The main place where this new annotation should be used is in Schema auto-derivation. Right now, ZIO Schema will generate
Schema.Case
value together with an identity for the subtype for each case (subtype) of an enumeration (sealed trait
). These term ids use the Scala case names (the names of thecase class
es that extend thesealed trait
). But, in the presence of this annotation, they should instead use the specified name.There are two ways to implement this ticket:
caseName
.The text was updated successfully, but these errors were encountered: