forked from ruby-grape/grape-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix for tags for path versioned endpoints (ruby-grape#447)
* Test for tags in a versioned endpoint * Use the version from route when tagging endpoints * Updated the CHANGELOG
- Loading branch information
Showing
3 changed files
with
23 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,31 @@ | ||
require 'spec_helper' | ||
|
||
describe 'Grape::Endpoint#path_and_definitions' do | ||
before do | ||
module API | ||
module V1 | ||
class Item < Grape::API | ||
version 'v1', using: :path | ||
let(:api) do | ||
item = Class.new(Grape::API) do | ||
version 'v1', using: :path | ||
|
||
resource :item do | ||
get '/' | ||
end | ||
end | ||
end | ||
|
||
class Root < Grape::API | ||
mount API::V1::Item | ||
add_swagger_documentation add_version: true | ||
resource :item do | ||
get '/' | ||
end | ||
end | ||
|
||
@options = { add_version: true } | ||
@target_routes = API::Root.combined_namespace_routes | ||
Class.new(Grape::API) do | ||
mount item | ||
add_swagger_documentation add_version: true | ||
end | ||
end | ||
|
||
let(:options) { { add_version: true } } | ||
let(:target_routes) { api.combined_namespace_routes } | ||
|
||
subject { api.endpoints[0].path_and_definition_objects(target_routes, options) } | ||
|
||
it 'is returning a versioned path' do | ||
expect(API::V1::Item.endpoints[0] | ||
.path_and_definition_objects(@target_routes, @options)[0].keys[0]).to eql '/v1/item' | ||
expect(subject[0].keys[0]).to eq '/v1/item' | ||
end | ||
|
||
it 'tags the endpoint with the resource name' do | ||
expect(subject.first['/v1/item'][:get][:tags]).to eq ['item'] | ||
end | ||
end |