No commit activity in last 3 years
No release in over 3 years
SchemaConformist is an automatic JSON request/response validator for your API testing in Rails.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 0
~> 4.3.0
 Project Readme

SchemaConformist

Gem Version Build Status

An automatic JSON request/response validator for testing in Rails

SchemaConformist is an automatic JSON request/response validator for your API testing in Rails.

This library automatically validates that JSON requests/responses are conformant with the schema. The schema can be described as one of JSON Hyper Schema, OpenAPI 2.0 and OpenAPI 3 (currently 3.0.2 is latest).

This library uses Committee to validate JSONs.

Usage

Installation

Add this line to your application's Gemfile:

gem 'schema_conformist'

and execute bundle install.

Configure schema_path as follows (ex. using an OpenAPI 3 schema):

Rails.application.config.schema_conformist.schema_path = Rails.root.join('doc', 'openapi.yaml')

That's all. Then all JSON requests/responses in integration-test/request-spec are validated according to your schema.

Writing the Schema

Write your API schema in one of JSON Hyper Schema, OpenAPI 2 and OpenAPI 3.

See test/dummy app for examples.

Configurations

Configuration options are following:

  • schema_conformist.schema_path
    • Required. The path where the schema is placed
  • schema_conformist.ignored_api_paths
    • Optional. The array of API paths not to validate. Each path can be described in String literal (used for prefix search) or regular expression.
  • schema_conformist.committee.old_assert_behavior

Contributing

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

License

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