-
-
Notifications
You must be signed in to change notification settings - Fork 250
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
Add derivation of Schema
for union types (towards #1926)
#2215
Add derivation of Schema
for union types (towards #1926)
#2215
Conversation
0865937
to
110f244
Compare
b9824cb
to
afc5f4e
Compare
afc5f4e
to
1f52a28
Compare
Awesome! Love it! Do you know whether it also works with opaque types? Also, totally out of the scope of this PR, but would a similar approach also work for using intersection types for interfaces? |
1f52a28
to
29b37f1
Compare
My understanding is that opaque types really just need to fetch an instance of the underlying type and expose it in its companion object where it's known that the two types are the same. I haven't tried it yet, but there is a chance it could be easy.
Interesting idea. This code here follows I rebased the branch again now, so hopefully it's good to go. |
Is this still missing? |
For annotations it would just be calls to
Do you think you'll be able to add them? If not, we can probably merge it and someone else opens an other PR. |
Btw I checked that the magnolia macro we use to get annotations works on type aliases: https://scastie.scala-lang.org/rI5LUKi5TrKCCbZ3tkrZNQ |
Thanks for the pointers. Added annotation handling now 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Finally found time to implement a first iteration of this this.
A patch for the codegen will probably be forthcoming, but this at least allows us to use union types with a bit more ease than before.
Usage looks like this:
This will produce a schema like this:
Limitations:
Schema.unionType
. The compile will fail otherwise.No annotations are picked up yet. It probably works the same as for the other cases, but I didn't have time to implement it now.