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

export to json schema #181

Closed
AndreaCrotti opened this issue Jun 14, 2016 · 8 comments
Closed

export to json schema #181

AndreaCrotti opened this issue Jun 14, 2016 · 8 comments

Comments

@AndreaCrotti
Copy link
Contributor

I was wondering if it was possible to convert a voluptuous schema definition into a json-schema
http://json-schema.org/documentation.html

I think the two formats are mostly overlapping in features, and at least all the basic things should be easy to convert, what do you think?

Thanks

@AndreaCrotti
Copy link
Contributor Author

Actually just found out about this other little project: https://pypi.python.org/pypi/genson

which can be used to pass in dictionaries and get a schema out of them, but probably with a direct conversion from Voluptuous to json schema we could do something even more expressive..

@tusharmakkar08
Copy link
Collaborator

Hey @AndreaCrotti : You mentioned probably with a direct conversion from Voluptuous to json schema we could do something even more expressive... Can you be a bit more explicit about the expressiveness you are talking about?

@AndreaCrotti
Copy link
Contributor Author

Well @tusharmakkar08 I mean that maybe apart from all the various type declarations we could even have some conversion rules for some validators.
That probably could not work in general but some simple validators can probably be translated easily..

@tusharmakkar08
Copy link
Collaborator

@AndreaCrotti I personally feel that it might be a overkill since projects like Genson do a pretty good job at translating dictionaries to schemas.

@AndreaCrotti
Copy link
Contributor Author

Ok no problem I'll close this then

@tusharmakkar08
Copy link
Collaborator

👍

@ssbarnea
Copy link

As someone that tried to use Genson before for generating a schema for validating Zuul config files I would say that the tool has no practical use for complex schemas. If you are lucky you may get some valid results for very basic data models, very.

Writing JSON schemas is a real PITA, it makes XML template transformation look like kindergarten stuff. If voluptuous would be able to create these schemas it would be great because there are already a big number of tools that can consume these schemas, and they validate not only JSON but also YAML and TOML as well.

For example there is the http://schemastore.org/json/ project which is a directory of >200 schemas, which is supported by lots of tools/editor/linters. In my case I used VsCode YAML extension which enabled linting of all these files for free, because it can look for schemas on that store.

In think that there are very good reasons for reopening this issue, as apparently we do have an emerging standard for schemas.

@langestefan
Copy link

I know this issue is ancient, but Genson is pretty much dead. I use this library now, it works great: voluptuous-serialize

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

4 participants