Skip to content

Instantly share code, notes, and snippets.

@ducin
Last active January 23, 2016 18:47
Show Gist options
  • Save ducin/87e0b55bddd1801d3d99 to your computer and use it in GitHub Desktop.
Save ducin/87e0b55bddd1801d3d99 to your computer and use it in GitHub Desktop.
Grunt JSON-Schema-faker basic demo
node_modules/
output/

Grunt JSON-Schema-faker demo

Run the following:

npm install -g grunt-cli # if not installed yet
npm install
grunt

to execute the demo. Then check output directory.

module.exports = function (grunt){
grunt.initConfig({
jsonschema_faker: {
options: {
indent: 2
},
sample: {
src: 'sample.json',
dest: 'output/sample.json',
options: {
size: 20
}
}
}
});
grunt.loadNpmTasks('grunt-jsonschema-faker');
// By default, run jsf
grunt.registerTask('default', ['jsonschema_faker']);
};
{
"name": "jsf-demo",
"description": "Grunt JSON-Schema-faker demo gist",
"dependencies": {
"grunt": "^0.4.5",
"grunt-jsonschema-faker": "^0.2.3"
}
}
{
"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