This gem helps you to validate and synchronize your API in strict accordance to the documentation in API Blueprint and OpenAPI formats. To do this it automatically searches received requests and responses in the documentation and run JSON-schemas validators.
- Installation
- Usage
- Middlewares
- Esplanade::Error
- Middleware args
- License
Add this line to your application's Gemfile:
gem 'esplanade'
After that execute:
$ bundle
Or install the gem by yourself:
$ gem install esplanade
config/application.rb
:
config.middleware.use Esplanade::SafeMiddleware, drafter_yaml_path: 'doc.yaml'
Debug logger.
It throws errors, so you should add your own middleware for processing.
config.middleware.use YourMiddleware
config.middleware.use Esplanade::DangerousMiddleware, drafter_yaml_path: 'doc.yaml'
Use it if you want to be sure that you have documented new custom responses.
config.middleware.use Esplanade::CheckCustomResponseMiddleware, drafter_yaml_path: 'doc.yaml'
config.middleware.use YourMiddleware
config.middleware.use Esplanade::DangerousMiddleware, drafter_yaml_path: 'doc.yaml'
Parent class for those described below.
Parent class for those described below. Inherited from Esplanade::Error
.
Error message format:
{
:method => "method",
:path => "path",
:raw_path => "path",
:content_type => "content_type"
}
Error message format:
{
:method => "method",
:path => "path",
:raw_path => "path",
:content_type => "content_type"
}
Error message format:
{
:method => "method",
:path => "path",
:raw_path => "path",
:content_type => "content_type"
}
Throws an error also when the body is empty and equal nil.
Error message format:
{
:method => "method",
:path => "path",
:raw_path => "path",
:content_type => "content_type",
:body => "body"
}
Error message format:
{
:method => "method",
:path => "path",
:raw_path => "path",
:content_type => "content_type",
:body => "body",
:error => ["error"]
}
Parent class for those described below. Inherited from Esplanade::Error
.
Error message format:
{
:request => {
:method => "method",
:path => "path",
:raw_path => "path"
},
:status => "status"
}
It's thrown when expected response to request isn't JSON (not Content-Type: application/json
) and there's no non-JSON responses documented for the endpoint.
Error message format:
{
:request => {
:method => "method",
:path => "path",
:raw_path => "path"
},
:status => "status",
:body => "body"
}
Error message format:
{
:request => {
:method => "method",
:path => "path",
:raw_path => "path"
},
:status => "status",
:body => "body",
:error => ["error"]
}
Support any tomograph constructor-params
The gem is available as open source under the terms of the MIT License.