Run the following:
npm install
node run.js
to execute the demo.
{ | |
"name": "jsf-demo", | |
"description": "JSON-Schema-faker demo gist", | |
"main": "run.js", | |
"dependencies": { | |
"json-schema-faker": "^0.2.6" | |
} | |
} |
var jsf = require('json-schema-faker'); | |
var schema = require('./schema.json'); | |
var sample = jsf(schema); | |
console.log(sample); |
{ | |
"type": "object", | |
"properties": { | |
"user": { | |
"type": "object", | |
"properties": { | |
"id": { | |
"$ref": "#/definitions/positiveInt" | |
}, | |
"name": { | |
"type": "string", | |
"faker": "name.findName" | |
}, | |
"email": { | |
"type": "string", | |
"format": "email", | |
"faker": "internet.email" | |
} | |
}, | |
"required": ["id", "name", "email"] | |
} | |
}, | |
"required": ["user"], | |
"definitions": { | |
"positiveInt": { | |
"type": "integer", | |
"minimum": 0, | |
"exclusiveMinimum": true | |
} | |
} | |
} |