Leason
A JSON schema learner.
The concept of Leason is simple: learn the schema by feeding json documents.
Install:
npm i leason -g
CLI:
$ bin/leason Usage: leason [options] Options: -h, --help output usage information -V, --version output the version number -t, --title add titles -f, --format try to detect format -e, --enum try to detect enum -s, --similar <n> merge similar objects
Script:
var Leason = ;var json = ; var leason = leason; console;
Result:
"$schema": "http://json-schema.org/draft-04/schema#" "type": "object" "properties": "name": "type": "string" "version": "type": "string" "description": "type": "string" "main": "type": "string" "watch": "type": "object" "properties": "test": "type": "array" "items": "type": "string" "bin": "type": "object" "properties": "leason": "type": "string" "scripts": "type": "object" "properties": "test": "type": "string" "watch": "type": "string" "author": "type": "string" "license": "type": "string" "dependencies": "type": "object" "properties": "type-of": "type": "string" "commander": "type": "string" "devDependencies": "type": "object" "properties": "js-yaml": "type": "string" "tape": "type": "string" "tap-spec": "type": "string" "glob": "type": "string" "npm-watch": "type": "string" "jshint": "type": "string"
As one can see there still is much to be desired.
Some goals:
- learn types
- learn formats (by testing validation)
- detect enum (just give up after 20) or a certain treshold.
- advanced. more filters to detect similarity.
- tresholds for each filter. 95% match, means 5% is probably invalid or not. that's why treshold.
- description filling
- optional title setter. just capitalize, humanize.
- auto refactor common parts into definitions.