In pursuit of irony: to codegen a code generator #520
Quafadas
started this conversation in
Show and tell
Replies: 2 comments 4 replies
-
Hey, thanks for this, it might be useful Internally, we actually have some Of course it doesn't help when the API you consume doesn't give a spec but rather examples, which I believe your POC is helping with :) |
Beta Was this translation helpful? Give feedback.
2 replies
-
@Quafadas : Your PR was merged and is live at https://app.quicktype.io/ : |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Backstory
A while ago, I wanted a way to codegen scala models out of JSON schema. The end result was a fork / branch of QuickType, which generated scala code. Sadly, I don't think the PR will get merged... it's been 6 months.
glideapps/quicktype#1932
It did successfully generate case classes for the Vega schema though...
This is the branch. https://github.com/Quafadas/quicktype/tree/scala3
Smithy
I recently had a lot of fun with a greenfield smithy project. But mostly, I interact with other APIs. I was rather taken with the idea of generating smithy models, and getting lots of that boilerplate free. It's rather experimental, but in case someone else has similar desires;
Given this JSON;
https://github.com/quicktype/quicktype/blob/master/test/inputs/json/misc/dbfb3.json
The "smithy" language added to that branch of QuickType will generate this;
Having a computer do this part, is loads better than writing it out by hand for my money. It's obviously incomplete - no service definition for example.
Note - this is very prototypical / unreliable. It doesn't deal well with corner cases, funny names etc. Usually, I end up tweaking the results by hand - it's a boilerplate generator that you should assume is wrong.
With enough effort, it could possibly also become reliable, but I don't think it's worth (at least for me) further investment.
It may save you some time, if you wish to represent a third party API in smithy-land. And so, recorded here for posterity. As I have no idea how to publish anything typescripty and the PR probably won't happen... you'll need to do build / run from source if it is of interest for you. Sorry for that.
Beta Was this translation helpful? Give feedback.
All reactions