Low commit activity in last 3 years
A long-lived project that still receives updates
generate fake data from json schema
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
>= 0.12.4
>= 0
 Project Readme

JsonSchema::Faker Build Status

Installation

Add this line to your application's Gemfile:

gem 'json_schema-faker'

And then execute:

$ bundle

Or install it yourself as:

$ gem install json_schema-faker

Usage

require "json_schema/faker"

raw_schema = {
  "id" => "https://example.com/schema.json",
  "$schema"    => "http://json-schema.org/draft-04/schema#",
  "properties" => { "a" => { "enum" => [ "e", "n", "u", "m" ] } },
  "required"   => [ "a" ],
}

schema = JsonSchema.parse!(raw_schema)

JsonSchema::Faker.new(schema).generate #=> { "a" => "e" }

Note: It is too difficult to correspond to complex schema.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/json_schema-faker. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

Run tests

before running rake spec, run git submodule init && git submodule update

License

The gem is available as open source under the terms of the MIT License.