grape 0.19.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of grape might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/Appraisals +8 -0
- data/CHANGELOG.md +40 -22
- data/Gemfile +1 -0
- data/Gemfile.lock +58 -59
- data/LICENSE +1 -1
- data/README.md +94 -49
- data/Rakefile +1 -0
- data/UPGRADING.md +89 -0
- data/benchmark/simple_with_type_coercer.rb +22 -0
- data/gemfiles/multi_json.gemfile +36 -0
- data/gemfiles/multi_xml.gemfile +36 -0
- data/gemfiles/rack_1.5.2.gemfile +1 -0
- data/gemfiles/rack_edge.gemfile +1 -0
- data/gemfiles/rails_3.gemfile +1 -0
- data/gemfiles/rails_4.gemfile +1 -0
- data/gemfiles/rails_5.gemfile +1 -0
- data/gemfiles/rails_edge.gemfile +1 -0
- data/grape.gemspec +0 -3
- data/lib/grape.rb +40 -17
- data/lib/grape/dsl/helpers.rb +32 -18
- data/lib/grape/dsl/inside_route.rb +2 -2
- data/lib/grape/dsl/parameters.rb +26 -0
- data/lib/grape/dsl/routing.rb +1 -1
- data/lib/grape/dsl/settings.rb +1 -1
- data/lib/grape/endpoint.rb +20 -16
- data/lib/grape/error_formatter/json.rb +1 -1
- data/lib/grape/error_formatter/txt.rb +1 -1
- data/lib/grape/extensions/active_support/hash_with_indifferent_access.rb +26 -0
- data/lib/grape/extensions/deep_hash_with_indifferent_access.rb +18 -0
- data/lib/grape/extensions/deep_mergeable_hash.rb +19 -0
- data/lib/grape/extensions/deep_symbolize_hash.rb +30 -0
- data/lib/grape/extensions/hash.rb +23 -0
- data/lib/grape/extensions/hashie/mash.rb +24 -0
- data/lib/grape/formatter/json.rb +1 -1
- data/lib/grape/formatter/serializable_hash.rb +2 -2
- data/lib/grape/locale/en.yml +1 -1
- data/lib/grape/middleware/globals.rb +1 -1
- data/lib/grape/parser/json.rb +2 -2
- data/lib/grape/parser/xml.rb +2 -2
- data/lib/grape/request.rb +11 -10
- data/lib/grape/util/json.rb +8 -0
- data/lib/grape/util/xml.rb +8 -0
- data/lib/grape/validations.rb +4 -0
- data/lib/grape/validations/params_scope.rb +77 -39
- data/lib/grape/validations/types/build_coercer.rb +27 -0
- data/lib/grape/validations/types/custom_type_coercer.rb +18 -4
- data/lib/grape/validations/types/file.rb +2 -3
- data/lib/grape/validations/validator_factory.rb +18 -0
- data/lib/grape/validations/validators/base.rb +4 -5
- data/lib/grape/validations/validators/coerce.rb +4 -0
- data/lib/grape/validations/validators/except_values.rb +20 -0
- data/lib/grape/validations/validators/values.rb +25 -5
- data/lib/grape/version.rb +1 -1
- data/spec/grape/api/invalid_format_spec.rb +3 -3
- data/spec/grape/api_spec.rb +28 -16
- data/spec/grape/dsl/helpers_spec.rb +25 -6
- data/spec/grape/endpoint_spec.rb +117 -13
- data/spec/grape/extensions/param_builders/hash_spec.rb +83 -0
- data/spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb +105 -0
- data/spec/grape/extensions/param_builders/hashie/mash_spec.rb +79 -0
- data/spec/grape/middleware/formatter_spec.rb +6 -2
- data/spec/grape/request_spec.rb +13 -3
- data/spec/grape/validations/instance_behaivour_spec.rb +44 -0
- data/spec/grape/validations/params_scope_spec.rb +23 -0
- data/spec/grape/validations/types_spec.rb +19 -0
- data/spec/grape/validations/validators/coerce_spec.rb +117 -8
- data/spec/grape/validations/validators/except_values_spec.rb +191 -0
- data/spec/grape/validations/validators/values_spec.rb +78 -0
- data/spec/integration/multi_json/json_spec.rb +7 -0
- data/spec/integration/multi_xml/xml_spec.rb +7 -0
- metadata +30 -46
- data/pkg/grape-0.18.0.gem +0 -0
@@ -0,0 +1,191 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Grape::Validations::ExceptValuesValidator do
|
4
|
+
module ValidationsSpec
|
5
|
+
class ExceptValuesModel
|
6
|
+
DEFAULT_EXCEPTS = ['invalid-type1', 'invalid-type2', 'invalid-type3'].freeze
|
7
|
+
class << self
|
8
|
+
attr_accessor :excepts
|
9
|
+
def excepts
|
10
|
+
@excepts ||= []
|
11
|
+
[DEFAULT_EXCEPTS + @excepts].flatten.uniq
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
TEST_CASES = {
|
17
|
+
req_except: {
|
18
|
+
requires: { except_values: ExceptValuesModel.excepts },
|
19
|
+
tests: [
|
20
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
21
|
+
{ value: 'invalid-type3', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
22
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json }
|
23
|
+
]
|
24
|
+
},
|
25
|
+
req_except_hash: {
|
26
|
+
requires: { except_values: { value: ExceptValuesModel.excepts } },
|
27
|
+
tests: [
|
28
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
29
|
+
{ value: 'invalid-type3', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
30
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json }
|
31
|
+
]
|
32
|
+
},
|
33
|
+
req_except_custom_message: {
|
34
|
+
requires: { except_values: { value: ExceptValuesModel.excepts, message: 'is not allowed' } },
|
35
|
+
tests: [
|
36
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type is not allowed' }.to_json },
|
37
|
+
{ value: 'invalid-type3', rc: 400, body: { error: 'type is not allowed' }.to_json },
|
38
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json }
|
39
|
+
]
|
40
|
+
},
|
41
|
+
req_except_no_value: {
|
42
|
+
requires: { except_values: { message: 'is not allowed' } },
|
43
|
+
tests: [
|
44
|
+
{ value: 'invalid-type1', rc: 200, body: { type: 'invalid-type1' }.to_json }
|
45
|
+
]
|
46
|
+
},
|
47
|
+
req_except_empty: {
|
48
|
+
requires: { except_values: [] },
|
49
|
+
tests: [
|
50
|
+
{ value: 'invalid-type1', rc: 200, body: { type: 'invalid-type1' }.to_json }
|
51
|
+
]
|
52
|
+
},
|
53
|
+
req_except_lambda: {
|
54
|
+
requires: { except_values: -> { ExceptValuesModel.excepts } },
|
55
|
+
add_excepts: ['invalid-type4'],
|
56
|
+
tests: [
|
57
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
58
|
+
{ value: 'invalid-type4', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
59
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json }
|
60
|
+
]
|
61
|
+
},
|
62
|
+
req_except_lambda_custom_message: {
|
63
|
+
requires: { except_values: { value: -> { ExceptValuesModel.excepts }, message: 'is not allowed' } },
|
64
|
+
add_excepts: ['invalid-type4'],
|
65
|
+
tests: [
|
66
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type is not allowed' }.to_json },
|
67
|
+
{ value: 'invalid-type4', rc: 400, body: { error: 'type is not allowed' }.to_json },
|
68
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json }
|
69
|
+
]
|
70
|
+
},
|
71
|
+
opt_except_default: {
|
72
|
+
optional: { except_values: ExceptValuesModel.excepts, default: 'valid-type2' },
|
73
|
+
tests: [
|
74
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
75
|
+
{ value: 'invalid-type3', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
76
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json },
|
77
|
+
{ rc: 200, body: { type: 'valid-type2' }.to_json }
|
78
|
+
]
|
79
|
+
},
|
80
|
+
opt_except_lambda_default: {
|
81
|
+
optional: { except_values: -> { ExceptValuesModel.excepts }, default: 'valid-type2' },
|
82
|
+
tests: [
|
83
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
84
|
+
{ value: 'invalid-type3', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
85
|
+
{ value: 'valid-type', rc: 200, body: { type: 'valid-type' }.to_json },
|
86
|
+
{ rc: 200, body: { type: 'valid-type2' }.to_json }
|
87
|
+
]
|
88
|
+
},
|
89
|
+
req_except_type_coerce: {
|
90
|
+
requires: { type: Integer, except_values: [10, 11] },
|
91
|
+
tests: [
|
92
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type is invalid' }.to_json },
|
93
|
+
{ value: 11, rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
94
|
+
{ value: '11', rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
95
|
+
{ value: '3', rc: 200, body: { type: 3 }.to_json },
|
96
|
+
{ value: 3, rc: 200, body: { type: 3 }.to_json }
|
97
|
+
]
|
98
|
+
},
|
99
|
+
opt_except_type_coerce_default: {
|
100
|
+
optional: { type: Integer, except_values: [10, 11], default: 12 },
|
101
|
+
tests: [
|
102
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type is invalid' }.to_json },
|
103
|
+
{ value: 10, rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
104
|
+
{ value: '3', rc: 200, body: { type: 3 }.to_json },
|
105
|
+
{ value: 3, rc: 200, body: { type: 3 }.to_json },
|
106
|
+
{ rc: 200, body: { type: 12 }.to_json }
|
107
|
+
]
|
108
|
+
},
|
109
|
+
opt_except_array_type_coerce_default: {
|
110
|
+
optional: { type: Array[Integer], except_values: [10, 11], default: 12 },
|
111
|
+
tests: [
|
112
|
+
{ value: 'invalid-type1', rc: 400, body: { error: 'type is invalid' }.to_json },
|
113
|
+
{ value: 10, rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
114
|
+
{ value: [10], rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
115
|
+
{ value: ['3'], rc: 200, body: { type: [3] }.to_json },
|
116
|
+
{ value: [3], rc: 200, body: { type: [3] }.to_json },
|
117
|
+
{ rc: 200, body: { type: 12 }.to_json }
|
118
|
+
]
|
119
|
+
},
|
120
|
+
req_except_range: {
|
121
|
+
optional: { type: Integer, except_values: 10..12 },
|
122
|
+
tests: [
|
123
|
+
{ value: 11, rc: 400, body: { error: 'type has a value not allowed' }.to_json },
|
124
|
+
{ value: 13, rc: 200, body: { type: 13 }.to_json }
|
125
|
+
]
|
126
|
+
}
|
127
|
+
}.freeze
|
128
|
+
|
129
|
+
module ExceptValidatorSpec
|
130
|
+
class API < Grape::API
|
131
|
+
default_format :json
|
132
|
+
|
133
|
+
TEST_CASES.each_with_index do |(k, v), _i|
|
134
|
+
params do
|
135
|
+
requires :type, v[:requires] if v.key? :requires
|
136
|
+
optional :type, v[:optional] if v.key? :optional
|
137
|
+
end
|
138
|
+
get k do
|
139
|
+
{ type: params[:type] }
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
it 'raises IncompatibleOptionValues on a default value in exclude' do
|
147
|
+
subject = Class.new(Grape::API)
|
148
|
+
expect do
|
149
|
+
subject.params do
|
150
|
+
optional :type, except_values: ValidationsSpec::ExceptValuesModel.excepts,
|
151
|
+
default: ValidationsSpec::ExceptValuesModel.excepts.sample
|
152
|
+
end
|
153
|
+
end.to raise_error Grape::Exceptions::IncompatibleOptionValues
|
154
|
+
end
|
155
|
+
|
156
|
+
it 'raises IncompatibleOptionValues when a default array has excluded values' do
|
157
|
+
subject = Class.new(Grape::API)
|
158
|
+
expect do
|
159
|
+
subject.params do
|
160
|
+
optional :type, type: Array[Integer],
|
161
|
+
except_values: 10..12,
|
162
|
+
default: [8, 9, 10]
|
163
|
+
end
|
164
|
+
end.to raise_error Grape::Exceptions::IncompatibleOptionValues
|
165
|
+
end
|
166
|
+
|
167
|
+
it 'raises IncompatibleOptionValues when type is incompatible with values array' do
|
168
|
+
subject = Class.new(Grape::API)
|
169
|
+
expect do
|
170
|
+
subject.params { optional :type, except_values: ['valid-type1', 'valid-type2', 'valid-type3'], type: Symbol }
|
171
|
+
end.to raise_error Grape::Exceptions::IncompatibleOptionValues
|
172
|
+
end
|
173
|
+
|
174
|
+
def app
|
175
|
+
ValidationsSpec::ExceptValidatorSpec::API
|
176
|
+
end
|
177
|
+
|
178
|
+
ValidationsSpec::TEST_CASES.each_with_index do |(k, v), i|
|
179
|
+
v[:tests].each do |t|
|
180
|
+
it "#{i}: #{k} - #{t[:value]}" do
|
181
|
+
ValidationsSpec::ExceptValuesModel.excepts = v[:add_excepts] if v.key? :add_excepts
|
182
|
+
body = {}
|
183
|
+
body[:type] = t[:value] if t.key? :value
|
184
|
+
get k.to_s, **body
|
185
|
+
expect(last_response.status).to eq t[:rc]
|
186
|
+
expect(last_response.body).to eq t[:body]
|
187
|
+
ValidationsSpec::ExceptValuesModel.excepts = nil
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
end
|
@@ -75,6 +75,13 @@ describe Grape::Validations::ValuesValidator do
|
|
75
75
|
end
|
76
76
|
get '/empty'
|
77
77
|
|
78
|
+
params do
|
79
|
+
optional :type, values: { value: ValuesModel.values }, default: 'valid-type2'
|
80
|
+
end
|
81
|
+
get '/default/hash/valid' do
|
82
|
+
{ type: params[:type] }
|
83
|
+
end
|
84
|
+
|
78
85
|
params do
|
79
86
|
optional :type, values: ValuesModel.values, default: 'valid-type2'
|
80
87
|
end
|
@@ -82,6 +89,13 @@ describe Grape::Validations::ValuesValidator do
|
|
82
89
|
{ type: params[:type] }
|
83
90
|
end
|
84
91
|
|
92
|
+
params do
|
93
|
+
optional :type, values: { except: ValuesModel.excepts }, default: 'valid-type2'
|
94
|
+
end
|
95
|
+
get '/default/except' do
|
96
|
+
{ type: params[:type] }
|
97
|
+
end
|
98
|
+
|
85
99
|
params do
|
86
100
|
optional :type, values: -> { ValuesModel.values }, default: 'valid-type2'
|
87
101
|
end
|
@@ -89,6 +103,13 @@ describe Grape::Validations::ValuesValidator do
|
|
89
103
|
{ type: params[:type] }
|
90
104
|
end
|
91
105
|
|
106
|
+
params do
|
107
|
+
requires :type, values: ->(v) { ValuesModel.values.include? v }
|
108
|
+
end
|
109
|
+
get '/lambda_val' do
|
110
|
+
{ type: params[:type] }
|
111
|
+
end
|
112
|
+
|
92
113
|
params do
|
93
114
|
requires :type, values: -> { [] }
|
94
115
|
end
|
@@ -143,6 +164,13 @@ describe Grape::Validations::ValuesValidator do
|
|
143
164
|
{ type: params[:type] }
|
144
165
|
end
|
145
166
|
|
167
|
+
params do
|
168
|
+
requires :type, type: String, values: { except: ValuesModel.excepts }
|
169
|
+
end
|
170
|
+
get '/except/exclusive/type' do
|
171
|
+
{ type: params[:type] }
|
172
|
+
end
|
173
|
+
|
146
174
|
params do
|
147
175
|
requires :type, values: { except: -> { ValuesModel.excepts } }
|
148
176
|
end
|
@@ -150,6 +178,13 @@ describe Grape::Validations::ValuesValidator do
|
|
150
178
|
{ type: params[:type] }
|
151
179
|
end
|
152
180
|
|
181
|
+
params do
|
182
|
+
requires :type, type: String, values: { except: -> { ValuesModel.excepts } }
|
183
|
+
end
|
184
|
+
get '/except/exclusive/lambda/type' do
|
185
|
+
{ type: params[:type] }
|
186
|
+
end
|
187
|
+
|
153
188
|
params do
|
154
189
|
requires :type, type: Integer, values: { except: -> { [3, 4, 5] } }
|
155
190
|
end
|
@@ -282,6 +317,18 @@ describe Grape::Validations::ValuesValidator do
|
|
282
317
|
expect(last_response.body).to eq({ type: 'valid-type2' }.to_json)
|
283
318
|
end
|
284
319
|
|
320
|
+
it 'allows a default value with except' do
|
321
|
+
get('/default/except')
|
322
|
+
expect(last_response.status).to eq 200
|
323
|
+
expect(last_response.body).to eq({ type: 'valid-type2' }.to_json)
|
324
|
+
end
|
325
|
+
|
326
|
+
it 'allows a valid default value' do
|
327
|
+
get('/default/hash/valid')
|
328
|
+
expect(last_response.status).to eq 200
|
329
|
+
expect(last_response.body).to eq({ type: 'valid-type2' }.to_json)
|
330
|
+
end
|
331
|
+
|
285
332
|
it 'allows a proc for values' do
|
286
333
|
get('/lambda', type: 'valid-type1')
|
287
334
|
expect(last_response.status).to eq 200
|
@@ -310,6 +357,18 @@ describe Grape::Validations::ValuesValidator do
|
|
310
357
|
expect(last_response.body).to eq({ error: 'type does not have a valid value' }.to_json)
|
311
358
|
end
|
312
359
|
|
360
|
+
it 'allows value using lambda' do
|
361
|
+
get('/lambda_val', type: 'valid-type1')
|
362
|
+
expect(last_response.status).to eq 200
|
363
|
+
expect(last_response.body).to eq({ type: 'valid-type1' }.to_json)
|
364
|
+
end
|
365
|
+
|
366
|
+
it 'does not allow invalid value using lambda' do
|
367
|
+
get('/lambda_val', type: 'invalid-type')
|
368
|
+
expect(last_response.status).to eq 400
|
369
|
+
expect(last_response.body).to eq({ error: 'type does not have a valid value' }.to_json)
|
370
|
+
end
|
371
|
+
|
313
372
|
it 'validates against an empty array in a proc' do
|
314
373
|
get('/empty_lambda', type: 'any')
|
315
374
|
expect(last_response.status).to eq 400
|
@@ -371,6 +430,13 @@ describe Grape::Validations::ValuesValidator do
|
|
371
430
|
end.to raise_error Grape::Exceptions::IncompatibleOptionValues
|
372
431
|
end
|
373
432
|
|
433
|
+
it 'raises IncompatibleOptionValues when except contains a value that is not a kind of the type' do
|
434
|
+
subject = Class.new(Grape::API)
|
435
|
+
expect do
|
436
|
+
subject.params { requires :type, values: { except: [10.5, 11] }, type: Integer }
|
437
|
+
end.to raise_error Grape::Exceptions::IncompatibleOptionValues
|
438
|
+
end
|
439
|
+
|
374
440
|
context 'with a lambda values' do
|
375
441
|
subject do
|
376
442
|
Class.new(Grape::API) do
|
@@ -451,6 +517,12 @@ describe Grape::Validations::ValuesValidator do
|
|
451
517
|
expect(last_response.body).to eq({ type: 'value' }.to_json)
|
452
518
|
end
|
453
519
|
|
520
|
+
it 'allows any other value outside excepts when type is included' do
|
521
|
+
get '/except/exclusive/type', type: 'value'
|
522
|
+
expect(last_response.status).to eq 200
|
523
|
+
expect(last_response.body).to eq({ type: 'value' }.to_json)
|
524
|
+
end
|
525
|
+
|
454
526
|
it 'rejects values that matches except' do
|
455
527
|
get '/except/exclusive', type: 'invalid-type1'
|
456
528
|
expect(last_response.status).to eq 400
|
@@ -465,6 +537,12 @@ describe Grape::Validations::ValuesValidator do
|
|
465
537
|
end
|
466
538
|
|
467
539
|
context 'exclusive excepts with lambda' do
|
540
|
+
it 'allows any other value outside excepts when type is included' do
|
541
|
+
get '/except/exclusive/lambda/type', type: 'value'
|
542
|
+
expect(last_response.status).to eq 200
|
543
|
+
expect(last_response.body).to eq({ type: 'value' }.to_json)
|
544
|
+
end
|
545
|
+
|
468
546
|
it 'allows any other value outside excepts' do
|
469
547
|
get '/except/exclusive/lambda', type: 'value'
|
470
548
|
expect(last_response.status).to eq 200
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: grape
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -66,48 +66,6 @@ dependencies:
|
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: multi_json
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.3.2
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: 1.3.2
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: multi_xml
|
85
|
-
requirement: !ruby/object:Gem::Requirement
|
86
|
-
requirements:
|
87
|
-
- - ">="
|
88
|
-
- !ruby/object:Gem::Version
|
89
|
-
version: 0.5.2
|
90
|
-
type: :runtime
|
91
|
-
prerelease: false
|
92
|
-
version_requirements: !ruby/object:Gem::Requirement
|
93
|
-
requirements:
|
94
|
-
- - ">="
|
95
|
-
- !ruby/object:Gem::Version
|
96
|
-
version: 0.5.2
|
97
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: hashie
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: 2.1.0
|
104
|
-
type: :runtime
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: 2.1.0
|
111
69
|
- !ruby/object:Gem::Dependency
|
112
70
|
name: virtus
|
113
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,6 +114,9 @@ files:
|
|
156
114
|
- Rakefile
|
157
115
|
- UPGRADING.md
|
158
116
|
- benchmark/simple.rb
|
117
|
+
- benchmark/simple_with_type_coercer.rb
|
118
|
+
- gemfiles/multi_json.gemfile
|
119
|
+
- gemfiles/multi_xml.gemfile
|
159
120
|
- gemfiles/rack_1.5.2.gemfile
|
160
121
|
- gemfiles/rack_edge.gemfile
|
161
122
|
- gemfiles/rails_3.gemfile
|
@@ -208,6 +169,12 @@ files:
|
|
208
169
|
- lib/grape/exceptions/validation.rb
|
209
170
|
- lib/grape/exceptions/validation_array_errors.rb
|
210
171
|
- lib/grape/exceptions/validation_errors.rb
|
172
|
+
- lib/grape/extensions/active_support/hash_with_indifferent_access.rb
|
173
|
+
- lib/grape/extensions/deep_hash_with_indifferent_access.rb
|
174
|
+
- lib/grape/extensions/deep_mergeable_hash.rb
|
175
|
+
- lib/grape/extensions/deep_symbolize_hash.rb
|
176
|
+
- lib/grape/extensions/hash.rb
|
177
|
+
- lib/grape/extensions/hashie/mash.rb
|
211
178
|
- lib/grape/formatter.rb
|
212
179
|
- lib/grape/formatter/json.rb
|
213
180
|
- lib/grape/formatter/serializable_hash.rb
|
@@ -249,10 +216,12 @@ files:
|
|
249
216
|
- lib/grape/util/env.rb
|
250
217
|
- lib/grape/util/inheritable_setting.rb
|
251
218
|
- lib/grape/util/inheritable_values.rb
|
219
|
+
- lib/grape/util/json.rb
|
252
220
|
- lib/grape/util/registrable.rb
|
253
221
|
- lib/grape/util/reverse_stackable_values.rb
|
254
222
|
- lib/grape/util/stackable_values.rb
|
255
223
|
- lib/grape/util/strict_hash_configuration.rb
|
224
|
+
- lib/grape/util/xml.rb
|
256
225
|
- lib/grape/validations.rb
|
257
226
|
- lib/grape/validations/attributes_iterator.rb
|
258
227
|
- lib/grape/validations/params_scope.rb
|
@@ -264,6 +233,7 @@ files:
|
|
264
233
|
- lib/grape/validations/types/multiple_type_coercer.rb
|
265
234
|
- lib/grape/validations/types/variant_collection_coercer.rb
|
266
235
|
- lib/grape/validations/types/virtus_collection_patch.rb
|
236
|
+
- lib/grape/validations/validator_factory.rb
|
267
237
|
- lib/grape/validations/validators/all_or_none.rb
|
268
238
|
- lib/grape/validations/validators/allow_blank.rb
|
269
239
|
- lib/grape/validations/validators/at_least_one_of.rb
|
@@ -271,13 +241,13 @@ files:
|
|
271
241
|
- lib/grape/validations/validators/coerce.rb
|
272
242
|
- lib/grape/validations/validators/default.rb
|
273
243
|
- lib/grape/validations/validators/exactly_one_of.rb
|
244
|
+
- lib/grape/validations/validators/except_values.rb
|
274
245
|
- lib/grape/validations/validators/multiple_params_base.rb
|
275
246
|
- lib/grape/validations/validators/mutual_exclusion.rb
|
276
247
|
- lib/grape/validations/validators/presence.rb
|
277
248
|
- lib/grape/validations/validators/regexp.rb
|
278
249
|
- lib/grape/validations/validators/values.rb
|
279
250
|
- lib/grape/version.rb
|
280
|
-
- pkg/grape-0.18.0.gem
|
281
251
|
- spec/grape/api/custom_validations_spec.rb
|
282
252
|
- spec/grape/api/deeply_included_options_spec.rb
|
283
253
|
- spec/grape/api/invalid_format_spec.rb
|
@@ -316,6 +286,9 @@ files:
|
|
316
286
|
- spec/grape/exceptions/unknown_validator_spec.rb
|
317
287
|
- spec/grape/exceptions/validation_errors_spec.rb
|
318
288
|
- spec/grape/exceptions/validation_spec.rb
|
289
|
+
- spec/grape/extensions/param_builders/hash_spec.rb
|
290
|
+
- spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb
|
291
|
+
- spec/grape/extensions/param_builders/hashie/mash_spec.rb
|
319
292
|
- spec/grape/integration/global_namespace_function_spec.rb
|
320
293
|
- spec/grape/integration/rack_sendfile_spec.rb
|
321
294
|
- spec/grape/integration/rack_spec.rb
|
@@ -344,6 +317,7 @@ files:
|
|
344
317
|
- spec/grape/util/stackable_values_spec.rb
|
345
318
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
346
319
|
- spec/grape/validations/attributes_iterator_spec.rb
|
320
|
+
- spec/grape/validations/instance_behaivour_spec.rb
|
347
321
|
- spec/grape/validations/params_scope_spec.rb
|
348
322
|
- spec/grape/validations/types_spec.rb
|
349
323
|
- spec/grape/validations/validators/all_or_none_spec.rb
|
@@ -352,12 +326,15 @@ files:
|
|
352
326
|
- spec/grape/validations/validators/coerce_spec.rb
|
353
327
|
- spec/grape/validations/validators/default_spec.rb
|
354
328
|
- spec/grape/validations/validators/exactly_one_of_spec.rb
|
329
|
+
- spec/grape/validations/validators/except_values_spec.rb
|
355
330
|
- spec/grape/validations/validators/mutual_exclusion_spec.rb
|
356
331
|
- spec/grape/validations/validators/presence_spec.rb
|
357
332
|
- spec/grape/validations/validators/regexp_spec.rb
|
358
333
|
- spec/grape/validations/validators/values_spec.rb
|
359
334
|
- spec/grape/validations/validators/zh-CN.yml
|
360
335
|
- spec/grape/validations_spec.rb
|
336
|
+
- spec/integration/multi_json/json_spec.rb
|
337
|
+
- spec/integration/multi_xml/xml_spec.rb
|
361
338
|
- spec/shared/versioning_examples.rb
|
362
339
|
- spec/spec_helper.rb
|
363
340
|
- spec/support/basic_auth_encode_helpers.rb
|
@@ -386,7 +363,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
386
363
|
version: '0'
|
387
364
|
requirements: []
|
388
365
|
rubyforge_project:
|
389
|
-
rubygems_version: 2.6.
|
366
|
+
rubygems_version: 2.6.12
|
390
367
|
signing_key:
|
391
368
|
specification_version: 4
|
392
369
|
summary: A simple Ruby framework for building REST-like APIs.
|
@@ -429,6 +406,9 @@ test_files:
|
|
429
406
|
- spec/grape/exceptions/unknown_validator_spec.rb
|
430
407
|
- spec/grape/exceptions/validation_errors_spec.rb
|
431
408
|
- spec/grape/exceptions/validation_spec.rb
|
409
|
+
- spec/grape/extensions/param_builders/hash_spec.rb
|
410
|
+
- spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb
|
411
|
+
- spec/grape/extensions/param_builders/hashie/mash_spec.rb
|
432
412
|
- spec/grape/integration/global_namespace_function_spec.rb
|
433
413
|
- spec/grape/integration/rack_sendfile_spec.rb
|
434
414
|
- spec/grape/integration/rack_spec.rb
|
@@ -457,6 +437,7 @@ test_files:
|
|
457
437
|
- spec/grape/util/stackable_values_spec.rb
|
458
438
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
459
439
|
- spec/grape/validations/attributes_iterator_spec.rb
|
440
|
+
- spec/grape/validations/instance_behaivour_spec.rb
|
460
441
|
- spec/grape/validations/params_scope_spec.rb
|
461
442
|
- spec/grape/validations/types_spec.rb
|
462
443
|
- spec/grape/validations/validators/all_or_none_spec.rb
|
@@ -465,12 +446,15 @@ test_files:
|
|
465
446
|
- spec/grape/validations/validators/coerce_spec.rb
|
466
447
|
- spec/grape/validations/validators/default_spec.rb
|
467
448
|
- spec/grape/validations/validators/exactly_one_of_spec.rb
|
449
|
+
- spec/grape/validations/validators/except_values_spec.rb
|
468
450
|
- spec/grape/validations/validators/mutual_exclusion_spec.rb
|
469
451
|
- spec/grape/validations/validators/presence_spec.rb
|
470
452
|
- spec/grape/validations/validators/regexp_spec.rb
|
471
453
|
- spec/grape/validations/validators/values_spec.rb
|
472
454
|
- spec/grape/validations/validators/zh-CN.yml
|
473
455
|
- spec/grape/validations_spec.rb
|
456
|
+
- spec/integration/multi_json/json_spec.rb
|
457
|
+
- spec/integration/multi_xml/xml_spec.rb
|
474
458
|
- spec/shared/versioning_examples.rb
|
475
459
|
- spec/spec_helper.rb
|
476
460
|
- spec/support/basic_auth_encode_helpers.rb
|