Skip to content
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

automatic Json.Decode.Decoder out of schema? #22

Open
amitu opened this issue Jun 18, 2017 · 4 comments
Open

automatic Json.Decode.Decoder out of schema? #22

amitu opened this issue Jun 18, 2017 · 4 comments

Comments

@amitu
Copy link
Contributor

amitu commented Jun 18, 2017

So I have setup a tooling that looks at Schema defined in my elm file, and generates python and go code to auto validate input/output/error cases. Now when I modify schema, my unit tests in python fail (they don't even check the schema, just assert that schema is getting verified).

But now my elm code has become "test at runtime", I change some APIs, then I have to manually go through the appropriate manual steps in browser that triggers API, and then I detect that my decode in elm frontend code is no longer compatible with my API-schema.

If there was a way to auto generate elm decoder out of schema, the runtime problem will become compile time problem for me.

Has anybody given any thought to how hard/easy would it be? Or is there some library / tool already available that does this?

@ericgj
Copy link
Contributor

ericgj commented Jan 5, 2018

Curious if you got anywhere with this. Seems like it might be possible with an additional schema property for the constructor name. To generate the decoder code, not the code for types themselves, right?

@amitu
Copy link
Contributor Author

amitu commented Jan 6, 2018

No. Nothing yet.

@ericgj
Copy link
Contributor

ericgj commented Jan 7, 2018

By the way, that python tooling sounds great. Is it open source/any chance you could share it? I'd love to have something like that.

@amitu
Copy link
Contributor Author

amitu commented Jan 7, 2018

https://gist.github.com/amitu/f6241ed802afa3312713efd03ef10509

No time to clean it up, but I think the gist should be mostly self contained. Do let me know if you want me to explain anything, or share any more utilities.

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

No branches or pull requests

2 participants