grape-swagger
grape-swagger copied to clipboard
in `block in combine_namespace_routes': undefined method `reject' for nil:NilClass (NoMethodError)
This issue looks similar to the issue fixed in #508.
~/workspace/ruby/test_grape_swagger hanfei@hanfei-rmbp
0:59:43 ❯ cat Gemfile
source 'https://rubygems.org'
gem 'grape', '~> 0.19'
gem 'grape-swagger', '~> 0.27'
~/workspace/ruby/test_grape_swagger hanfei@hanfei-rmbp
0:59:58 ❯ cat api.rb
require 'grape'
require 'grape-swagger'
module TheApi
class ParentLessNamespaceApi < Grape::API
route_param :animal do
route_param :breed do
resource :queues do
route_param :queue_id do
resource :reservations do
desc 'Lists all reservations specific type of animal of specific breed in specific queue'
get do
{ bla: 'Bla Black' }
end
end
end
end
end
end
end
end
class ParentLessApi < Grape::API
prefix :api
mount TheApi::ParentLessNamespaceApi
add_swagger_documentation version: 'v1'
end
~/workspace/ruby/test_grape_swagger hanfei@hanfei-rmbp
1:00:06 ❯ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-darwin16]
~/workspace/ruby/test_grape_swagger hanfei@hanfei-rmbp
1:00:32 ❯ ruby api.rb
/Users/hanfei/.rvm/gems/ruby-2.4.0/gems/grape-swagger-0.27.2/lib/grape-swagger.rb:100:in `block in combine_namespace_routes': undefined method `reject' for nil:NilClass (NoMethodError)
from /Users/hanfei/.rvm/gems/ruby-2.4.0/gems/grape-swagger-0.27.2/lib/grape-swagger.rb:95:in `each'
from /Users/hanfei/.rvm/gems/ruby-2.4.0/gems/grape-swagger-0.27.2/lib/grape-swagger.rb:95:in `combine_namespace_routes'
from /Users/hanfei/.rvm/gems/ruby-2.4.0/gems/grape-swagger-0.27.2/lib/grape-swagger.rb:49:in `add_swagger_documentation'
from api.rb:26:in `<class:ParentLessApi>'
from api.rb:23:in `<main>'
@mur-wtag
The related spec is one of some specs never get executed because the filenames of those specs not having the suffix _spec. And 3 of 4 are failed now.
Here is the list:
spec/swagger_v2/description_not_initialized.rb
spec/swagger_v2/host.rb
spec/swagger_v2/parent_less_namespace.rb
spec/swagger_v2/reference_entity.rb
@qqshfox Yes, you are absolutely right. It's getting:
# ./spec/swagger_v2/parent_less_namespace_spec.rb:26
NoMethodError:
undefined method `each' for nil:NilClass
# ./lib/grape-swagger/doc_methods/tag_name_description.rb:7:in `block in build'
this type of error.
Let's fix it. :)