typerator
v0.1.0
Published
JSON schema detector
Downloads
4
Readme
typerator : get JSON-schema from your data
How to get it
The module is only available on npm for the moment : npm install typerator
How to use it
getType
Returns the JSON schema of the passed parameter.
Example :
var typerator = require('typerator');
var a = 42;
var b = 'yolo';
var c = {
a: {
f: 'test'
},
b: 34
};
var d = [1, 2, [1, 3], {a: 23}];
var typeA = typerator.getType(a);
var typeB = typerator.getType(b);
var typeC = typerator.getType(c);
var typeD = typerator.getType(d);
union(typeA, typeB)
Returns the JSON schema resulting of the union of the schema typeA and typeB.
// Using types defined in the previous part
var unionAB = typerator.union(typeA, typeB);
// etc ...
typeToString(type)
Format a JSON schema into string
console.log(typerator.typeToString(typeA));
Hacking the source code
This project uses Ramda, some ES6 features and Gulp to transpile the library into ES5.
You'll need to install : gulp, gulp-babel and gulp-rename.