Skip to content

Commit

Permalink
Require Grape 0.16.2 and fix route_xxx deprecations.
Browse files Browse the repository at this point in the history
  • Loading branch information
dblock committed Apr 11, 2016
1 parent dd95ee7 commit d144452
Show file tree
Hide file tree
Showing 13 changed files with 127 additions and 115 deletions.
25 changes: 15 additions & 10 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# This configuration was generated by
# `rubocop --auto-gen-config`
# on 2016-02-07 23:26:32 +0900 using RuboCop version 0.33.0.
# on 2016-04-09 20:38:17 -0400 using RuboCop version 0.33.0.
# The point is for the user to remove these configuration records
# one by one as the offenses are removed from the code base.
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Offense count: 14
Metrics/AbcSize:
Max: 214
Max: 222

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ClassLength:
Max: 150
Max: 149

# Offense count: 7
Metrics/CyclomaticComplexity:
Max: 39
Max: 42

# Offense count: 354
# Offense count: 359
# Configuration parameters: AllowURI, URISchemes.
Metrics/LineLength:
Max: 242
Max: 206

# Offense count: 24
# Configuration parameters: CountComments.
Metrics/MethodLength:
Max: 169
Max: 175

# Offense count: 1
# Configuration parameters: CountComments.
Metrics/ModuleLength:
Max: 472
Max: 478

# Offense count: 5
Metrics/PerceivedComplexity:
Max: 40
Max: 44

# Offense count: 8
Style/ClassVars:
Exclude:
- 'example/api.rb'
- 'lib/grape-swagger/doc_methods.rb'

# Offense count: 95
# Offense count: 96
Style/Documentation:
Enabled: false

Expand All @@ -61,6 +61,11 @@ Style/FileName:
- 'spec/grape-swagger_helper_spec.rb'
- 'spec/grape-swagger_spec.rb'

# Offense count: 1
Style/MultilineBlockChain:
Exclude:
- 'lib/grape-swagger/doc_methods.rb'

# Offense count: 1
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
Style/PredicateName:
Expand Down
9 changes: 2 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ rvm:
- rbx-2

env:
- GRAPE_VERSION=0.10.0
- GRAPE_VERSION=0.10.1
- GRAPE_VERSION=0.11.0
- GRAPE_VERSION=0.12.0
- GRAPE_VERSION=0.13.0
- GRAPE_VERSION=0.14.0
# - GRAPE_VERSION=HEAD
- GRAPE_VERSION=0.16.2
- GRAPE_VERSION=HEAD

matrix:
allow_failures:
Expand Down
11 changes: 7 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
### 0.10.5 (Next)
### 0.11.0 (Next)

* [#338](https://github.com/ruby-grape/grape-swagger/pull/338): Fixed handling of nested Array parameters - [@itoufo](https://github.com/itoufo).
* [#347](https://github.com/ruby-grape/grape-swagger/pull/347): Fixed typeref when both :using and :as are provided in exposure but no :type in documentation - [@c910335](https://github.com/c910335).
* Your contribution here.
#### Features

* [#368](https://github.com/ruby-grape/grape-swagger/pull/368): Requires Grape 0.16.2, fixes `route_xxx` deprecation messages - [@dblock](https://github.com/dblock).

#### Fixes

* [#338](https://github.com/ruby-grape/grape-swagger/pull/338): Fixed handling of nested Array parameters - [@itoufo](https://github.com/itoufo).
* [#347](https://github.com/ruby-grape/grape-swagger/pull/347): Fixed typeref when both :using and :as are provided in exposure but no :type in documentation - [@c910335](https://github.com/c910335).
* [#321](https://github.com/ruby-grape/grape-swagger/pull/321): Fixed handling paths containing uppercase letters - [@gekola](https://github.com/gekola).
* [#322](https://github.com/ruby-grape/grape-swagger/pull/322): Entity's `entity_name` takes predence over root - [@gekola](https://github.com/gekola).
* Your contribution here.

### 0.10.4 (December 7, 2015)

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'http://rubygems.org'

gemspec

case version = ENV['GRAPE_VERSION'] || '~> 0.10.0'
case version = ENV['GRAPE_VERSION'] || '~> 0.16.2'
when 'HEAD'
gem 'grape', github: 'ruby-grape/grape'
else
Expand Down
2 changes: 1 addition & 1 deletion grape-swagger.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gem::Specification.new do |s|
s.summary = 'A simple way to add auto generated documentation to your Grape API that can be displayed with Swagger.'
s.license = 'MIT'

s.add_runtime_dependency 'grape', '>= 0.10.0'
s.add_runtime_dependency 'grape', '>= 0.16.2'
s.add_runtime_dependency 'grape-entity', '< 0.5.0'

s.add_development_dependency 'rake'
Expand Down
18 changes: 9 additions & 9 deletions lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ def add_swagger_documentation(options = {})

@target_class.combined_routes = {}
@target_class.routes.each do |route|
route_path = route.route_path
route_match = route_path.split(/^.*?#{route.route_prefix.to_s}/).last
route_path = route.path
route_match = route_path.split(/^.*?#{route.prefix.to_s}/).last
next unless route_match
route_match = route_match.match('\/([\w|-]*?)[\.\/\(]') || route_match.match('\/([\w|-]*)$')
next unless route_match
resource = route_match.captures.first
next if resource.empty?
@target_class.combined_routes[resource] ||= []
next if documentation_class.hide_documentation_path && route.route_path.match(/#{documentation_class.mount_path}($|\/|\(\.)/)
next if documentation_class.hide_documentation_path && route.path.match(/#{documentation_class.mount_path}($|\/|\(\.)/)
@target_class.combined_routes[resource] << route
end

Expand Down Expand Up @@ -77,17 +77,17 @@ def combine_namespace_routes(namespaces)
parent_route = @target_class.combined_routes[parent_route_name]
# fetch all routes that are within the current namespace
namespace_routes = parent_route.collect do |route|
route if (route.route_path.start_with?(route.route_prefix ? "/#{route.route_prefix}/#{name}" : "/#{name}") || route.route_path.start_with?((route.route_prefix ? "/#{route.route_prefix}/:version/#{name}" : "/:version/#{name}"))) &&
route if (route.path.start_with?(route.prefix ? "/#{route.prefix}/#{name}" : "/#{name}") || route.path.start_with?((route.prefix ? "/#{route.prefix}/:version/#{name}" : "/:version/#{name}"))) &&
(route.instance_variable_get(:@options)[:namespace] == "/#{name}" || route.instance_variable_get(:@options)[:namespace] == "/:version/#{name}")
end.compact

if namespace.options.key?(:swagger) && namespace.options[:swagger][:nested] == false
# Namespace shall appear as standalone resource, use specified name or use normalized path as name
if namespace.options[:swagger].key?(:name)
identifier = namespace.options[:swagger][:name].tr(' ', '-')
else
identifier = name.tr('_', '-').gsub(/\//, '_')
end
identifier = if namespace.options[:swagger].key?(:name)
namespace.options[:swagger][:name].tr(' ', '-')
else
name.tr('_', '-').gsub(/\//, '_')
end
@target_class.combined_namespace_identifiers[identifier] = name
@target_class.combined_namespace_routes[identifier] = namespace_routes

Expand Down
Loading

0 comments on commit d144452

Please sign in to comment.