class Apipie::ResponseDescription
Attributes
code[R]
description[R]
hash_validator[R]
is_array_of[R]
scope[R]
type_ref[R]
Public Class Methods
from_dsl_data(method_description, code, args)
click to toggle source
# File lib/apipie/response_description.rb, line 56 def self.from_dsl_data(method_description, code, args) options, scope, block, adapter = args Apipie::ResponseDescription.new(method_description, code, options, scope, block, adapter) end
new(method_description, code, options, scope, block, adapter)
click to toggle source
# File lib/apipie/response_description.rb, line 76 def initialize(method_description, code, options, scope, block, adapter) @type_ref = options[:param_group] @is_array_of = options[:array_of] || false raise ReturnsMultipleDefinitionError, options if @is_array_of && @type_ref @type_ref ||= @is_array_of @method_description = method_description if code.is_a? Symbol @code = Rack::Utils::SYMBOL_TO_STATUS_CODE[code] else @code = code end @description = options[:desc] if @description.nil? @description = Rack::Utils::HTTP_STATUS_CODES[@code] raise "Cannot infer description from status code #{@code}" if @description.nil? end @scope = scope if adapter @response_object = adapter else @response_object = ResponseObject.new(method_description, scope, block, @type_ref) end @response_object.additional_properties ||= options[:additional_properties] end
Public Instance Methods
additional_properties()
click to toggle source
# File lib/apipie/response_description.rb, line 116 def additional_properties !!@response_object.additional_properties end
Also aliased as: allow_additional_properties
is_array?()
click to toggle source
# File lib/apipie/response_description.rb, line 67 def is_array? @is_array_of != false end
param_description()
click to toggle source
# File lib/apipie/response_description.rb, line 108 def param_description nil end
params_ordered()
click to toggle source
# File lib/apipie/response_description.rb, line 112 def params_ordered @response_object.params_ordered end
to_json(lang=nil)
click to toggle source
# File lib/apipie/response_description.rb, line 121 def to_json(lang=nil) { :code => code, :description => description, :is_array => is_array?, :returns_object => params_ordered.map{ |param| param.to_json(lang).tap{|h| h.delete(:validations) }}.flatten, :additional_properties => additional_properties, } end
typename()
click to toggle source
# File lib/apipie/response_description.rb, line 71 def typename @response_object.typename end