JsonSchemaValidator

This gem provides methods to run a schema, through any available Schema Validators for Ruby.

They should be valid according to draft-4 ...

The schema validators currently being considered are:

These are the three currently available ruby validators that support draft-4. (According to json-schema.org).

Each validator gem has its quirks, we'll try to:

  • use each to validate a schema against the json-schema meta-schema
  • try to load each given schema as a schema for validation.

Installation

Add this line to your application's Gemfile:

gem 'json_schema_validator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install json_schema_validator

Usage

In your tests you can validate your schemas against the meta-schema with:

schema_path = /path/to/my/schemas
errors = JsonSchemaValidator.validate_schemas(schema_path)
# each schema validator adds his own error message
errors.each do |name, error|
  expect(error).to be_empty
end

TODO

Not perfect yet, since it was extracted from the gem fidor_schema. For now you need to read the code to find out about the detailed usage.

  • improve log output / handling
  • HowTO on validate data against the schema-draft v4 meta schema
  • add tests

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake rspec to run the tests.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/fidor/json_schema_validator