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

Require Grape 0.16.1 and fix route_xxx deprecations. #368

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
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
15 changes: 4 additions & 11 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,14 @@ language: ruby
sudo: false

rvm:
- 2.2
- 2.1
- 2.0
- 2.2.3
- 2.1.7
- jruby-19mode
- jruby-9.0.5.0
- rbx-2

env:
- GRAPE_VERSION=0.8.0
- GRAPE_VERSION=0.9.0
- 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=0.16.2
- GRAPE_VERSION=HEAD

matrix:
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.9.0'
case version = ENV['GRAPE_VERSION'] || '~> 0.16.2'
when 'HEAD'
gem 'grape', github: 'ruby-grape/grape'
else
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
**these branch generates a swagger file,
which is conform to the 1.2 spec**

# grape-swagger

[![Gem Version](https://badge.fury.io/rb/grape-swagger.svg)](http://badge.fury.io/rb/grape-swagger)
[![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=master)](https://travis-ci.org/ruby-grape/grape-swagger)
[![Build Status](https://travis-ci.org/ruby-grape/grape-swagger.svg?branch=swagger-1.2)](https://travis-ci.org/ruby-grape/grape-swagger)
[![Dependency Status](https://gemnasium.com/ruby-grape/grape-swagger.svg)](https://gemnasium.com/ruby-grape/grape-swagger)
[![Code Climate](https://codeclimate.com/github/ruby-grape/grape-swagger.svg)](https://codeclimate.com/github/ruby-grape/grape-swagger)

Expand Down
7 changes: 4 additions & 3 deletions RELEASING.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
# Releasing Grape-Swagger

There're no particular rules about when to release grape-swagger. Release bug fixes frequenty, features not so frequently and breaking API changes rarely.
There're no particular rules about when to release grape-swagger. Release bug fixes frequently, features not so frequently and breaking API changes rarely.

### Release

Run tests, check that all tests succeed locally.
Run tests and rubocop, check that all tests succeed locally.

```
bundle install
rake
bundle exec rake
```


Check that the last build succeeded in [Travis CI](https://travis-ci.org/ruby-grape/grape-swagger) for all supported platforms.

Increment the version, modify [lib/grape-swagger/version.rb](lib/grape-swagger/version.rb).
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.8.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