-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optional type discriminator #286
Comments
Hi! I had the same problem of this and ended up doing this:
This seems silly, but what this is essentially doing is telling the type system to look for your implicitly defined case class encoders and use those instead of the ADT encoder. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello!
I have a domain model (for consul api) and want to encode/decode types like
Check
andServiceCheck
and their subtypes . The issue is in model encoding/decoding results. Classes :and encoders/decoders:
When i encode instance of any subtype of
Check
orServiceCheck
i get a json object like this:The api does not recognise field
ScriptCheck
and fails with an error. If i try to encode ScriptCheck explicitly using encoder forScriptCheck
type then json will not have type discriminator.I tried to use annotations with empty values
@jsonHint("")
and@jsonDiscriminator("")
, as i thought that it will remove it because in macros there is a code like this:but got an error:
Also, i tried to construct encoder using
eitherWith
, but in result i get a json with additional fieldLeft
orRight
.In the meantime, decoder can be constructed using
orElse
and it will not require type discriminator.Is it possible to completely remove type discriminator?
The text was updated successfully, but these errors were encountered: