Concise data definition language (RFC 8610) implementation for JSON validator & code generator in Node.js
CDDL expresses Concise Binary Object Representation (CBOR) data structures (RFC 7049). Its main goal is to provide an easy and unambiguous way to express structures for protocol messages and data formats that use CBOR or JSON.
There are also CDDL parsers for other languages:
- Rust: anweiss/cddl
The package is currently mostly used to help generate typed interfaces for the WebDriver Bidi specification in the following projects:
- WebdriverIO - via the
cddl2tspackage and this script - Selenium - via the
cddl2javapackage
Note: this is work in progress, feel free to have a look at the code or contribute but don't use this for anything yet!
To install one of the packages run:
# Parser & validator
$ npm install @wdio/cddl
# Generate typescript definition
$ npm install @wdio/cddl2tsThe packages expose a CLI as well as a programmatic interface for parsing and transforming CDDL.
The cddl CLI offers a validate command that helps identify invalid CDDL formats, e.g.:
npx @wdio/cddl validate ./path/to/interface.cddl
✅ Valid CDDL file!The cddl2ts CLI allows transforming CDDL into TypeScript:
npx @wdio/cddl2ts ./path/to/interface.cddl &> ./path/to/interface.tsYou can import any of the packages into your typescript project for an easy integration
If you are interested in this project, please feel free to contribute ideas or code patches. Have a look at our contributing guidelines to get started.