grape 0.12.0 → 0.14.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 +9 -4
- data/CHANGELOG.md +265 -215
- data/CONTRIBUTING.md +4 -4
- data/Gemfile +0 -1
- data/Gemfile.lock +166 -0
- data/README.md +426 -161
- data/RELEASING.md +14 -6
- data/Rakefile +30 -33
- data/UPGRADING.md +54 -23
- data/benchmark/simple.rb +27 -0
- data/gemfiles/rack_1.5.2.gemfile +13 -0
- data/gemfiles/rails_3.gemfile +2 -2
- data/gemfiles/rails_4.gemfile +1 -2
- data/grape.gemspec +6 -7
- data/lib/grape/api.rb +24 -4
- data/lib/grape/dsl/callbacks.rb +20 -0
- data/lib/grape/dsl/configuration.rb +59 -2
- data/lib/grape/dsl/helpers.rb +8 -3
- data/lib/grape/dsl/inside_route.rb +100 -45
- data/lib/grape/dsl/parameters.rb +96 -7
- data/lib/grape/dsl/request_response.rb +1 -1
- data/lib/grape/dsl/routing.rb +17 -4
- data/lib/grape/dsl/settings.rb +36 -1
- data/lib/grape/dsl/validations.rb +7 -5
- data/lib/grape/endpoint.rb +102 -57
- data/lib/grape/error_formatter/base.rb +6 -6
- data/lib/grape/exceptions/base.rb +5 -5
- data/lib/grape/exceptions/invalid_version_header.rb +10 -0
- data/lib/grape/exceptions/unknown_parameter.rb +10 -0
- data/lib/grape/exceptions/validation_errors.rb +4 -3
- data/lib/grape/formatter/serializable_hash.rb +3 -2
- data/lib/grape/http/headers.rb +0 -1
- data/lib/grape/locale/en.yml +5 -1
- data/lib/grape/middleware/auth/base.rb +2 -2
- data/lib/grape/middleware/auth/dsl.rb +1 -1
- data/lib/grape/middleware/auth/strategies.rb +1 -1
- data/lib/grape/middleware/base.rb +8 -4
- data/lib/grape/middleware/error.rb +3 -2
- data/lib/grape/middleware/filter.rb +1 -1
- data/lib/grape/middleware/formatter.rb +64 -45
- data/lib/grape/middleware/globals.rb +3 -3
- data/lib/grape/middleware/versioner/accept_version_header.rb +5 -7
- data/lib/grape/middleware/versioner/header.rb +113 -50
- data/lib/grape/middleware/versioner/param.rb +5 -8
- data/lib/grape/middleware/versioner/parse_media_type_patch.rb +20 -0
- data/lib/grape/middleware/versioner/path.rb +3 -6
- data/lib/grape/namespace.rb +13 -2
- data/lib/grape/path.rb +4 -3
- data/lib/grape/request.rb +40 -0
- data/lib/grape/route.rb +5 -0
- data/lib/grape/util/content_types.rb +9 -9
- data/lib/grape/util/env.rb +22 -0
- data/lib/grape/util/file_response.rb +21 -0
- data/lib/grape/util/inheritable_setting.rb +23 -2
- data/lib/grape/util/inheritable_values.rb +1 -1
- data/lib/grape/util/stackable_values.rb +5 -2
- data/lib/grape/util/strict_hash_configuration.rb +2 -1
- data/lib/grape/validations/attributes_iterator.rb +8 -3
- data/lib/grape/validations/params_scope.rb +164 -22
- data/lib/grape/validations/types/build_coercer.rb +53 -0
- data/lib/grape/validations/types/custom_type_coercer.rb +183 -0
- data/lib/grape/validations/types/file.rb +28 -0
- data/lib/grape/validations/types/json.rb +65 -0
- data/lib/grape/validations/types/multiple_type_coercer.rb +76 -0
- data/lib/grape/validations/types/variant_collection_coercer.rb +59 -0
- data/lib/grape/validations/types/virtus_collection_patch.rb +16 -0
- data/lib/grape/validations/types.rb +144 -0
- data/lib/grape/validations/validators/all_or_none.rb +1 -1
- data/lib/grape/validations/validators/allow_blank.rb +3 -3
- data/lib/grape/validations/validators/base.rb +7 -0
- data/lib/grape/validations/validators/coerce.rb +32 -34
- data/lib/grape/validations/validators/presence.rb +2 -3
- data/lib/grape/validations/validators/regexp.rb +2 -4
- data/lib/grape/validations/validators/values.rb +3 -3
- data/lib/grape/validations.rb +5 -0
- data/lib/grape/version.rb +2 -1
- data/lib/grape.rb +15 -12
- data/pkg/grape-0.13.0.gem +0 -0
- data/spec/grape/api/custom_validations_spec.rb +5 -4
- data/spec/grape/api/deeply_included_options_spec.rb +7 -7
- data/spec/grape/api/nested_helpers_spec.rb +4 -2
- data/spec/grape/api/shared_helpers_spec.rb +8 -8
- data/spec/grape/api_spec.rb +151 -54
- data/spec/grape/dsl/configuration_spec.rb +13 -0
- data/spec/grape/dsl/helpers_spec.rb +16 -2
- data/spec/grape/dsl/inside_route_spec.rb +40 -4
- data/spec/grape/dsl/parameters_spec.rb +0 -6
- data/spec/grape/dsl/routing_spec.rb +1 -1
- data/spec/grape/dsl/validations_spec.rb +18 -0
- data/spec/grape/endpoint_spec.rb +130 -6
- data/spec/grape/entity_spec.rb +10 -8
- data/spec/grape/exceptions/invalid_accept_header_spec.rb +1 -15
- data/spec/grape/exceptions/validation_errors_spec.rb +28 -0
- data/spec/grape/integration/rack_spec.rb +3 -2
- data/spec/grape/middleware/base_spec.rb +40 -16
- data/spec/grape/middleware/error_spec.rb +16 -15
- data/spec/grape/middleware/exception_spec.rb +45 -43
- data/spec/grape/middleware/formatter_spec.rb +34 -5
- data/spec/grape/middleware/versioner/header_spec.rb +79 -47
- data/spec/grape/path_spec.rb +10 -10
- data/spec/grape/presenters/presenter_spec.rb +2 -2
- data/spec/grape/request_spec.rb +100 -0
- data/spec/grape/util/inheritable_values_spec.rb +14 -0
- data/spec/grape/util/stackable_values_spec.rb +10 -0
- data/spec/grape/validations/params_scope_spec.rb +86 -0
- data/spec/grape/validations/types_spec.rb +95 -0
- data/spec/grape/validations/validators/coerce_spec.rb +364 -10
- data/spec/grape/validations/validators/values_spec.rb +27 -15
- data/spec/grape/validations_spec.rb +53 -24
- data/spec/shared/versioning_examples.rb +2 -2
- data/spec/spec_helper.rb +0 -1
- data/spec/support/versioned_helpers.rb +2 -2
- metadata +55 -14
- data/.gitignore +0 -46
- data/.rspec +0 -2
- data/.rubocop.yml +0 -7
- data/.rubocop_todo.yml +0 -84
- data/.travis.yml +0 -20
- data/.yardopts +0 -2
- data/lib/backports/active_support/deep_dup.rb +0 -49
- data/lib/backports/active_support/duplicable.rb +0 -88
- data/lib/grape/http/request.rb +0 -27
@@ -318,6 +318,35 @@ describe Grape::Validations do
|
|
318
318
|
end
|
319
319
|
end
|
320
320
|
|
321
|
+
context 'hash with a required param with validation' do
|
322
|
+
before do
|
323
|
+
subject.params do
|
324
|
+
requires :items, type: Hash do
|
325
|
+
requires :key, type: String, values: %w(a b)
|
326
|
+
end
|
327
|
+
end
|
328
|
+
subject.get '/required' do
|
329
|
+
'required works'
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
it 'errors when param is not a Hash' do
|
334
|
+
get '/required', items: 'not a hash'
|
335
|
+
expect(last_response.status).to eq(400)
|
336
|
+
expect(last_response.body).to eq('items is invalid, items[key] is missing, items[key] is invalid')
|
337
|
+
|
338
|
+
get '/required', items: [{ key: 'hash in array' }]
|
339
|
+
expect(last_response.status).to eq(400)
|
340
|
+
expect(last_response.body).to eq('items is invalid, items[0][key] does not have a valid value')
|
341
|
+
end
|
342
|
+
|
343
|
+
it 'works when all params match' do
|
344
|
+
get '/required', items: { key: 'a' }
|
345
|
+
expect(last_response.status).to eq(200)
|
346
|
+
expect(last_response.body).to eq('required works')
|
347
|
+
end
|
348
|
+
end
|
349
|
+
|
321
350
|
context 'group' do
|
322
351
|
before do
|
323
352
|
subject.params do
|
@@ -374,10 +403,11 @@ describe Grape::Validations do
|
|
374
403
|
end
|
375
404
|
|
376
405
|
context 'custom validator for a Hash' do
|
377
|
-
module
|
378
|
-
|
379
|
-
|
380
|
-
|
406
|
+
module ValuesSpec
|
407
|
+
module DateRangeValidations
|
408
|
+
class DateRangeValidator < Grape::Validations::Base
|
409
|
+
def validate_param!(attr_name, params)
|
410
|
+
return if params[attr_name][:from] <= params[attr_name][:to]
|
381
411
|
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: "'from' must be lower or equal to 'to'"
|
382
412
|
end
|
383
413
|
end
|
@@ -462,7 +492,7 @@ describe Grape::Validations do
|
|
462
492
|
# NOTE: with body parameters in json or XML or similar this
|
463
493
|
# should actually fail with: children[parents][name] is missing.
|
464
494
|
expect(last_response.status).to eq(400)
|
465
|
-
expect(last_response.body).to eq('children[parents] is missing')
|
495
|
+
expect(last_response.body).to eq('children[0][parents] is missing')
|
466
496
|
end
|
467
497
|
|
468
498
|
it 'safely handles empty arrays and blank parameters' do
|
@@ -473,7 +503,7 @@ describe Grape::Validations do
|
|
473
503
|
expect(last_response.body).to eq('children is missing')
|
474
504
|
get '/within_array', children: [name: 'Jay']
|
475
505
|
expect(last_response.status).to eq(400)
|
476
|
-
expect(last_response.body).to eq('children[parents] is missing')
|
506
|
+
expect(last_response.body).to eq('children[0][parents] is missing')
|
477
507
|
end
|
478
508
|
|
479
509
|
it 'errors when param is not an Array' do
|
@@ -488,7 +518,7 @@ describe Grape::Validations do
|
|
488
518
|
|
489
519
|
get '/within_array', children: [name: 'Jay', parents: { name: 'Fred' }]
|
490
520
|
expect(last_response.status).to eq(400)
|
491
|
-
expect(last_response.body).to eq('children[parents] is invalid')
|
521
|
+
expect(last_response.body).to eq('children[0][parents] is invalid')
|
492
522
|
end
|
493
523
|
end
|
494
524
|
|
@@ -614,7 +644,7 @@ describe Grape::Validations do
|
|
614
644
|
{ name: 'Job', parents: [{ name: 'Joy' }] }
|
615
645
|
]
|
616
646
|
expect(last_response.status).to eq(400)
|
617
|
-
expect(last_response.body).to eq('children[parents][name] is missing')
|
647
|
+
expect(last_response.body).to eq('children[0][parents][0][name] is missing')
|
618
648
|
end
|
619
649
|
|
620
650
|
it 'safely handles empty arrays and blank parameters' do
|
@@ -622,7 +652,7 @@ describe Grape::Validations do
|
|
622
652
|
expect(last_response.status).to eq(200)
|
623
653
|
put_with_json '/within_array', children: [name: 'Jay']
|
624
654
|
expect(last_response.status).to eq(400)
|
625
|
-
expect(last_response.body).to eq('children[parents] is missing')
|
655
|
+
expect(last_response.body).to eq('children[0][parents] is missing')
|
626
656
|
end
|
627
657
|
end
|
628
658
|
|
@@ -653,7 +683,7 @@ describe Grape::Validations do
|
|
653
683
|
it 'errors when group is present, but required param is not' do
|
654
684
|
get '/optional_group', items: [{ not_key: 'foo' }]
|
655
685
|
expect(last_response.status).to eq(400)
|
656
|
-
expect(last_response.body).to eq('items[key] is missing')
|
686
|
+
expect(last_response.body).to eq('items[0][key] is missing')
|
657
687
|
end
|
658
688
|
|
659
689
|
it "errors when param is present but isn't an Array" do
|
@@ -697,7 +727,7 @@ describe Grape::Validations do
|
|
697
727
|
it 'does internal validations if the outer group is present' do
|
698
728
|
get '/nested_optional_group', items: [{ key: 'foo' }]
|
699
729
|
expect(last_response.status).to eq(400)
|
700
|
-
expect(last_response.body).to eq('items[required_subitems] is missing')
|
730
|
+
expect(last_response.body).to eq('items[0][required_subitems] is missing')
|
701
731
|
|
702
732
|
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }] }]
|
703
733
|
expect(last_response.status).to eq(200)
|
@@ -707,7 +737,7 @@ describe Grape::Validations do
|
|
707
737
|
it 'handles deep nesting' do
|
708
738
|
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }], optional_subitems: [{ not_value: 'baz' }] }]
|
709
739
|
expect(last_response.status).to eq(400)
|
710
|
-
expect(last_response.body).to eq('items[optional_subitems][value] is missing')
|
740
|
+
expect(last_response.body).to eq('items[0][optional_subitems][0][value] is missing')
|
711
741
|
|
712
742
|
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }], optional_subitems: [{ value: 'baz' }] }]
|
713
743
|
expect(last_response.status).to eq(200)
|
@@ -717,7 +747,7 @@ describe Grape::Validations do
|
|
717
747
|
it 'handles validation within arrays' do
|
718
748
|
get '/nested_optional_group', items: [{ key: 'foo' }]
|
719
749
|
expect(last_response.status).to eq(400)
|
720
|
-
expect(last_response.body).to eq('items[required_subitems] is missing')
|
750
|
+
expect(last_response.body).to eq('items[0][required_subitems] is missing')
|
721
751
|
|
722
752
|
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }] }]
|
723
753
|
expect(last_response.status).to eq(200)
|
@@ -725,7 +755,7 @@ describe Grape::Validations do
|
|
725
755
|
|
726
756
|
get '/nested_optional_group', items: [{ key: 'foo', required_subitems: [{ value: 'bar' }], optional_subitems: [{ not_value: 'baz' }] }]
|
727
757
|
expect(last_response.status).to eq(400)
|
728
|
-
expect(last_response.body).to eq('items[optional_subitems][value] is missing')
|
758
|
+
expect(last_response.body).to eq('items[0][optional_subitems][0][value] is missing')
|
729
759
|
end
|
730
760
|
|
731
761
|
it 'adds to declared parameters' do
|
@@ -763,9 +793,8 @@ describe Grape::Validations do
|
|
763
793
|
module CustomValidations
|
764
794
|
class Customvalidator < Grape::Validations::Base
|
765
795
|
def validate_param!(attr_name, params)
|
766
|
-
|
767
|
-
|
768
|
-
end
|
796
|
+
return if params[attr_name] == 'im custom'
|
797
|
+
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: 'is not custom!'
|
769
798
|
end
|
770
799
|
end
|
771
800
|
end
|
@@ -912,9 +941,8 @@ describe Grape::Validations do
|
|
912
941
|
module CustomValidations
|
913
942
|
class CustomvalidatorWithOptions < Grape::Validations::Base
|
914
943
|
def validate_param!(attr_name, params)
|
915
|
-
|
916
|
-
|
917
|
-
end
|
944
|
+
return if params[attr_name] == @option[:text]
|
945
|
+
fail Grape::Exceptions::Validation, params: [@scope.full_name(attr_name)], message: @option[:error_message]
|
918
946
|
end
|
919
947
|
end
|
920
948
|
end
|
@@ -950,25 +978,26 @@ describe Grape::Validations do
|
|
950
978
|
end
|
951
979
|
|
952
980
|
it 'in helper module which kind of Grape::DSL::Helpers::BaseHelper' do
|
953
|
-
|
981
|
+
shared_params = Module.new do
|
954
982
|
extend Grape::DSL::Helpers::BaseHelper
|
955
983
|
params :pagination do
|
956
984
|
end
|
957
985
|
end
|
958
|
-
subject.helpers
|
986
|
+
subject.helpers shared_params
|
959
987
|
end
|
960
988
|
end
|
961
989
|
|
962
990
|
context 'can be included in usual params' do
|
963
991
|
before do
|
964
|
-
|
992
|
+
shared_params = Module.new do
|
965
993
|
extend Grape::DSL::Helpers::BaseHelper
|
966
994
|
params :period do
|
967
995
|
optional :start_date
|
968
996
|
optional :end_date
|
969
997
|
end
|
970
998
|
end
|
971
|
-
|
999
|
+
|
1000
|
+
subject.helpers shared_params
|
972
1001
|
|
973
1002
|
subject.helpers do
|
974
1003
|
params :pagination do
|
@@ -3,7 +3,7 @@ shared_examples_for 'versioning' do
|
|
3
3
|
subject.format :txt
|
4
4
|
subject.version 'v1', macro_options
|
5
5
|
subject.get :hello do
|
6
|
-
"Version: #{request.env['api.version']
|
6
|
+
"Version: #{request.env['api.version']}"
|
7
7
|
end
|
8
8
|
versioned_get '/hello', 'v1', macro_options
|
9
9
|
expect(last_response.body).to eql 'Version: v1'
|
@@ -14,7 +14,7 @@ shared_examples_for 'versioning' do
|
|
14
14
|
subject.prefix 'api'
|
15
15
|
subject.version 'v1', macro_options
|
16
16
|
subject.get :hello do
|
17
|
-
"Version: #{request.env['api.version']
|
17
|
+
"Version: #{request.env['api.version']}"
|
18
18
|
end
|
19
19
|
versioned_get '/hello', 'v1', macro_options.merge(prefix: 'api')
|
20
20
|
expect(last_response.body).to eql 'Version: v1'
|
data/spec/spec_helper.rb
CHANGED
@@ -26,13 +26,13 @@ def versioned_headers(options)
|
|
26
26
|
when :header
|
27
27
|
{
|
28
28
|
'HTTP_ACCEPT' => [
|
29
|
-
"application/vnd.#{options[:vendor]
|
29
|
+
"application/vnd.#{options[:vendor]}-#{options[:version]}",
|
30
30
|
options[:format]
|
31
31
|
].compact.join('+')
|
32
32
|
}
|
33
33
|
when :accept_version_header
|
34
34
|
{
|
35
|
-
'HTTP_ACCEPT_VERSION' => "#{options[:version]
|
35
|
+
'HTTP_ACCEPT_VERSION' => "#{options[:version]}"
|
36
36
|
}
|
37
37
|
else
|
38
38
|
fail ArgumentError.new("unknown versioning strategy: #{options[:using]}")
|
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.14.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: 2015-
|
11
|
+
date: 2015-12-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -264,6 +264,20 @@ dependencies:
|
|
264
264
|
version: '0'
|
265
265
|
- !ruby/object:Gem::Dependency
|
266
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
|
267
281
|
requirement: !ruby/object:Gem::Requirement
|
268
282
|
requirements:
|
269
283
|
- - '>='
|
@@ -277,7 +291,7 @@ dependencies:
|
|
277
291
|
- !ruby/object:Gem::Version
|
278
292
|
version: '0'
|
279
293
|
- !ruby/object:Gem::Dependency
|
280
|
-
name:
|
294
|
+
name: benchmark-ips
|
281
295
|
requirement: !ruby/object:Gem::Requirement
|
282
296
|
requirements:
|
283
297
|
- - '>='
|
@@ -290,6 +304,20 @@ dependencies:
|
|
290
304
|
- - '>='
|
291
305
|
- !ruby/object:Gem::Version
|
292
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
|
293
321
|
description: A Ruby framework for rapid API development with great conventions.
|
294
322
|
email:
|
295
323
|
- michael@intridea.com
|
@@ -297,28 +325,23 @@ executables: []
|
|
297
325
|
extensions: []
|
298
326
|
extra_rdoc_files: []
|
299
327
|
files:
|
300
|
-
- .gitignore
|
301
|
-
- .rspec
|
302
|
-
- .rubocop.yml
|
303
|
-
- .rubocop_todo.yml
|
304
|
-
- .travis.yml
|
305
|
-
- .yardopts
|
306
328
|
- Appraisals
|
307
329
|
- CHANGELOG.md
|
308
330
|
- CONTRIBUTING.md
|
309
331
|
- Gemfile
|
332
|
+
- Gemfile.lock
|
310
333
|
- Guardfile
|
311
334
|
- LICENSE
|
312
335
|
- README.md
|
313
336
|
- RELEASING.md
|
314
337
|
- Rakefile
|
315
338
|
- UPGRADING.md
|
339
|
+
- benchmark/simple.rb
|
340
|
+
- gemfiles/rack_1.5.2.gemfile
|
316
341
|
- gemfiles/rails_3.gemfile
|
317
342
|
- gemfiles/rails_4.gemfile
|
318
343
|
- grape.gemspec
|
319
344
|
- grape.png
|
320
|
-
- lib/backports/active_support/deep_dup.rb
|
321
|
-
- lib/backports/active_support/duplicable.rb
|
322
345
|
- lib/grape.rb
|
323
346
|
- lib/grape/api.rb
|
324
347
|
- lib/grape/api/helpers.rb
|
@@ -344,6 +367,7 @@ files:
|
|
344
367
|
- lib/grape/exceptions/invalid_accept_header.rb
|
345
368
|
- lib/grape/exceptions/invalid_formatter.rb
|
346
369
|
- lib/grape/exceptions/invalid_message_body.rb
|
370
|
+
- lib/grape/exceptions/invalid_version_header.rb
|
347
371
|
- lib/grape/exceptions/invalid_versioner_option.rb
|
348
372
|
- lib/grape/exceptions/invalid_with_option_for_represent.rb
|
349
373
|
- lib/grape/exceptions/missing_group_type.rb
|
@@ -351,6 +375,7 @@ files:
|
|
351
375
|
- lib/grape/exceptions/missing_option.rb
|
352
376
|
- lib/grape/exceptions/missing_vendor_option.rb
|
353
377
|
- lib/grape/exceptions/unknown_options.rb
|
378
|
+
- lib/grape/exceptions/unknown_parameter.rb
|
354
379
|
- lib/grape/exceptions/unknown_validator.rb
|
355
380
|
- lib/grape/exceptions/unsupported_group_type.rb
|
356
381
|
- lib/grape/exceptions/validation.rb
|
@@ -361,7 +386,6 @@ files:
|
|
361
386
|
- lib/grape/formatter/txt.rb
|
362
387
|
- lib/grape/formatter/xml.rb
|
363
388
|
- lib/grape/http/headers.rb
|
364
|
-
- lib/grape/http/request.rb
|
365
389
|
- lib/grape/locale/en.yml
|
366
390
|
- lib/grape/middleware/auth/base.rb
|
367
391
|
- lib/grape/middleware/auth/dsl.rb
|
@@ -376,6 +400,7 @@ files:
|
|
376
400
|
- lib/grape/middleware/versioner/accept_version_header.rb
|
377
401
|
- lib/grape/middleware/versioner/header.rb
|
378
402
|
- lib/grape/middleware/versioner/param.rb
|
403
|
+
- lib/grape/middleware/versioner/parse_media_type_patch.rb
|
379
404
|
- lib/grape/middleware/versioner/path.rb
|
380
405
|
- lib/grape/namespace.rb
|
381
406
|
- lib/grape/parser/base.rb
|
@@ -383,8 +408,11 @@ files:
|
|
383
408
|
- lib/grape/parser/xml.rb
|
384
409
|
- lib/grape/path.rb
|
385
410
|
- lib/grape/presenters/presenter.rb
|
411
|
+
- lib/grape/request.rb
|
386
412
|
- lib/grape/route.rb
|
387
413
|
- lib/grape/util/content_types.rb
|
414
|
+
- lib/grape/util/env.rb
|
415
|
+
- lib/grape/util/file_response.rb
|
388
416
|
- lib/grape/util/inheritable_setting.rb
|
389
417
|
- lib/grape/util/inheritable_values.rb
|
390
418
|
- lib/grape/util/stackable_values.rb
|
@@ -392,6 +420,14 @@ files:
|
|
392
420
|
- lib/grape/validations.rb
|
393
421
|
- lib/grape/validations/attributes_iterator.rb
|
394
422
|
- lib/grape/validations/params_scope.rb
|
423
|
+
- lib/grape/validations/types.rb
|
424
|
+
- lib/grape/validations/types/build_coercer.rb
|
425
|
+
- lib/grape/validations/types/custom_type_coercer.rb
|
426
|
+
- lib/grape/validations/types/file.rb
|
427
|
+
- lib/grape/validations/types/json.rb
|
428
|
+
- lib/grape/validations/types/multiple_type_coercer.rb
|
429
|
+
- lib/grape/validations/types/variant_collection_coercer.rb
|
430
|
+
- lib/grape/validations/types/virtus_collection_patch.rb
|
395
431
|
- lib/grape/validations/validators/all_or_none.rb
|
396
432
|
- lib/grape/validations/validators/allow_blank.rb
|
397
433
|
- lib/grape/validations/validators/at_least_one_of.rb
|
@@ -405,6 +441,7 @@ files:
|
|
405
441
|
- lib/grape/validations/validators/regexp.rb
|
406
442
|
- lib/grape/validations/validators/values.rb
|
407
443
|
- lib/grape/version.rb
|
444
|
+
- pkg/grape-0.13.0.gem
|
408
445
|
- spec/grape/api/custom_validations_spec.rb
|
409
446
|
- spec/grape/api/deeply_included_options_spec.rb
|
410
447
|
- spec/grape/api/nested_helpers_spec.rb
|
@@ -448,12 +485,14 @@ files:
|
|
448
485
|
- spec/grape/middleware/versioner_spec.rb
|
449
486
|
- spec/grape/path_spec.rb
|
450
487
|
- spec/grape/presenters/presenter_spec.rb
|
488
|
+
- spec/grape/request_spec.rb
|
451
489
|
- spec/grape/util/inheritable_setting_spec.rb
|
452
490
|
- spec/grape/util/inheritable_values_spec.rb
|
453
491
|
- spec/grape/util/stackable_values_spec.rb
|
454
492
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
455
493
|
- spec/grape/validations/attributes_iterator_spec.rb
|
456
494
|
- spec/grape/validations/params_scope_spec.rb
|
495
|
+
- spec/grape/validations/types_spec.rb
|
457
496
|
- spec/grape/validations/validators/all_or_none_spec.rb
|
458
497
|
- spec/grape/validations/validators/allow_blank_spec.rb
|
459
498
|
- spec/grape/validations/validators/at_least_one_of_spec.rb
|
@@ -473,7 +512,7 @@ files:
|
|
473
512
|
- spec/support/endpoint_faker.rb
|
474
513
|
- spec/support/file_streamer.rb
|
475
514
|
- spec/support/versioned_helpers.rb
|
476
|
-
homepage: https://github.com/
|
515
|
+
homepage: https://github.com/ruby-grape/grape
|
477
516
|
licenses:
|
478
517
|
- MIT
|
479
518
|
metadata: {}
|
@@ -492,7 +531,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
492
531
|
- !ruby/object:Gem::Version
|
493
532
|
version: '0'
|
494
533
|
requirements: []
|
495
|
-
rubyforge_project:
|
534
|
+
rubyforge_project:
|
496
535
|
rubygems_version: 2.4.5
|
497
536
|
signing_key:
|
498
537
|
specification_version: 4
|
@@ -541,12 +580,14 @@ test_files:
|
|
541
580
|
- spec/grape/middleware/versioner_spec.rb
|
542
581
|
- spec/grape/path_spec.rb
|
543
582
|
- spec/grape/presenters/presenter_spec.rb
|
583
|
+
- spec/grape/request_spec.rb
|
544
584
|
- spec/grape/util/inheritable_setting_spec.rb
|
545
585
|
- spec/grape/util/inheritable_values_spec.rb
|
546
586
|
- spec/grape/util/stackable_values_spec.rb
|
547
587
|
- spec/grape/util/strict_hash_configuration_spec.rb
|
548
588
|
- spec/grape/validations/attributes_iterator_spec.rb
|
549
589
|
- spec/grape/validations/params_scope_spec.rb
|
590
|
+
- spec/grape/validations/types_spec.rb
|
550
591
|
- spec/grape/validations/validators/all_or_none_spec.rb
|
551
592
|
- spec/grape/validations/validators/allow_blank_spec.rb
|
552
593
|
- spec/grape/validations/validators/at_least_one_of_spec.rb
|
data/.gitignore
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
## MAC OS
|
2
|
-
.DS_Store
|
3
|
-
.com.apple.timemachine.supported
|
4
|
-
|
5
|
-
## TEXTMATE
|
6
|
-
*.tmproj
|
7
|
-
tmtags
|
8
|
-
|
9
|
-
## EMACS
|
10
|
-
*~
|
11
|
-
\#*
|
12
|
-
.\#*
|
13
|
-
|
14
|
-
## REDCAR
|
15
|
-
.redcar
|
16
|
-
|
17
|
-
## VIM
|
18
|
-
*.swp
|
19
|
-
*.swo
|
20
|
-
|
21
|
-
## RUBYMINE
|
22
|
-
.idea
|
23
|
-
|
24
|
-
## PROJECT::GENERAL
|
25
|
-
coverage
|
26
|
-
doc
|
27
|
-
pkg
|
28
|
-
.rvmrc
|
29
|
-
.bundle
|
30
|
-
.yardoc/*
|
31
|
-
dist
|
32
|
-
Gemfile.lock
|
33
|
-
gemfiles/*.lock
|
34
|
-
tmp
|
35
|
-
|
36
|
-
## Rubinius
|
37
|
-
.rbx
|
38
|
-
|
39
|
-
## Bundler binstubs
|
40
|
-
bin
|
41
|
-
|
42
|
-
## ripper-tags and gem-ctags
|
43
|
-
tags
|
44
|
-
|
45
|
-
## PROJECT::SPECIFIC
|
46
|
-
.project
|
data/.rspec
DELETED
data/.rubocop.yml
DELETED
data/.rubocop_todo.yml
DELETED
@@ -1,84 +0,0 @@
|
|
1
|
-
# This configuration was generated by `rubocop --auto-gen-config`
|
2
|
-
# on 2015-06-04 09:15:17 -0400 using RuboCop version 0.31.0.
|
3
|
-
# The point is for the user to remove these configuration records
|
4
|
-
# one by one as the offenses are removed from the code base.
|
5
|
-
# Note that changes in the inspected code, or installation of new
|
6
|
-
# versions of RuboCop, may require this file to be generated again.
|
7
|
-
|
8
|
-
# Offense count: 37
|
9
|
-
Metrics/AbcSize:
|
10
|
-
Max: 48
|
11
|
-
|
12
|
-
# Offense count: 2
|
13
|
-
Metrics/BlockNesting:
|
14
|
-
Max: 4
|
15
|
-
|
16
|
-
# Offense count: 4
|
17
|
-
# Configuration parameters: CountComments.
|
18
|
-
Metrics/ClassLength:
|
19
|
-
Max: 246
|
20
|
-
|
21
|
-
# Offense count: 23
|
22
|
-
Metrics/CyclomaticComplexity:
|
23
|
-
Max: 20
|
24
|
-
|
25
|
-
# Offense count: 675
|
26
|
-
# Configuration parameters: AllowURI, URISchemes.
|
27
|
-
Metrics/LineLength:
|
28
|
-
Max: 198
|
29
|
-
|
30
|
-
# Offense count: 44
|
31
|
-
# Configuration parameters: CountComments.
|
32
|
-
Metrics/MethodLength:
|
33
|
-
Max: 35
|
34
|
-
|
35
|
-
# Offense count: 8
|
36
|
-
# Configuration parameters: CountComments.
|
37
|
-
Metrics/ModuleLength:
|
38
|
-
Max: 243
|
39
|
-
|
40
|
-
# Offense count: 17
|
41
|
-
Metrics/PerceivedComplexity:
|
42
|
-
Max: 22
|
43
|
-
|
44
|
-
# Offense count: 26
|
45
|
-
# Cop supports --auto-correct.
|
46
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods.
|
47
|
-
Style/BlockDelimiters:
|
48
|
-
Enabled: false
|
49
|
-
|
50
|
-
# Offense count: 174
|
51
|
-
Style/Documentation:
|
52
|
-
Enabled: false
|
53
|
-
|
54
|
-
# Offense count: 7
|
55
|
-
Style/DoubleNegation:
|
56
|
-
Enabled: false
|
57
|
-
|
58
|
-
# Offense count: 5
|
59
|
-
Style/EachWithObject:
|
60
|
-
Enabled: false
|
61
|
-
|
62
|
-
# Offense count: 15
|
63
|
-
# Configuration parameters: MinBodyLength.
|
64
|
-
Style/GuardClause:
|
65
|
-
Enabled: false
|
66
|
-
|
67
|
-
# Offense count: 4
|
68
|
-
# Cop supports --auto-correct.
|
69
|
-
Style/Lambda:
|
70
|
-
Enabled: false
|
71
|
-
|
72
|
-
# Offense count: 3
|
73
|
-
Style/MultilineTernaryOperator:
|
74
|
-
Enabled: false
|
75
|
-
|
76
|
-
# Offense count: 3
|
77
|
-
# Configuration parameters: NamePrefix, NamePrefixBlacklist.
|
78
|
-
Style/PredicateName:
|
79
|
-
Enabled: false
|
80
|
-
|
81
|
-
# Offense count: 13
|
82
|
-
# Configuration parameters: EnforcedStyle, SupportedStyles.
|
83
|
-
Style/RaiseArgs:
|
84
|
-
Enabled: false
|
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
|
3
|
-
rvm:
|
4
|
-
- 2.2
|
5
|
-
- 2.1
|
6
|
-
- 2.0.0
|
7
|
-
- rbx-2.2.10
|
8
|
-
- jruby-19mode
|
9
|
-
- ruby-head
|
10
|
-
- jruby-head
|
11
|
-
|
12
|
-
matrix:
|
13
|
-
allow_failures:
|
14
|
-
- rvm: ruby-head
|
15
|
-
- rvm: jruby-head
|
16
|
-
|
17
|
-
gemfile:
|
18
|
-
- Gemfile
|
19
|
-
- gemfiles/rails_3.gemfile
|
20
|
-
- gemfiles/rails_4.gemfile
|
data/.yardopts
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Backport from Rails 4.x
|
2
|
-
# https://github.com/rails/rails/blob/4-0-stable/activesupport/lib/active_support/core_ext/object/deep_dup.rb
|
3
|
-
|
4
|
-
require_relative 'duplicable'
|
5
|
-
|
6
|
-
class Object
|
7
|
-
# Returns a deep copy of object if it's duplicable. If it's
|
8
|
-
# not duplicable, returns +self+.
|
9
|
-
#
|
10
|
-
# object = Object.new
|
11
|
-
# dup = object.deep_dup
|
12
|
-
# dup.instance_variable_set(:@a, 1)
|
13
|
-
#
|
14
|
-
# object.instance_variable_defined?(:@a) #=> false
|
15
|
-
# dup.instance_variable_defined?(:@a) #=> true
|
16
|
-
def deep_dup
|
17
|
-
duplicable? ? dup : self
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
class Array
|
22
|
-
# Returns a deep copy of array.
|
23
|
-
#
|
24
|
-
# array = [1, [2, 3]]
|
25
|
-
# dup = array.deep_dup
|
26
|
-
# dup[1][2] = 4
|
27
|
-
#
|
28
|
-
# array[1][2] #=> nil
|
29
|
-
# dup[1][2] #=> 4
|
30
|
-
def deep_dup
|
31
|
-
map(&:deep_dup)
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
class Hash
|
36
|
-
# Returns a deep copy of hash.
|
37
|
-
#
|
38
|
-
# hash = { a: { b: 'b' } }
|
39
|
-
# dup = hash.deep_dup
|
40
|
-
# dup[:a][:c] = 'c'
|
41
|
-
#
|
42
|
-
# hash[:a][:c] #=> nil
|
43
|
-
# dup[:a][:c] #=> "c"
|
44
|
-
def deep_dup
|
45
|
-
each_with_object(dup) do |(key, value), hash|
|
46
|
-
hash[key.deep_dup] = value.deep_dup
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|