Skip to content

Commit 4e2c235

Browse files
raykodblock
authored andcommitted
Fixed camel case issue #457 (#458)
* Fixed camel case issue #457 * Description of fixed issue in CHANGELOG.md * Fixing api_swagger_v2_detail_spec.rb with updated expectation
1 parent 611572f commit 4e2c235

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [#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).
1414
* [#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).
1515
* [#454](https://github.com/ruby-grape/grape-swagger/pull/454): Include documented Hashes in documentation output - [@aschuster3](https://github.com/aschuster3).
16+
* [#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/).
1617
* Your contribution here.
1718

1819
### 0.21.0 (June 1, 2016)

lib/grape-swagger.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def combine_routes(app, doc_klass)
6565
next unless route_match
6666
resource = route_match.captures.first
6767
next if resource.empty?
68-
resource.downcase!
6968
@target_class.combined_routes[resource] ||= []
7069
next if doc_klass.hide_documentation_path && route.path.match(/#{doc_klass.mount_path}($|\/|\(\.)/)
7170
@target_class.combined_routes[resource] << route

spec/swagger_v2/api_swagger_v2_detail_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ def app
144144
specify do
145145
expect(subject['paths']['/use_gfm_rc_detail']['get']).to include('description')
146146
expect(subject['paths']['/use_gfm_rc_detail']['get']['description']).to eql(
147-
"<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>"
147+
"<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>"
148148
)
149149
end
150150
end

spec/swagger_v2/namespaced_api_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,26 @@ def app
2121
end
2222
end
2323

24+
context 'with camel case namespace' do
25+
def app
26+
Class.new(Grape::API) do
27+
namespace :camelCases do
28+
get '/', desc: 'Look! An endpoint.'
29+
end
30+
add_swagger_documentation format: :json
31+
end
32+
end
33+
34+
subject do
35+
get '/swagger_doc'
36+
JSON.parse(last_response.body)['paths']['/camelCases']['get']
37+
end
38+
39+
it 'shows the namespace description in the json spec' do
40+
expect(subject['description']).to eql('Look! An endpoint.')
41+
end
42+
end
43+
2444
context 'mounted' do
2545
def app
2646
namespaced_api = Class.new(Grape::API) do

0 commit comments

Comments
 (0)