-
Notifications
You must be signed in to change notification settings - Fork 10
Union types improvements #41
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
Conversation
That is a pretty client API!
The changes in |
@davidmigloz Checkout the latest
Inspect the resulting output on Not comprehensive, but it exercises the Anyway, if you execute those tests on this branch you will see a bunch of things start to fail and some schemas are not even generated (hence the file exist checks). Let me know if you have troubles resolving the failing test. Here are two things I saw:
|
ahh good one. I think I know how to fix it easily. We just need to treat fields with |
Sorry, I haven't got time to look into it yet. I'll have some time this weekend! |
I've moved the first commit of this PR to a separate one (#45) as it's not related to unions. I'll try to work on this PR today. |
Closing in favor of newer solutions to come soon. |
Sorry @walsha2! I never found the time to finish this work.. |
No worries! I have plans for a rewrite to get it to a 1.0 sometime in the near future. Just need to find the time 😅 |
Sounds great, count with me if you need help. I have this branch with some minor fixes that I was going to send you PRs for, but never did: It's the fork I use to generate all the clients we use in LangChain.dart. |
This PR reworks union classes:
oneOf
root schemas not generating union classesonSchemaUnionFactoryName
(resolves Support customizing factory constructors names from union types #33)onSchemaName
Union
prefix to be the default)list
instead ofarray
)The last commit is a (real) example of the code it generates that touches several edge cases (I've included it just for the sake of reviewing the PR, we can remove it before merging).
I've also regenerated and tested the
openai_dart
client with these changes (you can see the diff here). All is working fine and the new factories look much nicer 🙂Some of the code could be improved in the future to reduce duplications.
Let me know what you think!
cc @walsha2