The objective of this project is to be a build tool that parses a rich domain model defined in JSON Schema (as specified in the IETF Internet Draft) in order to generate record definitions that can be used to Erlang applications to both read and write JSON.
I believe that having a formally defined object model for the data that's exchange over web resources is a major plus for APIs. It doesn't necessary imply that consumers have to generate static clients based on such a definition, but as far as the server is concerned, it raises the bar in term of consistency and opens the door for self-generated documentation.
jerg doesn't deal with the actual mapping between JSON and records: there is already a library named json_rec for that. It doesn't also deal with validation as, again, a library named jesse can take care of it.
This first version of jerg generates records with the appropriate type specification to enable type checking with dialyzer. It supports:
- cross-references for properties and collection items (ie the $ref property),
- default values,
- integer enumerations (other types can not be enumerated per limitation of the Erlang type specification).
It also supports a few extensions to JSON schema:
- extends: to allow a schema to extend another one in order to inherit all the properties of its parent (and any ancestors above it),
- abstract: to mark schemas that actually do not need to be output as records because they are just used through references and extension,
- recordName: to customize the name of the record generated from the concerned schema definition.
Enough talking: time to get started! Your next stop is jerg's GitHub project. Enjoy!