Class: Swagger::Grape::Type

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-swagger/grape/type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type) ⇒ Type

Returns a new instance of Type.



6
7
8
# File 'lib/ruby-swagger/grape/type.rb', line 6

def initialize(type)
  @type = type.to_s || 'String'
end

Instance Attribute Details

#discovered_typesObject (readonly)

Returns the value of attribute discovered_types.



4
5
6
# File 'lib/ruby-swagger/grape/type.rb', line 4

def discovered_types
  @discovered_types
end

Instance Method Details

#sub_typesObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ruby-swagger/grape/type.rb', line 14

def sub_types
  type = Object.const_get(@type)
  return [] unless type.respond_to?(:exposures)

  types = []

  type.exposures.each do |property, definition|
    types << definition[:using] if definition[:using].present?
  end

  types.uniq
end

#to_swagger(with_definition = true) ⇒ Object



10
11
12
# File 'lib/ruby-swagger/grape/type.rb', line 10

def to_swagger(with_definition = true)
  type_convert(@type.to_s, with_definition)
end