Skip to content

Commit

Permalink
Fixed camel case issue #457 (#458)
Browse files Browse the repository at this point in the history
* Fixed camel case issue #457

* Description of fixed issue in CHANGELOG.md

* Fixing api_swagger_v2_detail_spec.rb with updated expectation
  • Loading branch information
rayko authored and dblock committed Jun 15, 2016
1 parent 611572f commit 4e2c235
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
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] ||= []
next if doc_klass.hide_documentation_path && route.path.match(/#{doc_klass.mount_path}($|\/|\(\.)/)
@target_class.combined_routes[resource] << route
Expand Down
2 changes: 1 addition & 1 deletion spec/swagger_v2/api_swagger_v2_detail_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def app
specify do
expect(subject['paths']['/use_gfm_rc_detail']['get']).to include('description')
expect(subject['paths']['/use_gfm_rc_detail']['get']['description']).to eql(
"<h1>This returns something</h1>\n\n<p># Burgers in Heaven</p>\n\n<blockquote>\n<p>A burger doesn&#39;t come for free</p>\n</blockquote>\n\n<p>If you want to reserve a burger in heaven, you have to do\nsome crazy stuff on earth.</p>\n<pre class=\"highlight plaintext\"><code>def do_good\nputs 'help people'\nend\n</code></pre>\n\n<ul>\n<li><em>Will go to Heaven:</em> Probably</li>\n<li><em>Will go to Hell:</em> Probably not</li>\n</ul>"
"<h1>This returns something</h1>\n\n<p># Burgers in Heaven</p>\n\n<blockquote>\n<p>A burger doesn&#39;t come for free</p>\n</blockquote>\n\n<p>If you want to reserve a burger in heaven, you have to do\nsome crazy stuff on earth.</p>\n<pre class=\"highlight plaintext\"><code>def do_good\nputs 'help people'\nend\n</code></pre>\n<ul>\n<li><em>Will go to Heaven:</em> Probably</li>\n<li><em>Will go to Hell:</em> Probably not</li>\n</ul>"
)
end
end
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

0 comments on commit 4e2c235

Please sign in to comment.