From 22d299282a2fd5c86705ab33bb6cf88e01cb00b0 Mon Sep 17 00:00:00 2001 From: Rayko Date: Wed, 15 Jun 2016 11:02:04 -0300 Subject: [PATCH 1/3] Fixed camel case issue https://github.com/ruby-grape/grape-swagger/issues/457 --- CHANGELOG.md | 1 + lib/grape-swagger.rb | 1 - spec/swagger_v2/namespaced_api_spec.rb | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cd0ae168..1ffb9000 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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): Issue with camel case endpoints - [@rayko](https://github.com/rayko/). * Your contribution here. ### 0.21.0 (June 1, 2016) diff --git a/lib/grape-swagger.rb b/lib/grape-swagger.rb index 04bb7fe6..b1aea2d5 100644 --- a/lib/grape-swagger.rb +++ b/lib/grape-swagger.rb @@ -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 diff --git a/spec/swagger_v2/namespaced_api_spec.rb b/spec/swagger_v2/namespaced_api_spec.rb index 17104a1f..ad7fab36 100644 --- a/spec/swagger_v2/namespaced_api_spec.rb +++ b/spec/swagger_v2/namespaced_api_spec.rb @@ -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 From ec854c579eb5797aed154b36e3bbb87421f5231c Mon Sep 17 00:00:00 2001 From: Rayko Date: Wed, 15 Jun 2016 14:48:35 -0300 Subject: [PATCH 2/3] Description of fixed issue in CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ffb9000..53e81b74 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,7 +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): Issue with camel case endpoints - [@rayko](https://github.com/rayko/). +* [#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) From 02431cfcd4a5766b2db589ddf2c54be75dab30dd Mon Sep 17 00:00:00 2001 From: Rayko Date: Wed, 15 Jun 2016 16:41:44 -0300 Subject: [PATCH 3/3] Fixing api_swagger_v2_detail_spec.rb with updated expectation --- spec/swagger_v2/api_swagger_v2_detail_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/swagger_v2/api_swagger_v2_detail_spec.rb b/spec/swagger_v2/api_swagger_v2_detail_spec.rb index 6dd8dd39..5cb0005e 100644 --- a/spec/swagger_v2/api_swagger_v2_detail_spec.rb +++ b/spec/swagger_v2/api_swagger_v2_detail_spec.rb @@ -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( - "

This returns something

\n\n

# Burgers in Heaven

\n\n
\n

A burger doesn't come for free

\n
\n\n

If you want to reserve a burger in heaven, you have to do\nsome crazy stuff on earth.

\n
def do_good\nputs 'help people'\nend\n
\n\n
    \n
  • Will go to Heaven: Probably
  • \n
  • Will go to Hell: Probably not
  • \n
" + "

This returns something

\n\n

# Burgers in Heaven

\n\n
\n

A burger doesn't come for free

\n
\n\n

If you want to reserve a burger in heaven, you have to do\nsome crazy stuff on earth.

\n
def do_good\nputs 'help people'\nend\n
\n
    \n
  • Will go to Heaven: Probably
  • \n
  • Will go to Hell: Probably not
  • \n
" ) end end