Sha256: c105f64534187ecbecb8a4c79807f27fab14d085205f8f7fa6365273c90627e1
Contents?: true
Size: 856 Bytes
Versions: 2
Compression:
Stored size: 856 Bytes
Contents
require 'json-schema' module Fitting class Request def initialize(env_request, tomogram) @method = env_request.request_method @path = env_request.env['PATH_INFO'] || env_request.fullpath @body = env_request.env['action_dispatch.request.request_parameters'] @schema = tomogram.find_request(method: @method, path: @path) @fully_validate = JSON::Validator.fully_validate(@schema.request, @body) if @schema @valid = false @valid = true if @fully_validate == [] self end def route "#{@schema.method}\t#{@schema.path}" end def real_method_with_path "#{@method}\t#{@path}" end def schemas_of_possible_responses(status:) if @schema @schema.find_responses(status: status).map do |response| response['body'] end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fitting-2.0.2 | lib/fitting/request.rb |
fitting-2.0.1 | lib/fitting/request.rb |