Fuzzing Parameter Generator from JSON Schema
Add this line to your application's Gemfile:
gem 'json-fuzz-generator'
And then execute:
$ bundle
Or install it yourself as:
$ gem install json-fuzz-generator
{
"title": "Basic Schema",
"type": "object",
"properties": {
"id" : {
"type": "integer",
"minimum": 0
},
"name": {
"type": "string"
},
"birthday": {
"type": "string",
"format": "date"
}
}
}
require "json-fuzz-generator"
JSON::Fuzz::Generator.default_param(schema_file)
# => {"id"=>0, "name"=>"hoge", "birthday"=>"1992-06-27"}
require "json-fuzz-generator"
JSON::Fuzz::Generator.generate(schema_file)
# =>
#[
# ["sample", "array"],
# true,
# 73,
# nil,
# 0.34259093948835795,
# "hoge",
# {"id"=>"a", "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>"1", "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>0.1, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>["sample", "array"], "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>false, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>nil, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>0.0, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>{}, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>"hoge", "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>-1, "name"=>"hoge", "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>["sample", "array"], "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>true, "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>97, "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>nil, "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>0.7547537108664406, "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>{}, "birthday"=>"1992-06-27"},
# {"id"=>0, "name"=>"hoge", "birthday"=>["sample", "array"]},
# {"id"=>0, "name"=>"hoge", "birthday"=>false},
# {"id"=>0, "name"=>"hoge", "birthday"=>11},
# {"id"=>0, "name"=>"hoge", "birthday"=>nil},
# {"id"=>0, "name"=>"hoge", "birthday"=>0.5380909041403419},
# {"id"=>0, "name"=>"hoge", "birthday"=>{}},
# {"id"=>0, "name"=>"hoge", "birthday"=>"2010-01-32"},
# {"id"=>0, "name"=>"hoge", "birthday"=>"n2010-01-01"},
# {"id"=>0, "name"=>"hoge", "birthday"=>"2010-1-01"},
# {"id"=>0, "name"=>"hoge", "birthday"=>"2010-01-1"},
# {"id"=>0, "name"=>"hoge", "birthday"=>"2010-01-01n"},
#]
- Fork it ( https://github.com/deme0607/json-fuzz-generator/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request