https://github.com/okitan/json_schema-faker
generate fake data for json schema
https://github.com/okitan/json_schema-faker
faker gem json-schema
Last synced: 8 months ago
JSON representation
generate fake data for json schema
- Host: GitHub
- URL: https://github.com/okitan/json_schema-faker
- Owner: okitan
- License: mit
- Created: 2016-05-15T06:35:40.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2024-01-03T23:19:50.000Z (over 2 years ago)
- Last Synced: 2025-10-07T21:56:05.096Z (8 months ago)
- Topics: faker, gem, json-schema
- Language: Ruby
- Size: 86.9 KB
- Stars: 8
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# JsonSchema::Faker [](https://travis-ci.org/okitan/json_schema-faker)
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'json_schema-faker'
```
And then execute:
$ bundle
Or install it yourself as:
$ gem install json_schema-faker
## Usage
```ruby
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](http://contributor-covenant.org) 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](http://opensource.org/licenses/MIT).