Schema
Language-agnostic schema package manager for better data models, built with component.
Features
- write reusable JSON schemas to define data models
- no registry publishing or account required, uses github repositories
- automatic versioning using git commit ids.
Installation
With node.js previously installed:
npm install -g schema-plugin
To install any schema:
component install <org/repo>
To build a ./build/schema.json
file from components:
schema build
To build it as a standalone javascript file:
schema build -s
To use use in the component build process:
var schema = require('schema-plugin');
var Builder = require('component-builder');
var builder = new Builder;
builder.use(schema);
builder.build(function(err, out){
console.log(out.schema);
});
Notes
Reserved properties
- name
- type
- description
- title
- image
- url
- value
The value associated with the value
key must be either a string, a number, true, false or null.
The value associated with the type
key must be a term, a compact IRI, an absolute IRI, a relative IRI, or null.
Todo
Maybe refactor component.json builder/package/installer so it can point to different json files:
https://github.com/component/package.js/blob/master/index.js https://github.com/component/installer.js/blob/master/lib/installer.js https://github.com/component/component/blob/master/bin/component-install https://github.com/component/builder.js/tree/master/lib
Maybe that stuff can go into tooljs.
Maybe you can do schema build --for node,component
and it creates the node_modules for each component so they can be used too.
schema create user
schema build schema.json
# something like
schema build --node_modules --component --json
schema validate ./data.json --against ./schema.json
Maybe should work similar to brew tap x
, so you can bundle schemas into single repos.
Licence
- MIT
- Surveying icon by Luis Prado from The Noun Project