Skip to content

Instantly share code, notes, and snippets.

@ducin
Last active April 15, 2018 15:33
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ducin/9f2364ccde2e9248fbcd to your computer and use it in GitHub Desktop.
Save ducin/9f2364ccde2e9248fbcd to your computer and use it in GitHub Desktop.
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