grape 0.16.2 → 0.17.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 +4 -0
- data/CHANGELOG.md +54 -27
- data/Dangerfile +80 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +61 -27
- data/README.md +135 -7
- data/Rakefile +34 -30
- data/UPGRADING.md +21 -0
- data/gemfiles/rack_1.5.2.gemfile +21 -0
- data/gemfiles/rails_3.gemfile +22 -1
- data/gemfiles/rails_4.gemfile +21 -0
- data/gemfiles/rails_5.gemfile +34 -0
- data/grape.gemspec +0 -14
- data/lib/grape.rb +2 -0
- data/lib/grape/api.rb +9 -2
- data/lib/grape/dsl/headers.rb +1 -1
- data/lib/grape/dsl/inside_route.rb +15 -17
- data/lib/grape/dsl/middleware.rb +15 -1
- data/lib/grape/dsl/parameters.rb +16 -14
- data/lib/grape/dsl/request_response.rb +24 -20
- data/lib/grape/dsl/routing.rb +11 -10
- data/lib/grape/dsl/settings.rb +16 -0
- data/lib/grape/endpoint.rb +77 -60
- data/lib/grape/exceptions/validation.rb +5 -2
- data/lib/grape/exceptions/validation_array_errors.rb +11 -0
- data/lib/grape/formatter/xml.rb +1 -1
- data/lib/grape/middleware/error.rb +34 -25
- data/lib/grape/middleware/formatter.rb +9 -9
- data/lib/grape/middleware/stack.rb +110 -0
- data/lib/grape/middleware/versioner.rb +1 -1
- data/lib/grape/middleware/versioner/accept_version_header.rb +1 -1
- data/lib/grape/middleware/versioner/header.rb +3 -3
- data/lib/grape/path.rb +10 -2
- data/lib/grape/request.rb +1 -1
- data/lib/grape/router.rb +10 -19
- data/lib/grape/router/pattern.rb +2 -2
- data/lib/grape/router/route.rb +3 -3
- data/lib/grape/util/content_types.rb +1 -1
- data/lib/grape/util/inheritable_setting.rb +7 -2
- data/lib/grape/util/reverse_stackable_values.rb +45 -0
- data/lib/grape/util/stackable_values.rb +10 -11
- data/lib/grape/validations/attributes_iterator.rb +32 -7
- data/lib/grape/validations/params_scope.rb +33 -21
- data/lib/grape/validations/types.rb +4 -4
- data/lib/grape/validations/types/build_coercer.rb +9 -1
- data/lib/grape/validations/validators/all_or_none.rb +2 -2
- data/lib/grape/validations/validators/allow_blank.rb +10 -11
- data/lib/grape/validations/validators/at_least_one_of.rb +1 -1
- data/lib/grape/validations/validators/base.rb +16 -6
- data/lib/grape/validations/validators/coerce.rb +3 -6
- data/lib/grape/validations/validators/default.rb +26 -1
- data/lib/grape/validations/validators/exactly_one_of.rb +1 -1
- data/lib/grape/validations/validators/mutual_exclusion.rb +1 -1
- data/lib/grape/validations/validators/presence.rb +1 -1
- data/lib/grape/validations/validators/regexp.rb +1 -1
- data/lib/grape/validations/validators/values.rb +1 -1
- data/lib/grape/version.rb +1 -1
- data/spec/grape/api/custom_validations_spec.rb +3 -3
- data/spec/grape/api/parameters_modification_spec.rb +41 -0
- data/spec/grape/api_spec.rb +335 -108
- data/spec/grape/dsl/logger_spec.rb +1 -1
- data/spec/grape/dsl/middleware_spec.rb +25 -5
- data/spec/grape/dsl/request_response_spec.rb +20 -6
- data/spec/grape/dsl/validations_spec.rb +1 -1
- data/spec/grape/endpoint_spec.rb +166 -23
- data/spec/grape/entity_spec.rb +0 -2
- data/spec/grape/exceptions/body_parse_errors_spec.rb +37 -0
- data/spec/grape/exceptions/validation_errors_spec.rb +5 -5
- data/spec/grape/exceptions/validation_spec.rb +10 -0
- data/spec/grape/integration/global_namespace_function_spec.rb +1 -1
- data/spec/grape/integration/rack_spec.rb +1 -1
- data/spec/grape/middleware/base_spec.rb +1 -1
- data/spec/grape/middleware/exception_spec.rb +2 -2
- data/spec/grape/middleware/formatter_spec.rb +4 -4
- data/spec/grape/middleware/stack_spec.rb +123 -0
- data/spec/grape/middleware/versioner/header_spec.rb +6 -6
- data/spec/grape/request_spec.rb +22 -22
- data/spec/grape/util/inheritable_setting_spec.rb +23 -0
- data/spec/grape/util/reverse_stackable_values_spec.rb +131 -0
- data/spec/grape/validations/params_scope_spec.rb +88 -1
- data/spec/grape/validations/validators/allow_blank_spec.rb +5 -0
- data/spec/grape/validations/validators/coerce_spec.rb +5 -5
- data/spec/grape/validations/validators/default_spec.rb +44 -0
- data/spec/grape/validations/validators/values_spec.rb +1 -1
- data/spec/grape/validations_spec.rb +36 -17
- data/spec/spec_helper.rb +1 -8
- data/spec/support/versioned_helpers.rb +3 -3
- metadata +13 -188
- data/gemfiles/rails_3.gemfile.lock +0 -225
- data/pkg/grape-0.16.1.gem +0 -0
- data/pkg/patch.diff +0 -24
- data/tmp/Gemfile.lock +0 -63
@@ -95,7 +95,7 @@ describe Grape::Validations::ParamsScope do
|
|
95
95
|
attr_reader :value
|
96
96
|
|
97
97
|
def self.parse(value)
|
98
|
-
|
98
|
+
raise if value == 'invalid'
|
99
99
|
new(value)
|
100
100
|
end
|
101
101
|
|
@@ -405,4 +405,91 @@ describe Grape::Validations::ParamsScope do
|
|
405
405
|
expect(JSON.parse(last_response.body)).to eq('bar' => { 'a' => 'true', 'c' => { 'b' => 'yes' } })
|
406
406
|
end
|
407
407
|
end
|
408
|
+
|
409
|
+
context 'when validations are dependent on a parameter with specific value' do
|
410
|
+
before do
|
411
|
+
subject.params do
|
412
|
+
optional :a
|
413
|
+
given a: ->(val) { val == 'x' } do
|
414
|
+
requires :b
|
415
|
+
end
|
416
|
+
end
|
417
|
+
subject.get('/test') { declared(params).to_json }
|
418
|
+
end
|
419
|
+
|
420
|
+
it 'applies the validations only if the parameter has the specific value' do
|
421
|
+
get '/test'
|
422
|
+
expect(last_response.status).to eq(200)
|
423
|
+
|
424
|
+
get '/test', a: 'x'
|
425
|
+
expect(last_response.status).to eq(400)
|
426
|
+
expect(last_response.body).to eq('b is missing')
|
427
|
+
|
428
|
+
get '/test', a: 'x', b: true
|
429
|
+
expect(last_response.status).to eq(200)
|
430
|
+
end
|
431
|
+
|
432
|
+
it 'raises an error if the dependent parameter was never specified' do
|
433
|
+
expect do
|
434
|
+
subject.params do
|
435
|
+
given :c do
|
436
|
+
end
|
437
|
+
end
|
438
|
+
end.to raise_error(Grape::Exceptions::UnknownParameter)
|
439
|
+
end
|
440
|
+
|
441
|
+
it 'includes the parameter within #declared(params)' do
|
442
|
+
get '/test', a: true, b: true
|
443
|
+
|
444
|
+
expect(JSON.parse(last_response.body)).to eq('a' => 'true', 'b' => 'true')
|
445
|
+
end
|
446
|
+
|
447
|
+
it 'returns a sensible error message within a nested context' do
|
448
|
+
subject.params do
|
449
|
+
requires :bar, type: Hash do
|
450
|
+
optional :a
|
451
|
+
given a: ->(val) { val == 'x' } do
|
452
|
+
requires :b
|
453
|
+
end
|
454
|
+
end
|
455
|
+
end
|
456
|
+
subject.get('/nested') { 'worked' }
|
457
|
+
|
458
|
+
get '/nested', bar: { a: 'x' }
|
459
|
+
expect(last_response.status).to eq(400)
|
460
|
+
expect(last_response.body).to eq('bar[b] is missing')
|
461
|
+
end
|
462
|
+
|
463
|
+
it 'includes the nested parameter within #declared(params)' do
|
464
|
+
subject.params do
|
465
|
+
requires :bar, type: Hash do
|
466
|
+
optional :a
|
467
|
+
given a: ->(val) { val == 'x' } do
|
468
|
+
requires :b
|
469
|
+
end
|
470
|
+
end
|
471
|
+
end
|
472
|
+
subject.get('/nested') { declared(params).to_json }
|
473
|
+
|
474
|
+
get '/nested', bar: { a: 'x', b: 'yes' }
|
475
|
+
expect(JSON.parse(last_response.body)).to eq('bar' => { 'a' => 'x', 'b' => 'yes' })
|
476
|
+
end
|
477
|
+
|
478
|
+
it 'includes level 2 nested parameters outside the given within #declared(params)' do
|
479
|
+
subject.params do
|
480
|
+
requires :bar, type: Hash do
|
481
|
+
optional :a
|
482
|
+
given a: ->(val) { val == 'x' } do
|
483
|
+
requires :c, type: Hash do
|
484
|
+
requires :b
|
485
|
+
end
|
486
|
+
end
|
487
|
+
end
|
488
|
+
end
|
489
|
+
subject.get('/nested') { declared(params).to_json }
|
490
|
+
|
491
|
+
get '/nested', bar: { a: 'x', c: { b: 'yes' } }
|
492
|
+
expect(JSON.parse(last_response.body)).to eq('bar' => { 'a' => 'x', 'c' => { 'b' => 'yes' } })
|
493
|
+
end
|
494
|
+
end
|
408
495
|
end
|
@@ -488,6 +488,11 @@ describe Grape::Validations::AllowBlankValidator do
|
|
488
488
|
get '/disallow_boolean_blank', val: false
|
489
489
|
expect(last_response.status).to eq(200)
|
490
490
|
end
|
491
|
+
|
492
|
+
it 'accepts value when time allow_blank' do
|
493
|
+
get '/disallow_datetime_blank', val: Time.now
|
494
|
+
expect(last_response.status).to eq(200)
|
495
|
+
end
|
491
496
|
end
|
492
497
|
|
493
498
|
context 'in an optional group' do
|
@@ -400,7 +400,7 @@ describe Grape::Validations::CoerceValidator do
|
|
400
400
|
|
401
401
|
get '/ints', ints: '{"i":1,"j":"2"}'
|
402
402
|
expect(last_response.status).to eq(400)
|
403
|
-
expect(last_response.body).to eq('ints
|
403
|
+
expect(last_response.body).to eq('ints is invalid')
|
404
404
|
|
405
405
|
get '/ints', ints: '[{"i":"1","j":"2"}]'
|
406
406
|
expect(last_response.status).to eq(200)
|
@@ -453,8 +453,8 @@ describe Grape::Validations::CoerceValidator do
|
|
453
453
|
subject.get '/' do
|
454
454
|
if params[:splines].is_a? Hash
|
455
455
|
params[:splines][:obj][:y]
|
456
|
-
|
457
|
-
'arrays work'
|
456
|
+
elsif params[:splines].any? { |s| s.key? :obj }
|
457
|
+
'arrays work'
|
458
458
|
end
|
459
459
|
end
|
460
460
|
|
@@ -488,8 +488,8 @@ describe Grape::Validations::CoerceValidator do
|
|
488
488
|
subject.get '/' do
|
489
489
|
if params[:splines].is_a? Hash
|
490
490
|
params[:splines][:obj][:y]
|
491
|
-
|
492
|
-
'arrays work'
|
491
|
+
elsif params[:splines].any? { |s| s.key? :obj }
|
492
|
+
'arrays work'
|
493
493
|
end
|
494
494
|
end
|
495
495
|
|
@@ -49,6 +49,32 @@ describe Grape::Validations::DefaultValidator do
|
|
49
49
|
get '/array' do
|
50
50
|
{ array: params[:array] }
|
51
51
|
end
|
52
|
+
|
53
|
+
params do
|
54
|
+
requires :thing1
|
55
|
+
optional :more_things, type: Array do
|
56
|
+
requires :nested_thing
|
57
|
+
requires :other_thing, default: 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
get '/optional_array' do
|
61
|
+
{ thing1: params[:thing1] }
|
62
|
+
end
|
63
|
+
|
64
|
+
params do
|
65
|
+
requires :root, type: Hash do
|
66
|
+
optional :some_things, type: Array do
|
67
|
+
requires :foo
|
68
|
+
optional :options, type: Array do
|
69
|
+
requires :name, type: String
|
70
|
+
requires :value, type: String
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
get '/nested_optional_array' do
|
76
|
+
{ root: params[:root] }
|
77
|
+
end
|
52
78
|
end
|
53
79
|
end
|
54
80
|
end
|
@@ -57,6 +83,24 @@ describe Grape::Validations::DefaultValidator do
|
|
57
83
|
ValidationsSpec::DefaultValidatorSpec::API
|
58
84
|
end
|
59
85
|
|
86
|
+
it 'lets you leave required values nested inside an optional blank' do
|
87
|
+
get '/optional_array', thing1: 'stuff'
|
88
|
+
expect(last_response.status).to eq(200)
|
89
|
+
expect(last_response.body).to eq({ thing1: 'stuff' }.to_json)
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'allows optional arrays to be omitted' do
|
93
|
+
params = { some_things:
|
94
|
+
[{ foo: 'one', options: [{ name: 'wat', value: 'nope' }] },
|
95
|
+
{ foo: 'two' },
|
96
|
+
{ foo: 'three', options: [{ name: 'wooop', value: 'yap' }] }
|
97
|
+
]
|
98
|
+
}
|
99
|
+
get '/nested_optional_array', root: params
|
100
|
+
expect(last_response.status).to eq(200)
|
101
|
+
expect(last_response.body).to eq({ root: params }.to_json)
|
102
|
+
end
|
103
|
+
|
60
104
|
it 'set default value for optional param' do
|
61
105
|
get('/')
|
62
106
|
expect(last_response.status).to eq(200)
|
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Grape::Validations::ValuesValidator do
|
4
4
|
module ValidationsSpec
|
5
5
|
class ValuesModel
|
6
|
-
DEFAULT_VALUES = ['valid-type1', 'valid-type2', 'valid-type3']
|
6
|
+
DEFAULT_VALUES = ['valid-type1', 'valid-type2', 'valid-type3'].freeze
|
7
7
|
class << self
|
8
8
|
def values
|
9
9
|
@values ||= []
|
@@ -245,7 +245,7 @@ describe Grape::Validations do
|
|
245
245
|
it 'errors when param is not an Array' do
|
246
246
|
get '/required', items: 'hello'
|
247
247
|
expect(last_response.status).to eq(400)
|
248
|
-
expect(last_response.body).to eq('items is invalid
|
248
|
+
expect(last_response.body).to eq('items is invalid')
|
249
249
|
|
250
250
|
get '/required', items: { key: 'foo' }
|
251
251
|
expect(last_response.status).to eq(400)
|
@@ -337,7 +337,7 @@ describe Grape::Validations do
|
|
337
337
|
|
338
338
|
get '/required', items: [{ key: 'hash in array' }]
|
339
339
|
expect(last_response.status).to eq(400)
|
340
|
-
expect(last_response.body).to eq('items is invalid, items[
|
340
|
+
expect(last_response.body).to eq('items is invalid, items[key] does not have a valid value')
|
341
341
|
end
|
342
342
|
|
343
343
|
it 'works when all params match' do
|
@@ -396,7 +396,7 @@ describe Grape::Validations do
|
|
396
396
|
end
|
397
397
|
end
|
398
398
|
|
399
|
-
it 'errors when group param is invalid'do
|
399
|
+
it 'errors when group param is invalid' do
|
400
400
|
post '/group_with_nested', items: invalid_items
|
401
401
|
expect(last_response.status).to eq(400)
|
402
402
|
end
|
@@ -408,7 +408,7 @@ describe Grape::Validations do
|
|
408
408
|
class DateRangeValidator < Grape::Validations::Base
|
409
409
|
def validate_param!(attr_name, params)
|
410
410
|
return if params[attr_name][:from] <= params[attr_name][:to]
|
411
|
-
|
411
|
+
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "'from' must be lower or equal to 'to'"
|
412
412
|
end
|
413
413
|
end
|
414
414
|
end
|
@@ -466,7 +466,7 @@ describe Grape::Validations do
|
|
466
466
|
group :children, type: Array do
|
467
467
|
requires :name
|
468
468
|
group :parents, type: Array do
|
469
|
-
requires :name
|
469
|
+
requires :name, allow_blank: false
|
470
470
|
end
|
471
471
|
end
|
472
472
|
end
|
@@ -486,13 +486,33 @@ describe Grape::Validations do
|
|
486
486
|
|
487
487
|
it 'errors when a parameter is not present' do
|
488
488
|
get '/within_array', children: [
|
489
|
-
{ name: 'Jim', parents: [{}] },
|
490
|
-
{ name: 'Job', parents: [{
|
489
|
+
{ name: 'Jim', parents: [{ name: 'Joy' }] },
|
490
|
+
{ name: 'Job', parents: [{}] }
|
491
491
|
]
|
492
492
|
# NOTE: with body parameters in json or XML or similar this
|
493
493
|
# should actually fail with: children[parents][name] is missing.
|
494
494
|
expect(last_response.status).to eq(400)
|
495
|
-
expect(last_response.body).to eq('children[
|
495
|
+
expect(last_response.body).to eq('children[1][parents] is missing')
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'errors when a parameter is not present in array within array' do
|
499
|
+
get '/within_array', children: [
|
500
|
+
{ name: 'Jim', parents: [{ name: 'Joy' }] },
|
501
|
+
{ name: 'Job', parents: [{ name: 'Bill' }, { name: '' }] }
|
502
|
+
]
|
503
|
+
|
504
|
+
expect(last_response.status).to eq(400)
|
505
|
+
expect(last_response.body).to eq('children[1][parents][1][name] is empty')
|
506
|
+
end
|
507
|
+
|
508
|
+
it 'handle errors for all array elements' do
|
509
|
+
get '/within_array', children: [
|
510
|
+
{ name: 'Jim', parents: [] },
|
511
|
+
{ name: 'Job', parents: [] }
|
512
|
+
]
|
513
|
+
|
514
|
+
expect(last_response.status).to eq(400)
|
515
|
+
expect(last_response.body).to eq('children[0][parents] is missing, children[1][parents] is missing')
|
496
516
|
end
|
497
517
|
|
498
518
|
it 'safely handles empty arrays and blank parameters' do
|
@@ -507,14 +527,13 @@ describe Grape::Validations do
|
|
507
527
|
end
|
508
528
|
|
509
529
|
it 'errors when param is not an Array' do
|
510
|
-
# NOTE: would be nicer if these just returned 'children is invalid'
|
511
530
|
get '/within_array', children: 'hello'
|
512
531
|
expect(last_response.status).to eq(400)
|
513
|
-
expect(last_response.body).to eq('children is invalid
|
532
|
+
expect(last_response.body).to eq('children is invalid')
|
514
533
|
|
515
534
|
get '/within_array', children: { name: 'foo' }
|
516
535
|
expect(last_response.status).to eq(400)
|
517
|
-
expect(last_response.body).to eq('children is invalid
|
536
|
+
expect(last_response.body).to eq('children is invalid')
|
518
537
|
|
519
538
|
get '/within_array', children: [name: 'Jay', parents: { name: 'Fred' }]
|
520
539
|
expect(last_response.status).to eq(400)
|
@@ -565,7 +584,7 @@ describe Grape::Validations do
|
|
565
584
|
it 'requires defaults to Array type' do
|
566
585
|
get '/req', planets: 'Jupiter, Saturn'
|
567
586
|
expect(last_response.status).to eq(400)
|
568
|
-
expect(last_response.body).to eq('planets is invalid
|
587
|
+
expect(last_response.body).to eq('planets is invalid')
|
569
588
|
|
570
589
|
get '/req', planets: { name: 'Jupiter' }
|
571
590
|
expect(last_response.status).to eq(400)
|
@@ -581,7 +600,7 @@ describe Grape::Validations do
|
|
581
600
|
it 'optional defaults to Array type' do
|
582
601
|
get '/opt', name: 'Jupiter', moons: 'Europa, Ganymede'
|
583
602
|
expect(last_response.status).to eq(400)
|
584
|
-
expect(last_response.body).to eq('moons is invalid
|
603
|
+
expect(last_response.body).to eq('moons is invalid')
|
585
604
|
|
586
605
|
get '/opt', name: 'Jupiter', moons: { name: 'Ganymede' }
|
587
606
|
expect(last_response.status).to eq(400)
|
@@ -600,7 +619,7 @@ describe Grape::Validations do
|
|
600
619
|
it 'group defaults to Array type' do
|
601
620
|
get '/grp', stars: 'Sun'
|
602
621
|
expect(last_response.status).to eq(400)
|
603
|
-
expect(last_response.body).to eq('stars is invalid
|
622
|
+
expect(last_response.body).to eq('stars is invalid')
|
604
623
|
|
605
624
|
get '/grp', stars: { name: 'Sun' }
|
606
625
|
expect(last_response.status).to eq(400)
|
@@ -689,7 +708,7 @@ describe Grape::Validations do
|
|
689
708
|
it "errors when param is present but isn't an Array" do
|
690
709
|
get '/optional_group', items: 'hello'
|
691
710
|
expect(last_response.status).to eq(400)
|
692
|
-
expect(last_response.body).to eq('items is invalid
|
711
|
+
expect(last_response.body).to eq('items is invalid')
|
693
712
|
|
694
713
|
get '/optional_group', items: { key: 'foo' }
|
695
714
|
expect(last_response.status).to eq(400)
|
@@ -794,7 +813,7 @@ describe Grape::Validations do
|
|
794
813
|
class Customvalidator < Grape::Validations::Base
|
795
814
|
def validate_param!(attr_name, params)
|
796
815
|
return if params[attr_name] == 'im custom'
|
797
|
-
|
816
|
+
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: 'is not custom!'
|
798
817
|
end
|
799
818
|
end
|
800
819
|
end
|
@@ -942,7 +961,7 @@ describe Grape::Validations do
|
|
942
961
|
class CustomvalidatorWithOptions < Grape::Validations::Base
|
943
962
|
def validate_param!(attr_name, params)
|
944
963
|
return if params[attr_name] == @option[:text]
|
945
|
-
|
964
|
+
raise Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: message
|
946
965
|
end
|
947
966
|
end
|
948
967
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,14 +6,7 @@ require 'grape'
|
|
6
6
|
|
7
7
|
require 'rubygems'
|
8
8
|
require 'bundler'
|
9
|
-
Bundler.
|
10
|
-
|
11
|
-
require 'json'
|
12
|
-
require 'rack/test'
|
13
|
-
require 'base64'
|
14
|
-
require 'cookiejar'
|
15
|
-
require 'mime/types'
|
16
|
-
require 'cgi'
|
9
|
+
Bundler.require :default, :test
|
17
10
|
|
18
11
|
Dir["#{File.dirname(__FILE__)}/support/*.rb"].each do |file|
|
19
12
|
require file
|
@@ -13,7 +13,7 @@ def versioned_path(options = {})
|
|
13
13
|
when :accept_version_header
|
14
14
|
File.join('/', options[:prefix] || '', options[:path])
|
15
15
|
else
|
16
|
-
|
16
|
+
raise ArgumentError.new("unknown versioning strategy: #{options[:using]}")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -32,10 +32,10 @@ def versioned_headers(options)
|
|
32
32
|
}
|
33
33
|
when :accept_version_header
|
34
34
|
{
|
35
|
-
'HTTP_ACCEPT_VERSION' =>
|
35
|
+
'HTTP_ACCEPT_VERSION' => options[:version].to_s
|
36
36
|
}
|
37
37
|
else
|
38
|
-
|
38
|
+
raise ArgumentError.new("unknown versioning strategy: #{options[:using]}")
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
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: 0.17.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: 2016-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -136,188 +136,6 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
- !ruby/object:Gem::Dependency
|
140
|
-
name: grape-entity
|
141
|
-
requirement: !ruby/object:Gem::Requirement
|
142
|
-
requirements:
|
143
|
-
- - '='
|
144
|
-
- !ruby/object:Gem::Version
|
145
|
-
version: 0.5.0
|
146
|
-
type: :development
|
147
|
-
prerelease: false
|
148
|
-
version_requirements: !ruby/object:Gem::Requirement
|
149
|
-
requirements:
|
150
|
-
- - '='
|
151
|
-
- !ruby/object:Gem::Version
|
152
|
-
version: 0.5.0
|
153
|
-
- !ruby/object:Gem::Dependency
|
154
|
-
name: rake
|
155
|
-
requirement: !ruby/object:Gem::Requirement
|
156
|
-
requirements:
|
157
|
-
- - "~>"
|
158
|
-
- !ruby/object:Gem::Version
|
159
|
-
version: '10'
|
160
|
-
type: :development
|
161
|
-
prerelease: false
|
162
|
-
version_requirements: !ruby/object:Gem::Requirement
|
163
|
-
requirements:
|
164
|
-
- - "~>"
|
165
|
-
- !ruby/object:Gem::Version
|
166
|
-
version: '10'
|
167
|
-
- !ruby/object:Gem::Dependency
|
168
|
-
name: maruku
|
169
|
-
requirement: !ruby/object:Gem::Requirement
|
170
|
-
requirements:
|
171
|
-
- - ">="
|
172
|
-
- !ruby/object:Gem::Version
|
173
|
-
version: '0'
|
174
|
-
type: :development
|
175
|
-
prerelease: false
|
176
|
-
version_requirements: !ruby/object:Gem::Requirement
|
177
|
-
requirements:
|
178
|
-
- - ">="
|
179
|
-
- !ruby/object:Gem::Version
|
180
|
-
version: '0'
|
181
|
-
- !ruby/object:Gem::Dependency
|
182
|
-
name: yard
|
183
|
-
requirement: !ruby/object:Gem::Requirement
|
184
|
-
requirements:
|
185
|
-
- - ">="
|
186
|
-
- !ruby/object:Gem::Version
|
187
|
-
version: '0'
|
188
|
-
type: :development
|
189
|
-
prerelease: false
|
190
|
-
version_requirements: !ruby/object:Gem::Requirement
|
191
|
-
requirements:
|
192
|
-
- - ">="
|
193
|
-
- !ruby/object:Gem::Version
|
194
|
-
version: '0'
|
195
|
-
- !ruby/object:Gem::Dependency
|
196
|
-
name: rack-test
|
197
|
-
requirement: !ruby/object:Gem::Requirement
|
198
|
-
requirements:
|
199
|
-
- - ">="
|
200
|
-
- !ruby/object:Gem::Version
|
201
|
-
version: '0'
|
202
|
-
type: :development
|
203
|
-
prerelease: false
|
204
|
-
version_requirements: !ruby/object:Gem::Requirement
|
205
|
-
requirements:
|
206
|
-
- - ">="
|
207
|
-
- !ruby/object:Gem::Version
|
208
|
-
version: '0'
|
209
|
-
- !ruby/object:Gem::Dependency
|
210
|
-
name: rspec
|
211
|
-
requirement: !ruby/object:Gem::Requirement
|
212
|
-
requirements:
|
213
|
-
- - "~>"
|
214
|
-
- !ruby/object:Gem::Version
|
215
|
-
version: '3.0'
|
216
|
-
type: :development
|
217
|
-
prerelease: false
|
218
|
-
version_requirements: !ruby/object:Gem::Requirement
|
219
|
-
requirements:
|
220
|
-
- - "~>"
|
221
|
-
- !ruby/object:Gem::Version
|
222
|
-
version: '3.0'
|
223
|
-
- !ruby/object:Gem::Dependency
|
224
|
-
name: bundler
|
225
|
-
requirement: !ruby/object:Gem::Requirement
|
226
|
-
requirements:
|
227
|
-
- - ">="
|
228
|
-
- !ruby/object:Gem::Version
|
229
|
-
version: '0'
|
230
|
-
type: :development
|
231
|
-
prerelease: false
|
232
|
-
version_requirements: !ruby/object:Gem::Requirement
|
233
|
-
requirements:
|
234
|
-
- - ">="
|
235
|
-
- !ruby/object:Gem::Version
|
236
|
-
version: '0'
|
237
|
-
- !ruby/object:Gem::Dependency
|
238
|
-
name: cookiejar
|
239
|
-
requirement: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - ">="
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: '0'
|
244
|
-
type: :development
|
245
|
-
prerelease: false
|
246
|
-
version_requirements: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - ">="
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: '0'
|
251
|
-
- !ruby/object:Gem::Dependency
|
252
|
-
name: rack-contrib
|
253
|
-
requirement: !ruby/object:Gem::Requirement
|
254
|
-
requirements:
|
255
|
-
- - ">="
|
256
|
-
- !ruby/object:Gem::Version
|
257
|
-
version: '0'
|
258
|
-
type: :development
|
259
|
-
prerelease: false
|
260
|
-
version_requirements: !ruby/object:Gem::Requirement
|
261
|
-
requirements:
|
262
|
-
- - ">="
|
263
|
-
- !ruby/object:Gem::Version
|
264
|
-
version: '0'
|
265
|
-
- !ruby/object:Gem::Dependency
|
266
|
-
name: mime-types
|
267
|
-
requirement: !ruby/object:Gem::Requirement
|
268
|
-
requirements:
|
269
|
-
- - "<"
|
270
|
-
- !ruby/object:Gem::Version
|
271
|
-
version: '3.0'
|
272
|
-
type: :development
|
273
|
-
prerelease: false
|
274
|
-
version_requirements: !ruby/object:Gem::Requirement
|
275
|
-
requirements:
|
276
|
-
- - "<"
|
277
|
-
- !ruby/object:Gem::Version
|
278
|
-
version: '3.0'
|
279
|
-
- !ruby/object:Gem::Dependency
|
280
|
-
name: appraisal
|
281
|
-
requirement: !ruby/object:Gem::Requirement
|
282
|
-
requirements:
|
283
|
-
- - ">="
|
284
|
-
- !ruby/object:Gem::Version
|
285
|
-
version: '0'
|
286
|
-
type: :development
|
287
|
-
prerelease: false
|
288
|
-
version_requirements: !ruby/object:Gem::Requirement
|
289
|
-
requirements:
|
290
|
-
- - ">="
|
291
|
-
- !ruby/object:Gem::Version
|
292
|
-
version: '0'
|
293
|
-
- !ruby/object:Gem::Dependency
|
294
|
-
name: benchmark-ips
|
295
|
-
requirement: !ruby/object:Gem::Requirement
|
296
|
-
requirements:
|
297
|
-
- - ">="
|
298
|
-
- !ruby/object:Gem::Version
|
299
|
-
version: '0'
|
300
|
-
type: :development
|
301
|
-
prerelease: false
|
302
|
-
version_requirements: !ruby/object:Gem::Requirement
|
303
|
-
requirements:
|
304
|
-
- - ">="
|
305
|
-
- !ruby/object:Gem::Version
|
306
|
-
version: '0'
|
307
|
-
- !ruby/object:Gem::Dependency
|
308
|
-
name: rubocop
|
309
|
-
requirement: !ruby/object:Gem::Requirement
|
310
|
-
requirements:
|
311
|
-
- - '='
|
312
|
-
- !ruby/object:Gem::Version
|
313
|
-
version: 0.35.1
|
314
|
-
type: :development
|
315
|
-
prerelease: false
|
316
|
-
version_requirements: !ruby/object:Gem::Requirement
|
317
|
-
requirements:
|
318
|
-
- - '='
|
319
|
-
- !ruby/object:Gem::Version
|
320
|
-
version: 0.35.1
|
321
139
|
description: A Ruby framework for rapid API development with great conventions.
|
322
140
|
email:
|
323
141
|
- michael@intridea.com
|
@@ -328,6 +146,7 @@ files:
|
|
328
146
|
- Appraisals
|
329
147
|
- CHANGELOG.md
|
330
148
|
- CONTRIBUTING.md
|
149
|
+
- Dangerfile
|
331
150
|
- Gemfile
|
332
151
|
- Gemfile.lock
|
333
152
|
- Guardfile
|
@@ -339,8 +158,8 @@ files:
|
|
339
158
|
- benchmark/simple.rb
|
340
159
|
- gemfiles/rack_1.5.2.gemfile
|
341
160
|
- gemfiles/rails_3.gemfile
|
342
|
-
- gemfiles/rails_3.gemfile.lock
|
343
161
|
- gemfiles/rails_4.gemfile
|
162
|
+
- gemfiles/rails_5.gemfile
|
344
163
|
- grape.gemspec
|
345
164
|
- grape.png
|
346
165
|
- lib/grape.rb
|
@@ -385,6 +204,7 @@ files:
|
|
385
204
|
- lib/grape/exceptions/unknown_validator.rb
|
386
205
|
- lib/grape/exceptions/unsupported_group_type.rb
|
387
206
|
- lib/grape/exceptions/validation.rb
|
207
|
+
- lib/grape/exceptions/validation_array_errors.rb
|
388
208
|
- lib/grape/exceptions/validation_errors.rb
|
389
209
|
- lib/grape/formatter.rb
|
390
210
|
- lib/grape/formatter/json.rb
|
@@ -402,6 +222,7 @@ files:
|
|
402
222
|
- lib/grape/middleware/filter.rb
|
403
223
|
- lib/grape/middleware/formatter.rb
|
404
224
|
- lib/grape/middleware/globals.rb
|
225
|
+
- lib/grape/middleware/stack.rb
|
405
226
|
- lib/grape/middleware/versioner.rb
|
406
227
|
- lib/grape/middleware/versioner/accept_version_header.rb
|
407
228
|
- lib/grape/middleware/versioner/header.rb
|
@@ -427,6 +248,7 @@ files:
|
|
427
248
|
- lib/grape/util/inheritable_setting.rb
|
428
249
|
- lib/grape/util/inheritable_values.rb
|
429
250
|
- lib/grape/util/registrable.rb
|
251
|
+
- lib/grape/util/reverse_stackable_values.rb
|
430
252
|
- lib/grape/util/stackable_values.rb
|
431
253
|
- lib/grape/util/strict_hash_configuration.rb
|
432
254
|
- lib/grape/validations.rb
|
@@ -453,14 +275,13 @@ files:
|
|
453
275
|
- lib/grape/validations/validators/regexp.rb
|
454
276
|
- lib/grape/validations/validators/values.rb
|
455
277
|
- lib/grape/version.rb
|
456
|
-
- pkg/grape-0.16.1.gem
|
457
|
-
- pkg/patch.diff
|
458
278
|
- spec/grape/api/custom_validations_spec.rb
|
459
279
|
- spec/grape/api/deeply_included_options_spec.rb
|
460
280
|
- spec/grape/api/invalid_format_spec.rb
|
461
281
|
- spec/grape/api/namespace_parameters_in_route_spec.rb
|
462
282
|
- spec/grape/api/nested_helpers_spec.rb
|
463
283
|
- spec/grape/api/optional_parameters_in_route_spec.rb
|
284
|
+
- spec/grape/api/parameters_modification_spec.rb
|
464
285
|
- spec/grape/api/patch_method_helpers_spec.rb
|
465
286
|
- spec/grape/api/recognize_path_spec.rb
|
466
287
|
- spec/grape/api/required_parameters_in_route_spec.rb
|
@@ -504,6 +325,7 @@ files:
|
|
504
325
|
- spec/grape/middleware/exception_spec.rb
|
505
326
|
- spec/grape/middleware/formatter_spec.rb
|
506
327
|
- spec/grape/middleware/globals_spec.rb
|
328
|
+
- spec/grape/middleware/stack_spec.rb
|
507
329
|
- spec/grape/middleware/versioner/accept_version_header_spec.rb
|
508
330
|
- spec/grape/middleware/versioner/header_spec.rb
|
509
331
|
- spec/grape/middleware/versioner/param_spec.rb
|
@@ -515,6 +337,7 @@ files:
|
|
515
337
|
- spec/grape/request_spec.rb
|
516
338
|
- spec/grape/util/inheritable_setting_spec.rb
|
517
339
|
- spec/grape/util/inheritable_values_spec.rb
|
340
|
+
- spec/grape/util/reverse_stackable_values_spec.rb
|
518
341
|
- spec/grape/util/stackable_values_spec.rb
|
519
342
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
520
343
|
- spec/grape/validations/attributes_iterator_spec.rb
|
@@ -539,7 +362,6 @@ files:
|
|
539
362
|
- spec/support/endpoint_faker.rb
|
540
363
|
- spec/support/file_streamer.rb
|
541
364
|
- spec/support/versioned_helpers.rb
|
542
|
-
- tmp/Gemfile.lock
|
543
365
|
homepage: https://github.com/ruby-grape/grape
|
544
366
|
licenses:
|
545
367
|
- MIT
|
@@ -571,6 +393,7 @@ test_files:
|
|
571
393
|
- spec/grape/api/namespace_parameters_in_route_spec.rb
|
572
394
|
- spec/grape/api/nested_helpers_spec.rb
|
573
395
|
- spec/grape/api/optional_parameters_in_route_spec.rb
|
396
|
+
- spec/grape/api/parameters_modification_spec.rb
|
574
397
|
- spec/grape/api/patch_method_helpers_spec.rb
|
575
398
|
- spec/grape/api/recognize_path_spec.rb
|
576
399
|
- spec/grape/api/required_parameters_in_route_spec.rb
|
@@ -614,6 +437,7 @@ test_files:
|
|
614
437
|
- spec/grape/middleware/exception_spec.rb
|
615
438
|
- spec/grape/middleware/formatter_spec.rb
|
616
439
|
- spec/grape/middleware/globals_spec.rb
|
440
|
+
- spec/grape/middleware/stack_spec.rb
|
617
441
|
- spec/grape/middleware/versioner/accept_version_header_spec.rb
|
618
442
|
- spec/grape/middleware/versioner/header_spec.rb
|
619
443
|
- spec/grape/middleware/versioner/param_spec.rb
|
@@ -625,6 +449,7 @@ test_files:
|
|
625
449
|
- spec/grape/request_spec.rb
|
626
450
|
- spec/grape/util/inheritable_setting_spec.rb
|
627
451
|
- spec/grape/util/inheritable_values_spec.rb
|
452
|
+
- spec/grape/util/reverse_stackable_values_spec.rb
|
628
453
|
- spec/grape/util/stackable_values_spec.rb
|
629
454
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
630
455
|
- spec/grape/validations/attributes_iterator_spec.rb
|