Skip to content

in block in combine_namespace_routes': undefined method reject' for nil:NilClass (NoMethodError) #610

Open
@qqshfox

Description

@qqshfox

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>'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions