grape-swagger 0.27.2 → 0.27.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -3
- data/.travis.yml +1 -0
- data/CHANGELOG.md +10 -0
- data/Gemfile +3 -3
- data/grape-swagger.gemspec +1 -1
- data/lib/grape-swagger.rb +1 -1
- data/lib/grape-swagger/doc_methods/parse_params.rb +1 -1
- data/lib/grape-swagger/doc_methods/path_string.rb +2 -1
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/issues/605_root_route_documentation_spec.rb +23 -0
- data/spec/lib/parse_params_spec.rb +8 -0
- data/spec/swagger_v2/simple_mounted_api_spec.rb +9 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f8965c701e729810dda5456398ca1be10ede83f
|
4
|
+
data.tar.gz: ea1d30739c20e4317301e8f4117c62ae9b48a3aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e3ddeb7ee947dbc7bcfbc5aa6c102e71c68bf9f366f2a9fdb0db56c7ea8beba030d5eea0353821c32ba4c0596e82e48f37f9e99f5d215e1ddcb0ea1cd954f782
|
7
|
+
data.tar.gz: 96e40804304834a0c1615cc0a1915b370a1b84c9df308311972fedbc92ccf7e771f87120b9963d216532c825aed47538b6e9c335ddb5b8f8378edb2ea99899b1
|
data/.rubocop.yml
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
1
3
|
AllCops:
|
2
4
|
Exclude:
|
3
5
|
- vendor/**/*
|
4
6
|
- example/**/*
|
5
7
|
TargetRubyVersion: 2.4
|
6
8
|
|
7
|
-
|
9
|
+
Layout/IndentHash:
|
10
|
+
EnforcedStyle: consistent
|
8
11
|
|
9
12
|
Metrics/BlockLength:
|
10
13
|
Exclude:
|
@@ -18,8 +21,6 @@ Metrics/MethodLength:
|
|
18
21
|
Exclude:
|
19
22
|
- spec/**/*
|
20
23
|
|
21
|
-
Style/IndentHash:
|
22
|
-
EnforcedStyle: consistent
|
23
24
|
|
24
25
|
Style/FileName:
|
25
26
|
Enabled: false
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,16 @@
|
|
8
8
|
|
9
9
|
* Your contribution here.
|
10
10
|
|
11
|
+
### 0.27.3 (July 11, 2017)
|
12
|
+
|
13
|
+
#### Features
|
14
|
+
|
15
|
+
* [#613](https://github.com/ruby-grape/grape-swagger/pull/613): Fix Proc with arity one in param values - [@timothysu](https://github.com/timothysu).
|
16
|
+
|
17
|
+
#### Fixes
|
18
|
+
|
19
|
+
* [#616](https://github.com/ruby-grape/grape-swagger/pull/616): Fix swagger to show root path ([#605](https://github.com/ruby-grape/grape-swagger/issue/605)) - [@NightWolf007](https://github.com/NightWolf007).
|
20
|
+
|
11
21
|
### 0.27.2 (May 11, 2017)
|
12
22
|
|
13
23
|
#### Features
|
data/Gemfile
CHANGED
@@ -6,9 +6,9 @@ ruby RUBY_VERSION
|
|
6
6
|
|
7
7
|
gemspec
|
8
8
|
|
9
|
-
gem 'grape', case version = ENV['GRAPE_VERSION'] || '~> 0
|
9
|
+
gem 'grape', case version = ENV['GRAPE_VERSION'] || '~> 1.0'
|
10
10
|
when 'HEAD'
|
11
|
-
{
|
11
|
+
{ git: 'https://github.com/ruby-grape/grape' }
|
12
12
|
else
|
13
13
|
version
|
14
14
|
end
|
@@ -25,7 +25,7 @@ group :development, :test do
|
|
25
25
|
gem 'rake'
|
26
26
|
gem 'rdoc'
|
27
27
|
gem 'rspec', '~> 3.0'
|
28
|
-
gem 'rubocop', '~> 0.
|
28
|
+
gem 'rubocop', '~> 0.49'
|
29
29
|
end
|
30
30
|
|
31
31
|
group :test do
|
data/grape-swagger.gemspec
CHANGED
@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = 'Add auto generated documentation to your Grape API that can be displayed with Swagger.'
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
16
|
-
s.required_ruby_version = '>= 2.2
|
16
|
+
s.required_ruby_version = '>= 2.2'
|
17
17
|
s.add_runtime_dependency 'grape', '>= 0.16.2'
|
18
18
|
|
19
19
|
s.files = `git ls-files`.split("\n")
|
data/lib/grape-swagger.rb
CHANGED
@@ -69,7 +69,7 @@ module Grape
|
|
69
69
|
route_match = route_match.match('\/([\w|-]*?)[\.\/\(]') || route_match.match('\/([\w|-]*)$')
|
70
70
|
next unless route_match
|
71
71
|
resource = route_match.captures.first
|
72
|
-
|
72
|
+
resource = '/' if resource.empty?
|
73
73
|
@target_class.combined_routes[resource] ||= []
|
74
74
|
next if doc_klass.hide_documentation_path && route.path.match(/#{doc_klass.mount_path}($|\/|\(\.)/)
|
75
75
|
@target_class.combined_routes[resource] << route
|
@@ -101,7 +101,7 @@ module GrapeSwagger
|
|
101
101
|
def parse_enum_or_range_values(values)
|
102
102
|
case values
|
103
103
|
when Proc
|
104
|
-
parse_enum_or_range_values(values.call)
|
104
|
+
parse_enum_or_range_values(values.call) if values.parameters.empty?
|
105
105
|
when Range
|
106
106
|
parse_range_values(values) if values.first.is_a?(Integer)
|
107
107
|
else
|
@@ -14,7 +14,8 @@ module GrapeSwagger
|
|
14
14
|
path.gsub!(/:(\w+)/, '{\1}')
|
15
15
|
|
16
16
|
# set item from path, this could be used for the definitions object
|
17
|
-
|
17
|
+
path_name = path.gsub(%r{/{(.+?)}}, '').split('/').last
|
18
|
+
item = path_name.present? ? path_name.singularize.underscore.camelize : 'Item'
|
18
19
|
|
19
20
|
if route.version && options[:add_version]
|
20
21
|
version = GrapeSwagger::DocMethods::Version.get(route)
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe '#605 root route documentation' do
|
6
|
+
let(:app) do
|
7
|
+
Class.new(Grape::API) do
|
8
|
+
get do
|
9
|
+
{ message: 'hello world' }
|
10
|
+
end
|
11
|
+
|
12
|
+
add_swagger_documentation format: :json
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
subject do
|
17
|
+
get '/swagger_doc'
|
18
|
+
JSON.parse(last_response.body)['paths']
|
19
|
+
end
|
20
|
+
|
21
|
+
specify { expect(app.combined_routes.keys).to include '/' }
|
22
|
+
specify { expect(subject.keys).to include '/' }
|
23
|
+
end
|
@@ -47,6 +47,14 @@ describe GrapeSwagger::DocMethods::ParseParams do
|
|
47
47
|
expect(parsed_range).to eql(enum: %w[a b c])
|
48
48
|
end
|
49
49
|
end
|
50
|
+
|
51
|
+
describe 'with arity one' do
|
52
|
+
let(:values) { proc { |v| v < 25 } }
|
53
|
+
specify do
|
54
|
+
parsed_range = subject.send(:parse_enum_or_range_values, values)
|
55
|
+
expect(parsed_range).to be_nil
|
56
|
+
end
|
57
|
+
end
|
50
58
|
end
|
51
59
|
|
52
60
|
describe 'values as Array -> enums' do
|
@@ -100,6 +100,15 @@ describe 'a simple mounted api' do
|
|
100
100
|
{ 'name' => 'custom', 'description' => 'Operations about customs' }
|
101
101
|
],
|
102
102
|
'paths' => {
|
103
|
+
'/' => {
|
104
|
+
'get' => {
|
105
|
+
'summary' => 'Document root',
|
106
|
+
'description' => 'Document root',
|
107
|
+
'produces' => ['application/json'],
|
108
|
+
'responses' => { '200' => { 'description' => 'Document root' } },
|
109
|
+
'operationId' => 'get'
|
110
|
+
}
|
111
|
+
},
|
103
112
|
'/simple' => {
|
104
113
|
'get' => {
|
105
114
|
'summary' => 'This gets something.',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape-swagger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.27.
|
4
|
+
version: 0.27.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Vandecasteele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- spec/issues/579_align_put_post_parameters_spec.rb
|
89
89
|
- spec/issues/582_file_response_spec.rb
|
90
90
|
- spec/issues/587_range_parameter_delimited_by_dash_spec.rb
|
91
|
+
- spec/issues/605_root_route_documentation_spec.rb
|
91
92
|
- spec/lib/data_type_spec.rb
|
92
93
|
- spec/lib/endpoint_spec.rb
|
93
94
|
- spec/lib/extensions_spec.rb
|
@@ -170,7 +171,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
170
171
|
requirements:
|
171
172
|
- - ">="
|
172
173
|
- !ruby/object:Gem::Version
|
173
|
-
version: 2.2
|
174
|
+
version: '2.2'
|
174
175
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
175
176
|
requirements:
|
176
177
|
- - ">="
|
@@ -197,6 +198,7 @@ test_files:
|
|
197
198
|
- spec/issues/579_align_put_post_parameters_spec.rb
|
198
199
|
- spec/issues/582_file_response_spec.rb
|
199
200
|
- spec/issues/587_range_parameter_delimited_by_dash_spec.rb
|
201
|
+
- spec/issues/605_root_route_documentation_spec.rb
|
200
202
|
- spec/lib/data_type_spec.rb
|
201
203
|
- spec/lib/endpoint_spec.rb
|
202
204
|
- spec/lib/extensions_spec.rb
|