You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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,
it took a while until I got the cddl NPM package back from my former employer and I started to continue working on the parser again to help the Browser Testing and Tools WG validate their CDDL interface. I started work on a compiler into TypeScript. Compiling the AST into a JSON Schema should be much easier given it is basically just a restructured AST.
I am not sure how much time I get to spend on this, given it is not my primary job and more side hobby. If the current CDDL Rust package does the job, go with that one.
Activity
jugglinmike commentedon Nov 23, 2022
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.
zcorpan commentedon Nov 23, 2022
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.
christian-bromann commentedon May 5, 2023
Hey folks,
it took a while until I got the
cddlNPM package back from my former employer and I started to continue working on the parser again to help the Browser Testing and Tools WG validate their CDDL interface. I started work on a compiler into TypeScript. Compiling the AST into a JSON Schema should be much easier given it is basically just a restructured AST.I am not sure how much time I get to spend on this, given it is not my primary job and more side hobby. If the current CDDL Rust package does the job, go with that one.
lolaodelola commentedon Jan 29, 2024
@jugglinmike is this still relevant?
jugglinmike commentedon Jan 29, 2024
@lolaodelola Yup!