Class: WeakSwaggerParameters::Definitions::Body

Inherits:
Object
  • Object
show all
Includes:
PropertyContainer
Defined in:
lib/weak_swagger_parameters/definitions/body.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ Body

Returns a new instance of Body.



8
9
10
# File 'lib/weak_swagger_parameters/definitions/body.rb', line 8

def initialize(&block)
  instance_eval(&block) if block.present?
end

Instance Method Details

#apply_docs(parent_node) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/weak_swagger_parameters/definitions/body.rb', line 16

def apply_docs(parent_node)
  param_definitions = child_definitions
  schema_options = {}
  schema_options[:required] = required_fields unless required_fields.empty?

  parent_node.instance_eval do
    parameter name: :body, in: :body, required: true do
      schema schema_options do
        param_definitions.each { |definition| definition.apply_docs(self) }
      end
    end
  end
end

#apply_validations(parent_node) ⇒ Object



12
13
14
# File 'lib/weak_swagger_parameters/definitions/body.rb', line 12

def apply_validations(parent_node)
  child_definitions.each { |definition| definition.apply_validations(parent_node) }
end