Class: Swaggard::Swagger::Definition

Inherits:
Object
  • Object
show all
Defined in:
lib/swaggard/swagger/definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ Definition

Returns a new instance of Definition.



7
8
9
10
# File 'lib/swaggard/swagger/definition.rb', line 7

def initialize(id)
  @id = id
  @properties = []
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/swaggard/swagger/definition.rb', line 5

def id
  @id
end

Instance Method Details

#add_property(property) ⇒ Object



12
13
14
# File 'lib/swaggard/swagger/definition.rb', line 12

def add_property(property)
  @properties << property
end

#to_docObject



16
17
18
19
20
21
22
# File 'lib/swaggard/swagger/definition.rb', line 16

def to_doc
  {
    'type'        => 'object',
    'required'    => [],
    'properties'  => Hash[@properties.map { |property| [property.id, property.to_doc] }]
  }
end