Sha256: 8cb60f6c6848e60a1864a741e9adf9245585e1be88a3098e2f34126fa2528d7d
Contents?: true
Size: 923 Bytes
Versions: 3
Compression:
Stored size: 923 Bytes
Contents
module Fitting class Request attr_accessor :path, :method, :body, :schema class Unsuitable < RuntimeError; end class NotDocumented < RuntimeError; end def initialize(env_request, tomogram) @method = env_request.request_method @path = env_request.env['PATH_INFO'] @body = env_request.env['action_dispatch.request.request_parameters'] @schema = tomogram.find_request(method: @method, path: @path) raise NotDocumented unless @schema || Fitting.configuration.skip_not_documented self end def valid! res = JSON::Validator.fully_validate(@schema['request'], @body) raise Unsuitable unless res.empty? end def validate? @schema && Fitting.configuration.validation_requests end def to_hash { 'method' => @method, 'path' => @path, 'body' => @body, 'schema' => @schema } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
fitting-0.4.2 | lib/fitting/request.rb |
fitting-0.4.1 | lib/fitting/request.rb |
fitting-0.3.0 | lib/fitting/request.rb |