nogates / brujula

Yet another Ruby RAML parser aiming for RAML 1.0 fully support
6 stars 2 forks source link

Protocols in Root node of RAML doc causes runtime error #4

Open rwhitworth opened 8 years ago

rwhitworth commented 8 years ago

A RAML 1.0 document with Protocols defined in the root node causes Brujula to exit with:

Uncaught exception: undefined method `each' for "HTTP":String
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:90:in `block in flatten_children'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:89:in `each'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:89:in `each_with_object'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:89:in `flatten_children'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:81:in `each_flatted_child'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/map_object.rb:12:in `initialize'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_builder.rb:16:in `new'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_builder.rb:16:in `call'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_parser.rb:21:in `block in call'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_parser.rb:20:in `each'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_parser.rb:20:in `call'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object_parser.rb:5:in `call'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/object.rb:25:in `initialize'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/raml/v1_0/root.rb:25:in `initialize'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/raml/definition.rb:39:in `new'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/raml/definition.rb:39:in `load_raml_objects'
    /Users/rwhitworth/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/brujula-0.2.0/lib/brujula/raml/definition.rb:25:in `root'
    /Users/rwhitworth/Documents/git/rwhitworth/ruby/brujula/brujula.rb:8:in `<top (required)>'

An example document can be found here: https://github.com/kamilzasada/manageably-doc/blob/master/manageably-1.0.raml

The issue looks to stem from handling of array values in the root node.