ruby-grape / ruby-grape/grape-swagger
in `block in combine_namespace_routes': undefined method `reject' for nil:NilClass (NoMethodError)
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 1.1k
- Forks
- 479
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 6
Description
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>'
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the failure with the api.rb example, then inspect combine_namespace_routes in grape-swagger.rb around lines 95-100 and compare the related fix in issue #508. Done means the nested mounted routes no longer raise NoMethodError and add_swagger_documentation completes successfully.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- api, documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100