Skip to content

Instantly share code, notes, and snippets.

@ducin

ducin/README.md

Last active Apr 15, 2018
Embed
What would you like to do?
JSON-Schema-faker console basic demo

JSON-Schema-faker demo

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
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment