-
Notifications
You must be signed in to change notification settings - Fork 476
Adding swagger documentation for multiple Grape APIs in single Rails app #28
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
Comments
Having the same issue. Consider the scenario where you'd want to mount multiple api versions within grape (mount Twitter::APIv1, mount Twitter::APIv2) |
same issue here ... |
Dito! I have the same issue. |
I just got it work; I'm currently cleaning up code and working on live demo. But meanwhile you can checkout code and your's feedback is welcome, specially from decent Ruby devs, because i'm quite newbie in Ruby. |
I have now livedemos - Versioneye uses grape-swagger to add Swagger's documention for different versions( v1,v2 ) on same server. As you can notice settings are api-specific - you can add version without changing old versions: |
This has been fixed in #57. |
As far as I can tell, this does not work with grape version cascading. For example, if I mount my v1 endpoints like so: module API::V1
class Root < Grape::API
version ['v2', 'v1'], using: :path
mount API::V1::Places
mount API::V1::Users
add_swagger_documentation api_version: 'v1', mount_path: '/docs'
end
end ...and mount my v2 endpoints like so: module API::V2
class Root < Grape::API
version 'v2', using: :path, cascade: true
mount API::V2::Users
add_swagger_documentation api_version: 'v2', mount_path: '/docs'
end
end ...then the v2 docs do not include any of the endpoints defined in Am I missing something? |
I don't think you're missing anything, can you reopen an issue specifically for this? |
this get fixed in other version or the ticket is still open? |
#146 is still open, is that what you're asking @gessgallardo ? |
In our Rails app we are mounting two separate Grape APIs, e.g. /api/partner/v1 and /api/clients/v1. Now when I call
add_swagger_documentation
for each of these APIs, two separateswagger_doc
entry points are mounted correctly. However querying these two entry points returns the same API documentation. E.g. querying /api/partner/v1/swagger_doc.json returns the documentation for API::Partner but querying /api/clients/v1/swagger_doc.json also returns the documentation for API::Partner.I've been doing some debugging on this issue and it seems that the
@@target_class
class variable points to the same API class in theget @@mount_path
definition:This is despite the fact that two separate documentation classes get created with separate class variable. Somehow these class variables get merged into a single new instance of the Grape::Endpoint class. Here is what I see in the logs:
Maybe this data shouldn't be stored in class variables?
The text was updated successfully, but these errors were encountered: