grape-swagger 0.10.2 → 0.10.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +37 -16
- data/.travis.yml +1 -0
- data/CHANGELOG.md +10 -0
- data/README.md +195 -1
- data/example/config.ru +1 -1
- data/grape-swagger.gemspec +2 -2
- data/lib/grape-swagger.rb +8 -2
- data/lib/grape-swagger/doc_methods.rb +124 -40
- data/lib/grape-swagger/markdown.rb +1 -1
- data/lib/grape-swagger/version.rb +1 -1
- data/spec/api_description_spec.rb +6 -4
- data/spec/array_params_spec.rb +5 -5
- data/spec/boolean_params_spec.rb +1 -1
- data/spec/default_api_spec.rb +1 -2
- data/spec/float_api_spec.rb +1 -1
- data/spec/group_params_spec.rb +2 -2
- data/spec/hash_params_spec.rb +1 -1
- data/spec/i18n_spec.rb +364 -0
- data/spec/mutually_exclusive_spec.rb +2 -2
- data/spec/non_default_api_spec.rb +0 -1
- data/spec/param_type_spec.rb +6 -4
- data/spec/param_values_spec.rb +6 -6
- data/spec/spec_helper.rb +3 -0
- data/spec/support/i18n_helper.rb +8 -0
- metadata +12 -8
@@ -30,7 +30,7 @@ describe 'Mutually exclusive group params' do
|
|
30
30
|
body = JSON.parse last_response.body
|
31
31
|
parameters = body['apis'].first['operations'].first['parameters']
|
32
32
|
expect(parameters).to eq [
|
33
|
-
{ 'paramType' => 'form', 'name' => 'required_group[param_group_1][param_1]', 'description' =>
|
34
|
-
{ 'paramType' => 'form', 'name' => 'required_group[param_group_2][][param_2]', 'description' =>
|
33
|
+
{ 'paramType' => 'form', 'name' => 'required_group[param_group_1][param_1]', 'description' => '', 'type' => 'string', 'required' => false, 'allowMultiple' => false },
|
34
|
+
{ 'paramType' => 'form', 'name' => 'required_group[param_group_2][][param_2]', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false }]
|
35
35
|
end
|
36
36
|
end
|
data/spec/param_type_spec.rb
CHANGED
@@ -5,8 +5,9 @@ describe 'Params Types' do
|
|
5
5
|
Class.new(Grape::API) do
|
6
6
|
format :json
|
7
7
|
|
8
|
+
desc 'description', nickname: 'desc', params: { input1: { type: Integer, param_type: 'query' } }
|
8
9
|
params do
|
9
|
-
requires :
|
10
|
+
requires :input2, type: String, documentation: { param_type: 'query' }
|
10
11
|
end
|
11
12
|
post :action do
|
12
13
|
end
|
@@ -19,12 +20,13 @@ describe 'Params Types' do
|
|
19
20
|
get '/swagger_doc/action'
|
20
21
|
expect(last_response.status).to eq 200
|
21
22
|
body = JSON.parse last_response.body
|
22
|
-
body['apis'].first['operations'].
|
23
|
+
body['apis'].first['operations'].flat_map { |o| o['parameters'] }
|
23
24
|
end
|
24
25
|
|
25
26
|
it 'reads param type correctly' do
|
26
|
-
expect(subject).to
|
27
|
-
{ 'paramType' => 'query', 'name' => '
|
27
|
+
expect(subject).to match_array [
|
28
|
+
{ 'paramType' => 'query', 'name' => 'input1', 'description' => '', 'type' => 'integer', 'required' => false, 'allowMultiple' => false, 'format' => 'int32' },
|
29
|
+
{ 'paramType' => 'query', 'name' => 'input2', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false }
|
28
30
|
]
|
29
31
|
end
|
30
32
|
|
data/spec/param_values_spec.rb
CHANGED
@@ -46,7 +46,7 @@ describe 'Convert values to enum or Range' do
|
|
46
46
|
|
47
47
|
it 'has values as array in enum' do
|
48
48
|
expect(plain_array).to eq [
|
49
|
-
{ 'paramType' => 'form', 'name' => 'letter', 'description' =>
|
49
|
+
{ 'paramType' => 'form', 'name' => 'letter', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false, 'enum' => %w(a b c) }
|
50
50
|
]
|
51
51
|
end
|
52
52
|
end
|
@@ -56,7 +56,7 @@ describe 'Convert values to enum or Range' do
|
|
56
56
|
|
57
57
|
it 'has proc returned values as array in enum' do
|
58
58
|
expect(array_in_proc).to eq [
|
59
|
-
{ 'paramType' => 'form', 'name' => 'letter', 'description' =>
|
59
|
+
{ 'paramType' => 'form', 'name' => 'letter', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false, 'enum' => %w(d e f) }
|
60
60
|
]
|
61
61
|
end
|
62
62
|
end
|
@@ -66,7 +66,7 @@ describe 'Convert values to enum or Range' do
|
|
66
66
|
|
67
67
|
it 'has letter range values' do
|
68
68
|
expect(range_letter).to eq [
|
69
|
-
{ 'paramType' => 'form', 'name' => 'letter', 'description' =>
|
69
|
+
{ 'paramType' => 'form', 'name' => 'letter', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false }
|
70
70
|
]
|
71
71
|
end
|
72
72
|
|
@@ -74,7 +74,7 @@ describe 'Convert values to enum or Range' do
|
|
74
74
|
|
75
75
|
it 'has integer range values' do
|
76
76
|
expect(range_integer).to eq [
|
77
|
-
{ 'paramType' => 'form', 'name' => 'integer', 'description' =>
|
77
|
+
{ 'paramType' => 'form', 'name' => 'integer', 'description' => '', 'type' => 'integer', 'required' => true, 'allowMultiple' => false, 'format' => 'int32', 'minimum' => -5, 'maximum' => 5 }
|
78
78
|
]
|
79
79
|
end
|
80
80
|
end
|
@@ -113,7 +113,7 @@ describe 'Convert values to enum for float range and not arrays inside a proc',
|
|
113
113
|
|
114
114
|
it 'has proc returned value as string in enum' do
|
115
115
|
expect(non_array_in_proc).to eq [
|
116
|
-
{ 'paramType' => 'form', 'name' => 'letter', 'description' =>
|
116
|
+
{ 'paramType' => 'form', 'name' => 'letter', 'description' => '', 'type' => 'string', 'required' => true, 'allowMultiple' => false, 'enum' => 'string' }
|
117
117
|
]
|
118
118
|
end
|
119
119
|
end
|
@@ -123,7 +123,7 @@ describe 'Convert values to enum for float range and not arrays inside a proc',
|
|
123
123
|
|
124
124
|
it 'has float range values as string' do
|
125
125
|
expect(range_float).to eq [
|
126
|
-
{ 'paramType' => 'form', 'name' => 'float', 'description' =>
|
126
|
+
{ 'paramType' => 'form', 'name' => 'float', 'description' => '', 'type' => 'number', 'format' => 'float', 'required' => true, 'allowMultiple' => false }
|
127
127
|
]
|
128
128
|
end
|
129
129
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,10 +15,13 @@ Bundler.setup :default, :test
|
|
15
15
|
|
16
16
|
require 'rack/test'
|
17
17
|
|
18
|
+
require 'i18n_helper'
|
19
|
+
|
18
20
|
RSpec.configure do |config|
|
19
21
|
require 'rspec/expectations'
|
20
22
|
config.include RSpec::Matchers
|
21
23
|
config.mock_with :rspec
|
22
24
|
config.include Rack::Test::Methods
|
23
25
|
config.raise_errors_for_deprecations!
|
26
|
+
config.include I18nHelper
|
24
27
|
end
|
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.10.
|
4
|
+
version: 0.10.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Vandecasteele
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: grape
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: grape-entity
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - <
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.5.0
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - <
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.5.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +142,14 @@ dependencies:
|
|
142
142
|
requirements:
|
143
143
|
- - '='
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: 0.33.0
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - '='
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
152
|
+
version: 0.33.0
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
154
|
name: kramdown
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
@@ -245,6 +245,7 @@ files:
|
|
245
245
|
- spec/group_params_spec.rb
|
246
246
|
- spec/hash_params_spec.rb
|
247
247
|
- spec/hide_api_spec.rb
|
248
|
+
- spec/i18n_spec.rb
|
248
249
|
- spec/markdown/kramdown_adapter_spec.rb
|
249
250
|
- spec/markdown/markdown_spec.rb
|
250
251
|
- spec/markdown/redcarpet_adapter_spec.rb
|
@@ -259,6 +260,7 @@ files:
|
|
259
260
|
- spec/simple_mounted_api_spec.rb
|
260
261
|
- spec/spec_helper.rb
|
261
262
|
- spec/support/grape_version.rb
|
263
|
+
- spec/support/i18n_helper.rb
|
262
264
|
- spec/version_spec.rb
|
263
265
|
homepage: https://github.com/ruby-grape/grape-swagger
|
264
266
|
licenses:
|
@@ -306,6 +308,7 @@ test_files:
|
|
306
308
|
- spec/group_params_spec.rb
|
307
309
|
- spec/hash_params_spec.rb
|
308
310
|
- spec/hide_api_spec.rb
|
311
|
+
- spec/i18n_spec.rb
|
309
312
|
- spec/markdown/kramdown_adapter_spec.rb
|
310
313
|
- spec/markdown/markdown_spec.rb
|
311
314
|
- spec/markdown/redcarpet_adapter_spec.rb
|
@@ -320,4 +323,5 @@ test_files:
|
|
320
323
|
- spec/simple_mounted_api_spec.rb
|
321
324
|
- spec/spec_helper.rb
|
322
325
|
- spec/support/grape_version.rb
|
326
|
+
- spec/support/i18n_helper.rb
|
323
327
|
- spec/version_spec.rb
|