Sha256: 8d42ff902749e29448d79a7bf88f20573267ae8a3e0f3bd960b800a994b3ec01
Contents?: true
Size: 1.85 KB
Versions: 7
Compression:
Stored size: 1.85 KB
Contents
require 'tomograph/tomogram/action' module Tomograph module ApiBlueprint class Yaml class Action def initialize(content, path, resource) @content = content @path = path @resource = resource end attr_reader :path, :resource def method @method ||= @content.first['attributes']['method'] end def content_type @content_type ||= @content.first['attributes'].has_key?('headers') ? @content.first['attributes']['headers']['content'][0]['content']['value']['content'] : nil end def request return @request if @request request_action = @content.find { |el| el['element'] == 'httpRequest' } @request = json_schema(request_action['content']) end def json_schema(actions) schema_node = actions.find do |action| action && action['element'] == 'asset' && action['attributes']['contentType'] == 'application/schema+json' end return {} unless schema_node MultiJson.load(schema_node['content']) rescue MultiJson::ParseError => e puts "[Tomograph] Error while parsing #{e}. skipping..." {} end def responses return @responses if @responses @responses = @content.select do |response| response['element'] == 'httpResponse' && response['attributes'] end @responses = @responses.map do |response| { 'status' => response['attributes']['statusCode'], 'body' => json_schema(response['content']), 'content-type' => response['attributes'].has_key?('headers') ? response['attributes']['headers']['content'][0]['content']['value']['content'] : nil } end end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems