bellycard / napa

A simple framework for building APIs with Grape
Other
329 stars 72 forks source link

Swagger throwing undefined method `collect' for nil:NilClass #197

Open craigulliott opened 9 years ago

craigulliott commented 9 years ago

it appears grape-swagger doesn't support grapes use of the route_param block

This code works fine.

 desc 'Delete a question'
 params do
   requires :id, desc: 'ID of the question'
 end
 delete ':id' do
   Question.find(params[:id]).delete
   { success: true }
 end

This code below throws an error.

route_param :id do
   delete do
     Question.find(params[:id]).delete
     { success: true }
   end
 end

I'm logging this as an issue because the way we use Napa at Belly and the official grape examples result in this error. And it took me several hours to figure out what the cause was. Hopefully this helps someone else.

ianneub commented 9 years ago

I think this is also related to #203 I was getting this same error, until I forced grape-swagger to ~> 0.9.0

gem 'grape-swagger', '~> 0.9.0'