Class: Swaggard::Swagger::Parameters::Body

Inherits:
Base
  • Object
show all
Defined in:
lib/swaggard/swagger/parameters/body.rb

Defined Under Namespace

Classes: Property

Instance Attribute Summary collapse

Attributes inherited from Base

#description, #is_required, #name

Instance Method Summary collapse

Constructor Details

#initialize(operation_name) ⇒ Body

Returns a new instance of Body.



10
11
12
13
14
15
16
17
# File 'lib/swaggard/swagger/parameters/body.rb', line 10

def initialize(operation_name)
  @in             = 'body'
  @name           = 'body'
  @is_required    = false
  @description    = ''
  @definition     = Definition.new("#{operation_name}_body")
  @definition_id  = @definition.id
end

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



8
9
10
# File 'lib/swaggard/swagger/parameters/body.rb', line 8

def definition
  @definition
end

Instance Method Details

#add_property(string) ⇒ Object



19
20
21
22
# File 'lib/swaggard/swagger/parameters/body.rb', line 19

def add_property(string)
  property = Property.new(string)
  @definition.add_property(property)
end

#description=(description) ⇒ Object



39
40
41
# File 'lib/swaggard/swagger/parameters/body.rb', line 39

def description=(description)
  @definition.description = description
end

#empty?Boolean

Returns:

  • (Boolean)


24
25
26
# File 'lib/swaggard/swagger/parameters/body.rb', line 24

def empty?
  @definition.empty?
end

#title=(title) ⇒ Object



43
44
45
# File 'lib/swaggard/swagger/parameters/body.rb', line 43

def title=(title)
  @definition.title = title
end

#to_docObject



28
29
30
31
32
33
34
35
36
37
# File 'lib/swaggard/swagger/parameters/body.rb', line 28

def to_doc
  doc = super

  doc.delete('type')
  doc.delete('description')

  doc['schema'] = { '$ref' => "#/definitions/#{@definition_id}" }

  doc
end