Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grape-swagger compatibility #11

Closed
sunnyrjuneja opened this issue Apr 3, 2015 · 3 comments
Closed

grape-swagger compatibility #11

sunnyrjuneja opened this issue Apr 3, 2015 · 3 comments

Comments

@sunnyrjuneja
Copy link

Hi,

I wanted to discuss the "out of the box" compatibility of grape-swagger and grape-swagger-rails. It seems that when you install grape-swagger-rails (0.1.0) while using grape (0.11.0) and grape-swagger (0.10.1), you need to set options that aren't obvious from the README.

The first error I encountered was that when you setup grape-swagger-rails, there is an flash of errors that override each other and end with:

swagger_doc' from path http://api.rails-app.dev:3000/swagger_doc/swagger_doc.json (server returned undefined)

The other flashed errors are the same message but swagger_doc replaced with your resource. From the rails log, I was able to see that it was requesting a resource that was suffixed with .json

Started GET "/swagger_doc/swagger_doc.json" for 127.0.0.1 at 2015-04-03 16:14:20 -0700

ActionController::RoutingError (No route matches [GET] "/swagger_doc/swagger_doc.json"):

But out of the box, grape-swagger only creates urls of the form (notice no .json):
/swagger_doc/swagger_doc

By changing
add_swagger_documentation
to:

add_swagger_documentation(format: :json)

I was able to resolve the problem.

I propose that one or more of the following happens:

  1. The README for grape-swagger is changed.
  2. The README for grape-swagger-rails is changed.
  3. The code in grape-swagger automatically assumes the format of :json.
  4. Something better that the authors know. :)

I'm happy to send a PR anywhere for anything. I'm going to ping @dblock because he is so awesome and responds to everything grape related.

The following issues are relevant:
https://github.com/tim-vandecasteele/grape-swagger/issues/190
https://github.com/tim-vandecasteele/grape-swagger/issues/197

@dblock
Copy link
Member

dblock commented Apr 4, 2015

We discussed undoing the root cause of this in ruby-grape/grape#914, I think I would really like that, this has created such a mess.

Otherwise I think 3) is the way to go, ideally the default should be for a "typical" JSON API.

@dmitry
Copy link

dmitry commented May 18, 2015

Looks like fix was merged, but still grape still not released with fix. gem 'grape', github: 'intridea/grape' works fine!

@aschuster3
Copy link

Because this issue hasn't been updated in over a year, I'm assuming it was resolved or is now not relevant. If this issue still exists in some form, please ping me here and I'll reopen it or open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants