Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Autogenerate SDK #257

Open
imp opened this issue Apr 22, 2020 · 2 comments
Open

Autogenerate SDK #257

imp opened this issue Apr 22, 2020 · 2 comments

Comments

@imp
Copy link

imp commented Apr 22, 2020

Just tossing the idea - is it possible to autogenerate the SDK for Azure services?
Similar to what rusoto does - is it practical to take the specs and use codgen to build the basic building blocks for all the services? This may create a nice platform to create a higher level SDK and not spend time on mechanical coding [and maintaining!] vast number of interfaces.

@MindFlavor
Copy link
Owner

That's partially what I've been doing using this tool: bpb. It's a custom tool build just for that, it takes json files and spits out a builder pattern request generator. This is a sample json: azure_sdk_cosmos/src/requests/create_slug_attachment_builder.json. It takes care of the generation of only, the execute code must be written by hand at the moment. While it could be automated I found out there are so many nitpicks that will make the effort not worthwhile (the only exception being the traits parameter headers).
While the bpb tool does only cover the builder pattern that's the bulk of the repetitive code (There is another issue about this too: #250). For example, the file generated from the above json (azure_sdk_cosmos/src/requests/create_slug_attachment_builder.rs) has 341 lines but only 42 have to be written by hand (the rest is autogenerated).
Also a complete automation would require a procedural macro and - while powerful - I fear they would make the code harder to understand and to contribute to.
Last but not least one of the goal of these creates is to be as rusty as possible (for example we prefer compile time errors instead of runtime ones whenever possible) so it's useful to be able to use a different approach for every method.

@imp
Copy link
Author

imp commented Apr 26, 2020

Glad to hear that you have similar ideas in working! I had a really quick experiment with openapi-generator and it feels like there is a fair amount of heavy lifting that can be offloaded to it. Or perhaps it and bpb can be combined together to automate things even further?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants