-
Notifications
You must be signed in to change notification settings - Fork 4
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
Script to generate JSON Schema from CDDL #23
Comments
I agree that manual translation is not a viable option. That said, the "cddl" npm package doesn't seem viable at this time, either. From the project's documentation:
We've already experienced friction from neglecting this warning when we had to change our use of CDDL to accommodate the parser's limitations. I doubt that we'll have a better experience if we build code on top of that module in its current state. On the other hand, the "cddl" Rust crate seems more mature. It's documentation is a little cautionary:
...but the WebDriver BiDi proposal are among its current users. My search for alternatives has only turned up a couple other CDDL parsers (one in Java and one in Ruby), but both appear to have been decommissioned. I think that if we want to offer a JSON Schema representation, automating its generation with the "cddl" Rust crate is the way to go. |
A semantic difference between JSON Schema and CDDL to keep in mind when converting is, similarly to W3C XML Schema vs. RELAX NG, the former starts with "everything is allowed" and you need to disallow things, and the latter starts with "everything is disallowed" and you need to allow things. This can make it tricky when combining schemas and you don't want to allow arbitrary keys for an object, for example. |
Hey folks, |
@jugglinmike is this still relevant? |
@lolaodelola Yup! |
In #19 I wrote a script to extract the CDDL fragments from
index.bs
and put them into two CDDL files (one for the remote end definition and one for the local end definition). I also manually converted them to JSON Schema.The script also imports the
cddl
npm package, which is able to parse the CDDL. My idea was that it should be possible to iterate over the parsed AST and from that generate equivalent JSON Schema, such that the output is the same as the manually-crafted JSON Schemas (modulo formatting).This is lower priority than tackling the MVP milestones in the roadmap #15, but still seems worthwhile since manually maintaining the JSON Schemas seems error prone at best.
The text was updated successfully, but these errors were encountered: