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

Support resource groupings for prefixed APIs #58

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def add_swagger_documentation(options={})

@combined_routes = {}
routes.each do |route|
resource = route.route_path.match('\/(\w*?)[\.\/\(]').captures.first
resource = route.route_path.split(route.route_prefix).last.match('\/(\w*?)[\.\/\(]').captures.first
next if resource.empty?
resource.downcase!
@combined_routes[resource] ||= []
Expand Down
5 changes: 3 additions & 2 deletions spec/non_default_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def app; SimpleApiWithMarkdown end
end
end

context "versioned API" do
context "prefixed and versioned API" do
before :all do
class VersionedMountedApi < Grape::API
prefix 'api'
Expand All @@ -278,7 +278,8 @@ class SimpleApiWithVersion < Grape::API
def app; SimpleApiWithVersion end

it "parses version and places it in the path" do
get '/swagger_doc/api.json'
get '/swagger_doc/something.json'

JSON.parse(last_response.body)["apis"].each do |api|
api["path"].should start_with "/api/v1/"
end
Expand Down