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

How do you convert json schema to json type def #11

Open
reubano opened this issue Jan 17, 2022 · 1 comment
Open

How do you convert json schema to json type def #11

reubano opened this issue Jan 17, 2022 · 1 comment

Comments

@reubano
Copy link

reubano commented Jan 17, 2022

I don't see how to convert from json schema anywhere in these repos or the website. I'd love to be able to use your Python code generation tools with json schema as an input. And since json schema is more widely supported, I'd like to keep the source of truth as json schema.

@uint
Copy link

uint commented Dec 14, 2022

I'm in no way related to this project, but you're asking for something that's tricky to code and a nightmare to maintain.

JSON Schema is a lot more expressive than Typedef and tends to bring a kind of ambiguity with it (your data structures can be represented in multiple ways in the schema). It can describe a broader range of things than Typedef can. There's a reason codegen tools that accept JSON Schema tend to only allow a subset of it. JSON Schema was optimized for validation and expressing just about anything, not codegen.

I think trying to write a generic tool which accepts any JSON Schema on input is asking for trouble. But if you only use a well-defined subset of JSON Schema, maybe you could write a thing that translates that to Typedef for your own specific needs.

Also consider the opposite approach - keep Typedef as your source of truth, and generate JSON Schema out of Typedef. I imagine that would be much more sane.

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