tim-vandecasteele/grape-swagger — pull request #22 by christian-marie (2013-01-23 23:26:24+00:00)
Title: Empty route created due to bug in route_path matching, results in: 0 : error http://localhost:9292/swagger_doc/.json

When attempting to mount an API which has a 'root' route, i.e. a get without any resource:
```ruby
module API
class BreaksSwagger < Grape::API
desc "Document root, i.e. GET http://host/"
get do
end
end
end
```
We get a route with an empty path, which breaks swagger as it tries to GET /.json:
```` ruby
{""=>[version=v1, method=GET, path=/(.:format)]}
````
This is due to a little bug on on line 14 of lib/grape-swagger.rb:
````ruby
resource = route.route_path.match('\/(\w*?)[\.\/\(]').captures.first || '/'
````

Fixing the logic to return a route of "/" still breaks swagger as it tries to GET //.json

This works, but it looks pretty of goofy in swagger and I figured you'd want to implement something less hacky.
````ruby
resource = route.route_path.match('\/(\w*?)[\.\/\(]').captures.first
resource.empty? && resource = 'doc_root'
````

So for now, the pull request just drops the route entirely as completely breaks swagger by default, and the doc_root thing is a bit of a hack.