Method: Soaspec::WsdlGenerator#document_type_for

Defined in:
lib/soaspec/wsdl_generator.rb

#document_type_for(element, depth = 1) ⇒ Object

Adds documentation content for all children of XML element

Parameters:

  • element (Nokogiri::XML::Element)

    Type to document for

  • depth (Integer) (defaults to: 1)

    How many times to iterate depth for



88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# File 'lib/soaspec/wsdl_generator.rb', line 88

def document_type_for(element, depth = 1)
  # raise "Too far deep for #{element}" unless depth < 6
  return unless depth < 6

  if complex_type? element
    complex_type = element.children.find { |c| c.name == 'complexType' }
    sequence = complex_type.children.find { |c| c.name == 'sequence' }
    sequence.children.select { |node| node.class == Nokogiri::XML::Element }.each do |sub_element|
      document_type_for sub_element, depth += 1
    end
  else
    return "No type seen for #{element}, #{element.class}" unless element['type']

    name = element['name']
    type = value_after_namespace(element['type'])
    @use_camel_case = true unless /[[:upper:]]/.match(name[0]).nil?
    spaces = '  ' * depth
    @content += "#{spaces}#{name.snakecase}: #{fill_in_field_from_type(type)} # #{type} \n"
  end
end