Sha256: 06e4e94814ff32403bcaeda7794c32e242ba826d4f13b58c15572596deb9c671
Contents?: true
Size: 758 Bytes
Versions: 1
Compression:
Stored size: 758 Bytes
Contents
require 'json-schema' module Esplanade class Request attr_accessor :path, :method, :body, :schema class Unsuitable < RuntimeError; end class NotDocumented < RuntimeError; end def initialize(env, tomogram) @method = env['REQUEST_METHOD'] @path = env['PATH_INFO'] @body = Body.craft(env) @schema = tomogram.find_request(method: @method, path: @path) raise NotDocumented unless schema || Esplanade.configuration.skip_not_documented self end def error JSON::Validator.fully_validate(@schema['request'], @body) end def valid! raise Unsuitable, error unless error.empty? end def validate? @schema && Esplanade.configuration.validation_requests end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
esplanade-0.1.0 | lib/esplanade/request.rb |