class Swaggard::Swagger::Response::ResponseModel

Attributes

id[RW]
response_class[RW]

Public Instance Methods

parse(value) click to toggle source
# File lib/swaggard/swagger/response.rb, line 79
def parse(value)
  @is_array_response = value =~ /Array/
  @response_class = if @is_array_response
                      value.match(/^Array<(.*)>$/)[1]
                    else
                      value
                    end
end
response_class_type() click to toggle source
# File lib/swaggard/swagger/response.rb, line 99
def response_class_type
  if PRIMITIVE_TYPES.include?(@response_class)
    { 'type' => @response_class }
  else
    { '$ref' => "#/definitions/#@response_class" }
  end
end
to_doc() click to toggle source
# File lib/swaggard/swagger/response.rb, line 88
def to_doc
  if @is_array_response
    {
      'type'  => 'array',
      'items' => response_class_type
    }
  else
    response_class_type
  end
end