Class: WeakSwaggerParameters::Definitions::HashProperty

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

Instance Method Summary collapse

Constructor Details

#initialize(name, description, &block) ⇒ HashProperty

Returns a new instance of HashProperty.



8
9
10
11
12
13
# File 'lib/weak_swagger_parameters/definitions/hash_property.rb', line 8

def initialize(name, description, &block)
  @name = name
  @description = description

  instance_eval(&block) if block.present?
end

Instance Method Details

#apply_docs(parent_node) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/weak_swagger_parameters/definitions/hash_property.rb', line 26

def apply_docs(parent_node)
  name = @name
  description = @description
  definitions = child_definitions

  parent_node.instance_eval do
    property name, description: description, type: :object do
      hash_node = self
      definitions.each { |definition| definition.apply_docs(hash_node) }
    end
  end
end

#apply_validations(parent_node) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/weak_swagger_parameters/definitions/hash_property.rb', line 15

def apply_validations(parent_node)
  name = @name
  param_definitions = child_definitions

  parent_node.instance_eval do
    hash name, strong: true do
      param_definitions.each { |definition| definition.apply_validations(parent_node) }
    end
  end
end