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

Fixed camel case issue #457 #458

Merged
merged 3 commits into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from 2 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
* [#444](https://github.com/ruby-grape/grape-swagger//pull/444): Default value provided in the documentation hash, override the grape default [@scauglog](https://github.com/scauglog).
* [#443](https://github.com/ruby-grape/grape-swagger/issues/443): Type provided in the documentation hash, override the grape type [@scauglog](https://github.com/scauglog).
* [#454](https://github.com/ruby-grape/grape-swagger/pull/454): Include documented Hashes in documentation output - [@aschuster3](https://github.com/aschuster3).
* [#457](https://github.com/ruby-grape/grape-swagger/issues/457): Using camel case on namespace throws exception on add_swagger_documentation method - [@rayko](https://github.com/rayko/).
* Your contribution here.

### 0.21.0 (June 1, 2016)
Expand Down
1 change: 0 additions & 1 deletion lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ def combine_routes(app, doc_klass)
next unless route_match
resource = route_match.captures.first
next if resource.empty?
resource.downcase!
@target_class.combined_routes[resource] ||= []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you can re-use this method operation_id.rb#L13

next if doc_klass.hide_documentation_path && route.path.match(/#{doc_klass.mount_path}($|\/|\(\.)/)
@target_class.combined_routes[resource] << route
Expand Down
20 changes: 20 additions & 0 deletions spec/swagger_v2/namespaced_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,26 @@ def app
end
end

context 'with camel case namespace' do
def app
Class.new(Grape::API) do
namespace :camelCases do
get '/', desc: 'Look! An endpoint.'
end
add_swagger_documentation format: :json
end
end

subject do
get '/swagger_doc'
JSON.parse(last_response.body)['paths']['/camelCases']['get']
end

it 'shows the namespace description in the json spec' do
expect(subject['description']).to eql('Look! An endpoint.')
end
end

context 'mounted' do
def app
namespaced_api = Class.new(Grape::API) do
Expand Down