evestera / json_typegen

Tools and libraries to create types for Rust, Kotlin, TypeScript and Python from JSON samples
https://typegen.vestera.as
Apache License 2.0
268 stars 26 forks source link

Update npm package #39

Closed bragle closed 4 months ago

bragle commented 12 months ago

I've been using json_typegen_wasm and it's great! Noticed the npm package is a bit behind the repo. Any chance we could get a new release? It'd be awesome to have the recent additions, especially around pydantic.

sbarre commented 7 months ago

I realize this is slightly unrelated to your question but I have been trying to use the npm package myself but there's no readme or description, and I haven't been able to import or require it in normal ways.

I've used the WebAssembly.instantiate method directly with the .wasm file but that doesn't seem to work either.

Would you mind sharing how you are importing the npm package into an application @bragle ?

Are you using it in the browser or in a Node environment?

Edit: I figured this out. The NPM package is not importable without transpilation, so I had to pull out the wasm and js files and bring them in differently in order to run them directly in Node.

bragle commented 7 months ago

@sbarre I'm running it in the browser, but I ended up just building it myself so I can run the newest version. You can see it in action here: https://devina.io/json-type-generator. I'd be happy to share my github workflow file with you. I haven't tested it, but I'm guessing it'll work in node as well

sbarre commented 7 months ago

Thanks for the offer, it's very kind, but I did manage to get this running in Node.. It took a bit of wrangling but it's working fine now, without any transpiling.

This library didn't end up being as useful as I hoped, as it can't (rightfully) use a lot of the more advanced JSON schema features like min/max, or conditionals, because it can only work from the one provided JSON example.