grape 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +26 -0
  3. data/CONTRIBUTING.md +2 -2
  4. data/README.md +2 -2
  5. data/UPGRADING.md +14 -0
  6. data/grape.gemspec +2 -2
  7. data/lib/grape/api/instance.rb +16 -47
  8. data/lib/grape/api.rb +6 -10
  9. data/lib/grape/content_types.rb +1 -4
  10. data/lib/grape/declared_params_handler.rb +118 -0
  11. data/lib/grape/dsl/declared.rb +35 -0
  12. data/lib/grape/dsl/helpers.rb +2 -2
  13. data/lib/grape/dsl/inside_route.rb +3 -141
  14. data/lib/grape/dsl/parameters.rb +8 -26
  15. data/lib/grape/dsl/routing.rb +41 -29
  16. data/lib/grape/dsl/settings.rb +1 -1
  17. data/lib/grape/dsl/validations.rb +22 -20
  18. data/lib/grape/endpoint.rb +84 -83
  19. data/lib/grape/exceptions/base.rb +1 -1
  20. data/lib/grape/middleware/auth/dsl.rb +4 -4
  21. data/lib/grape/middleware/base.rb +4 -0
  22. data/lib/grape/middleware/error.rb +1 -1
  23. data/lib/grape/middleware/formatter.rb +6 -4
  24. data/lib/grape/middleware/versioner/accept_version_header.rb +1 -1
  25. data/lib/grape/middleware/versioner/base.rb +20 -0
  26. data/lib/grape/middleware/versioner/header.rb +1 -17
  27. data/lib/grape/middleware/versioner/path.rb +1 -1
  28. data/lib/grape/namespace.rb +5 -9
  29. data/lib/grape/params_builder.rb +2 -19
  30. data/lib/grape/router/base_route.rb +14 -5
  31. data/lib/grape/router/greedy_route.rb +11 -5
  32. data/lib/grape/router/pattern.rb +6 -20
  33. data/lib/grape/router/route.rb +7 -11
  34. data/lib/grape/router.rb +35 -61
  35. data/lib/grape/util/api_description.rb +10 -8
  36. data/lib/grape/validations/attributes_iterator.rb +2 -2
  37. data/lib/grape/validations/params_scope.rb +12 -10
  38. data/lib/grape/validations/validators/allow_blank_validator.rb +1 -1
  39. data/lib/grape/validations/validators/base.rb +2 -2
  40. data/lib/grape/validations/validators/except_values_validator.rb +1 -1
  41. data/lib/grape/validations/validators/{mutual_exclusion_validator.rb → mutually_exclusive_validator.rb} +1 -1
  42. data/lib/grape/validations/validators/presence_validator.rb +1 -1
  43. data/lib/grape/validations/validators/regexp_validator.rb +12 -2
  44. data/lib/grape/validations/validators/values_validator.rb +1 -1
  45. data/lib/grape/version.rb +1 -1
  46. data/lib/grape.rb +5 -13
  47. metadata +11 -14
  48. data/lib/grape/exceptions/missing_option.rb +0 -11
  49. data/lib/grape/exceptions/unknown_options.rb +0 -11
  50. data/lib/grape/extensions/active_support/hash_with_indifferent_access.rb +0 -24
  51. data/lib/grape/extensions/hash.rb +0 -27
  52. data/lib/grape/extensions/hashie/mash.rb +0 -24
data/lib/grape.rb CHANGED
@@ -2,37 +2,29 @@
2
2
 
3
3
  require 'logger'
4
4
  require 'active_support'
5
- require 'active_support/concern'
6
5
  require 'active_support/version'
7
6
  require 'active_support/isolated_execution_state'
8
- require 'active_support/core_ext/array/conversions'
7
+ require 'active_support/core_ext/array/conversions' # to_xml
9
8
  require 'active_support/core_ext/array/wrap'
10
- require 'active_support/core_ext/enumerable'
11
- require 'active_support/core_ext/hash/conversions'
9
+ require 'active_support/core_ext/hash/conversions' # to_xml
12
10
  require 'active_support/core_ext/hash/deep_merge'
13
11
  require 'active_support/core_ext/hash/deep_transform_values'
14
- require 'active_support/core_ext/hash/except'
15
12
  require 'active_support/core_ext/hash/indifferent_access'
16
- require 'active_support/core_ext/hash/keys'
17
13
  require 'active_support/core_ext/hash/reverse_merge'
18
- require 'active_support/core_ext/hash/slice'
19
- require 'active_support/core_ext/module/delegation'
14
+ require 'active_support/core_ext/module/delegation' # delegate_missing_to
20
15
  require 'active_support/core_ext/object/blank'
21
16
  require 'active_support/core_ext/object/deep_dup'
22
- require 'active_support/core_ext/object/try'
23
17
  require 'active_support/core_ext/object/duplicable'
24
- require 'active_support/core_ext/string/output_safety'
25
- require 'active_support/core_ext/string/exclude'
26
18
  require 'active_support/deprecation'
27
19
  require 'active_support/inflector'
28
20
  require 'active_support/ordered_options'
29
21
  require 'active_support/notifications'
30
- require 'dry-configurable'
31
22
 
32
23
  require 'English'
33
24
  require 'bigdecimal'
34
25
  require 'date'
35
26
  require 'dry-types'
27
+ require 'dry-configurable'
36
28
  require 'forwardable'
37
29
  require 'json'
38
30
  require 'mustermann/grape'
@@ -79,5 +71,5 @@ end
79
71
 
80
72
  # https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html
81
73
  # adding Grape.deprecator to Rails App if any
82
- require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1')
74
+ require 'grape/railtie' if defined?(Rails::Railtie)
83
75
  loader.eager_load
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grape
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '7.0'
18
+ version: '7.1'
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - ">="
24
24
  - !ruby/object:Gem::Version
25
- version: '7.0'
25
+ version: '7.1'
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: dry-configurable
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -112,8 +112,10 @@ files:
112
112
  - lib/grape/api/instance.rb
113
113
  - lib/grape/content_types.rb
114
114
  - lib/grape/cookies.rb
115
+ - lib/grape/declared_params_handler.rb
115
116
  - lib/grape/dry_types.rb
116
117
  - lib/grape/dsl/callbacks.rb
118
+ - lib/grape/dsl/declared.rb
117
119
  - lib/grape/dsl/desc.rb
118
120
  - lib/grape/dsl/headers.rb
119
121
  - lib/grape/dsl/helpers.rb
@@ -148,12 +150,10 @@ files:
148
150
  - lib/grape/exceptions/method_not_allowed.rb
149
151
  - lib/grape/exceptions/missing_group_type.rb
150
152
  - lib/grape/exceptions/missing_mime_type.rb
151
- - lib/grape/exceptions/missing_option.rb
152
153
  - lib/grape/exceptions/missing_vendor_option.rb
153
154
  - lib/grape/exceptions/too_deep_parameters.rb
154
155
  - lib/grape/exceptions/too_many_multipart_files.rb
155
156
  - lib/grape/exceptions/unknown_auth_strategy.rb
156
- - lib/grape/exceptions/unknown_options.rb
157
157
  - lib/grape/exceptions/unknown_parameter.rb
158
158
  - lib/grape/exceptions/unknown_params_builder.rb
159
159
  - lib/grape/exceptions/unknown_validator.rb
@@ -161,9 +161,6 @@ files:
161
161
  - lib/grape/exceptions/validation.rb
162
162
  - lib/grape/exceptions/validation_array_errors.rb
163
163
  - lib/grape/exceptions/validation_errors.rb
164
- - lib/grape/extensions/active_support/hash_with_indifferent_access.rb
165
- - lib/grape/extensions/hash.rb
166
- - lib/grape/extensions/hashie/mash.rb
167
164
  - lib/grape/formatter.rb
168
165
  - lib/grape/formatter/base.rb
169
166
  - lib/grape/formatter/json.rb
@@ -258,7 +255,7 @@ files:
258
255
  - lib/grape/validations/validators/except_values_validator.rb
259
256
  - lib/grape/validations/validators/length_validator.rb
260
257
  - lib/grape/validations/validators/multiple_params_base.rb
261
- - lib/grape/validations/validators/mutual_exclusion_validator.rb
258
+ - lib/grape/validations/validators/mutually_exclusive_validator.rb
262
259
  - lib/grape/validations/validators/presence_validator.rb
263
260
  - lib/grape/validations/validators/regexp_validator.rb
264
261
  - lib/grape/validations/validators/same_as_validator.rb
@@ -270,9 +267,9 @@ licenses:
270
267
  - MIT
271
268
  metadata:
272
269
  bug_tracker_uri: https://github.com/ruby-grape/grape/issues
273
- changelog_uri: https://github.com/ruby-grape/grape/blob/v3.0.1/CHANGELOG.md
274
- documentation_uri: https://www.rubydoc.info/gems/grape/3.0.1
275
- source_code_uri: https://github.com/ruby-grape/grape/tree/v3.0.1
270
+ changelog_uri: https://github.com/ruby-grape/grape/blob/v3.1.0/CHANGELOG.md
271
+ documentation_uri: https://www.rubydoc.info/gems/grape/3.1.0
272
+ source_code_uri: https://github.com/ruby-grape/grape/tree/v3.1.0
276
273
  rubygems_mfa_required: 'true'
277
274
  rdoc_options: []
278
275
  require_paths:
@@ -281,14 +278,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
281
278
  requirements:
282
279
  - - ">="
283
280
  - !ruby/object:Gem::Version
284
- version: '3.0'
281
+ version: '3.1'
285
282
  required_rubygems_version: !ruby/object:Gem::Requirement
286
283
  requirements:
287
284
  - - ">="
288
285
  - !ruby/object:Gem::Version
289
286
  version: '0'
290
287
  requirements: []
291
- rubygems_version: 3.6.7
288
+ rubygems_version: 3.6.9
292
289
  specification_version: 4
293
290
  summary: A simple Ruby framework for building REST-like APIs.
294
291
  test_files: []
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Exceptions
5
- class MissingOption < Base
6
- def initialize(option)
7
- super(message: compose_message(:missing_option, option: option))
8
- end
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Exceptions
5
- class UnknownOptions < Base
6
- def initialize(options)
7
- super(message: compose_message(:unknown_options, options: options))
8
- end
9
- end
10
- end
11
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Extensions
5
- module ActiveSupport
6
- module HashWithIndifferentAccess
7
- module ParamBuilder
8
- extend ::ActiveSupport::Concern
9
-
10
- included do
11
- Grape.deprecator.warn 'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
12
- namespace_inheritable(:build_params_with, :hash_with_indifferent_access)
13
- end
14
-
15
- def build_params
16
- ::ActiveSupport::HashWithIndifferentAccess.new(rack_params).tap do |params|
17
- params.deep_merge!(grape_routing_args) if env.key?(Grape::Env::GRAPE_ROUTING_ARGS)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Extensions
5
- module Hash
6
- module ParamBuilder
7
- extend ::ActiveSupport::Concern
8
-
9
- included do
10
- Grape.deprecator.warn 'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
11
- namespace_inheritable(:build_params_with, :hash)
12
- end
13
-
14
- def build_params
15
- rack_params.deep_dup.tap do |params|
16
- params.deep_symbolize_keys!
17
-
18
- if env.key?(Grape::Env::GRAPE_ROUTING_ARGS)
19
- grape_routing_args.deep_symbolize_keys!
20
- params.deep_merge!(grape_routing_args)
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Extensions
5
- module Hashie
6
- module Mash
7
- module ParamBuilder
8
- extend ::ActiveSupport::Concern
9
-
10
- included do
11
- Grape.deprecator.warn 'This concern has been deprecated. Use `build_with` with one of the following short_name (:hash, :hash_with_indifferent_access, :hashie_mash) instead.'
12
- namespace_inheritable(:build_params_with, :hashie_mash)
13
- end
14
-
15
- def build_params
16
- ::Hashie::Mash.new(rack_params).tap do |params|
17
- params.deep_merge!(grape_routing_args) if env.key?(Grape::Env::GRAPE_ROUTING_ARGS)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
24
- end