grape 2.4.0 → 3.2.1

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 (119) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +109 -0
  3. data/CONTRIBUTING.md +2 -10
  4. data/README.md +137 -181
  5. data/UPGRADING.md +154 -0
  6. data/grape.gemspec +4 -4
  7. data/lib/grape/api/instance.rb +51 -104
  8. data/lib/grape/api.rb +29 -42
  9. data/lib/grape/content_types.rb +1 -4
  10. data/lib/grape/declared_params_handler.rb +118 -0
  11. data/lib/grape/dry_types.rb +48 -4
  12. data/lib/grape/dsl/callbacks.rb +8 -58
  13. data/lib/grape/dsl/declared.rb +35 -0
  14. data/lib/grape/dsl/desc.rb +8 -67
  15. data/lib/grape/dsl/helpers.rb +59 -64
  16. data/lib/grape/dsl/inside_route.rb +28 -189
  17. data/lib/grape/dsl/logger.rb +3 -6
  18. data/lib/grape/dsl/middleware.rb +22 -40
  19. data/lib/grape/dsl/parameters.rb +24 -51
  20. data/lib/grape/dsl/request_response.rb +136 -139
  21. data/lib/grape/dsl/routing.rb +240 -200
  22. data/lib/grape/dsl/settings.rb +23 -135
  23. data/lib/grape/dsl/validations.rb +38 -44
  24. data/lib/grape/endpoint.rb +169 -205
  25. data/lib/grape/error_formatter/base.rb +4 -2
  26. data/lib/grape/exceptions/base.rb +19 -45
  27. data/lib/grape/exceptions/incompatible_option_values.rb +1 -1
  28. data/lib/grape/exceptions/invalid_accept_header.rb +1 -1
  29. data/lib/grape/exceptions/invalid_formatter.rb +1 -1
  30. data/lib/grape/exceptions/invalid_message_body.rb +1 -1
  31. data/lib/grape/exceptions/invalid_version_header.rb +1 -1
  32. data/lib/grape/exceptions/invalid_versioner_option.rb +1 -1
  33. data/lib/grape/exceptions/method_not_allowed.rb +1 -1
  34. data/lib/grape/exceptions/missing_group_type.rb +0 -2
  35. data/lib/grape/exceptions/missing_mime_type.rb +1 -1
  36. data/lib/grape/exceptions/request_error.rb +11 -0
  37. data/lib/grape/exceptions/unknown_auth_strategy.rb +1 -1
  38. data/lib/grape/exceptions/unknown_parameter.rb +1 -1
  39. data/lib/grape/exceptions/unknown_params_builder.rb +1 -1
  40. data/lib/grape/exceptions/unknown_validator.rb +1 -1
  41. data/lib/grape/exceptions/unsupported_group_type.rb +0 -2
  42. data/lib/grape/exceptions/validation.rb +7 -4
  43. data/lib/grape/exceptions/validation_errors.rb +13 -7
  44. data/lib/grape/locale/en.yml +0 -5
  45. data/lib/grape/middleware/auth/base.rb +2 -0
  46. data/lib/grape/middleware/auth/dsl.rb +9 -10
  47. data/lib/grape/middleware/base.rb +6 -4
  48. data/lib/grape/middleware/error.rb +4 -14
  49. data/lib/grape/middleware/formatter.rb +11 -7
  50. data/lib/grape/middleware/stack.rb +3 -2
  51. data/lib/grape/middleware/versioner/accept_version_header.rb +3 -3
  52. data/lib/grape/middleware/versioner/base.rb +42 -40
  53. data/lib/grape/middleware/versioner/header.rb +2 -18
  54. data/lib/grape/middleware/versioner/param.rb +2 -2
  55. data/lib/grape/middleware/versioner/path.rb +2 -2
  56. data/lib/grape/namespace.rb +15 -8
  57. data/lib/grape/params_builder/base.rb +2 -0
  58. data/lib/grape/params_builder.rb +2 -19
  59. data/lib/grape/request.rb +2 -10
  60. data/lib/grape/router/base_route.rb +14 -5
  61. data/lib/grape/router/greedy_route.rb +11 -5
  62. data/lib/grape/router/pattern.rb +6 -20
  63. data/lib/grape/router/route.rb +7 -11
  64. data/lib/grape/router.rb +42 -65
  65. data/lib/grape/util/api_description.rb +58 -0
  66. data/lib/grape/util/base_inheritable.rb +5 -2
  67. data/lib/grape/util/cache.rb +1 -0
  68. data/lib/grape/util/deep_freeze.rb +35 -0
  69. data/lib/grape/util/inheritable_setting.rb +8 -1
  70. data/lib/grape/util/media_type.rb +2 -2
  71. data/lib/grape/util/registry.rb +1 -1
  72. data/lib/grape/util/translation.rb +42 -0
  73. data/lib/grape/validations/attributes_iterator.rb +35 -20
  74. data/lib/grape/validations/contract_scope.rb +2 -8
  75. data/lib/grape/validations/multiple_attributes_iterator.rb +1 -1
  76. data/lib/grape/validations/param_scope_tracker.rb +57 -0
  77. data/lib/grape/validations/params_documentation.rb +50 -0
  78. data/lib/grape/validations/params_scope.rb +147 -156
  79. data/lib/grape/validations/single_attribute_iterator.rb +2 -2
  80. data/lib/grape/validations/types/array_coercer.rb +2 -3
  81. data/lib/grape/validations/types/dry_type_coercer.rb +4 -11
  82. data/lib/grape/validations/types/primitive_coercer.rb +1 -28
  83. data/lib/grape/validations/types.rb +10 -25
  84. data/lib/grape/validations/validators/all_or_none_of_validator.rb +6 -3
  85. data/lib/grape/validations/validators/allow_blank_validator.rb +10 -5
  86. data/lib/grape/validations/validators/at_least_one_of_validator.rb +5 -2
  87. data/lib/grape/validations/validators/base.rb +95 -25
  88. data/lib/grape/validations/validators/coerce_validator.rb +15 -35
  89. data/lib/grape/validations/validators/contract_scope_validator.rb +9 -5
  90. data/lib/grape/validations/validators/default_validator.rb +12 -18
  91. data/lib/grape/validations/validators/exactly_one_of_validator.rb +10 -3
  92. data/lib/grape/validations/validators/except_values_validator.rb +13 -4
  93. data/lib/grape/validations/validators/length_validator.rb +21 -22
  94. data/lib/grape/validations/validators/multiple_params_base.rb +5 -5
  95. data/lib/grape/validations/validators/{mutual_exclusion_validator.rb → mutually_exclusive_validator.rb} +4 -2
  96. data/lib/grape/validations/validators/presence_validator.rb +4 -2
  97. data/lib/grape/validations/validators/regexp_validator.rb +11 -3
  98. data/lib/grape/validations/validators/same_as_validator.rb +6 -15
  99. data/lib/grape/validations/validators/values_validator.rb +29 -21
  100. data/lib/grape/version.rb +1 -1
  101. data/lib/grape.rb +29 -23
  102. metadata +31 -26
  103. data/lib/grape/api/helpers.rb +0 -9
  104. data/lib/grape/dsl/api.rb +0 -17
  105. data/lib/grape/dsl/configuration.rb +0 -15
  106. data/lib/grape/exceptions/conflicting_types.rb +0 -11
  107. data/lib/grape/exceptions/empty_message_body.rb +0 -11
  108. data/lib/grape/exceptions/invalid_parameters.rb +0 -11
  109. data/lib/grape/exceptions/missing_option.rb +0 -11
  110. data/lib/grape/exceptions/too_deep_parameters.rb +0 -11
  111. data/lib/grape/exceptions/too_many_multipart_files.rb +0 -11
  112. data/lib/grape/exceptions/unknown_options.rb +0 -11
  113. data/lib/grape/extensions/active_support/hash_with_indifferent_access.rb +0 -24
  114. data/lib/grape/extensions/hash.rb +0 -27
  115. data/lib/grape/extensions/hashie/mash.rb +0 -24
  116. data/lib/grape/types/invalid_value.rb +0 -8
  117. data/lib/grape/util/strict_hash_configuration.rb +0 -108
  118. data/lib/grape/validations/attributes_doc.rb +0 -60
  119. data/lib/grape/validations/validator_factory.rb +0 -15
@@ -4,24 +4,15 @@ module Grape
4
4
  module Validations
5
5
  module Validators
6
6
  class SameAsValidator < Base
7
- def validate_param!(attr_name, params)
8
- confirmation = options_key?(:value) ? @option[:value] : @option
9
- return if params[attr_name] == params[confirmation]
10
-
11
- raise Grape::Exceptions::Validation.new(
12
- params: [@scope.full_name(attr_name)],
13
- message: build_message
14
- )
7
+ def initialize(attrs, options, required, scope, opts)
8
+ super
9
+ @value = option_value
15
10
  end
16
11
 
17
- private
12
+ def validate_param!(attr_name, params)
13
+ return if params[attr_name] == params[@value]
18
14
 
19
- def build_message
20
- if options_key?(:message)
21
- @option[:message]
22
- else
23
- format I18n.t(:same_as, scope: 'grape.errors.messages'), parameter: @option
24
- end
15
+ validation_error!(attr_name, message { translate(:same_as, parameter: @value) })
25
16
  end
26
17
  end
27
18
  end
@@ -4,45 +4,53 @@ module Grape
4
4
  module Validations
5
5
  module Validators
6
6
  class ValuesValidator < Base
7
+ default_message_key :values
8
+
7
9
  def initialize(attrs, options, required, scope, opts)
8
- @values = options.is_a?(Hash) ? options[:value] : options
9
10
  super
11
+ values = option_value
12
+
13
+ # Zero-arity procs return a collection per-request (e.g. DB-backed lists).
14
+ # Non-zero-arity procs are per-element predicates, called directly at validation time.
15
+ # Non-Proc values are wrapped in a zero-arity lambda for a uniform call interface.
16
+ if values.is_a?(Proc)
17
+ @values_call = values
18
+ @values_is_predicate = !values.arity.zero?
19
+ else
20
+ @values_call = -> { values }
21
+ @values_is_predicate = false
22
+ end
10
23
  end
11
24
 
12
25
  def validate_param!(attr_name, params)
13
- return unless params.is_a?(Hash)
26
+ return unless hash_like?(params)
14
27
 
15
- val = params[attr_name]
28
+ val = scrub(params[attr_name])
16
29
 
17
30
  return if val.nil? && !required_for_root_scope?
18
-
19
- val = val.scrub if val.respond_to?(:scrub)
20
-
21
- # don't forget that +false.blank?+ is true
22
31
  return if val != false && val.blank? && @allow_blank
23
-
24
32
  return if check_values?(val, attr_name)
25
33
 
26
- raise Grape::Exceptions::Validation.new(
27
- params: [@scope.full_name(attr_name)],
28
- message: message(:values)
29
- )
34
+ validation_error!(attr_name)
30
35
  end
31
36
 
32
37
  private
33
38
 
34
39
  def check_values?(val, attr_name)
35
- values = @values.is_a?(Proc) && @values.arity.zero? ? @values.call : @values
36
- return true if values.nil?
37
-
38
40
  param_array = val.nil? ? [nil] : Array.wrap(val)
39
- return param_array.all? { |param| values.include?(param) } unless values.is_a?(Proc)
40
41
 
41
- begin
42
- param_array.all? { |param| values.call(param) }
43
- rescue StandardError => e
44
- warn "Error '#{e}' raised while validating attribute '#{attr_name}'"
45
- false
42
+ if @values_is_predicate
43
+ begin
44
+ param_array.all? { |param| @values_call.call(param) }
45
+ rescue StandardError => e
46
+ warn "Error '#{e}' raised while validating attribute '#{attr_name}'"
47
+ false
48
+ end
49
+ else
50
+ values = @values_call.call
51
+ return true if values.nil?
52
+
53
+ param_array.all? { |param| values.include?(param) }
46
54
  end
47
55
  end
48
56
 
data/lib/grape/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Grape
4
4
  # The current version of Grape.
5
- VERSION = '2.4.0'
5
+ VERSION = '3.2.1'
6
6
  end
data/lib/grape.rb CHANGED
@@ -2,28 +2,19 @@
2
2
 
3
3
  require 'logger'
4
4
  require 'active_support'
5
- require 'active_support/concern'
6
- require 'active_support/configurable'
7
5
  require 'active_support/version'
8
- require 'active_support/isolated_execution_state' if ActiveSupport::VERSION::MAJOR > 6
9
- require 'active_support/core_ext/array/conversions'
10
- require 'active_support/core_ext/array/extract_options'
6
+ require 'active_support/isolated_execution_state'
7
+ require 'active_support/core_ext/array/conversions' # to_xml
11
8
  require 'active_support/core_ext/array/wrap'
12
- require 'active_support/core_ext/enumerable'
13
- require 'active_support/core_ext/hash/conversions'
9
+ require 'active_support/core_ext/hash/conversions' # to_xml
14
10
  require 'active_support/core_ext/hash/deep_merge'
15
- require 'active_support/core_ext/hash/except'
11
+ require 'active_support/core_ext/hash/deep_transform_values'
16
12
  require 'active_support/core_ext/hash/indifferent_access'
17
- require 'active_support/core_ext/hash/keys'
18
13
  require 'active_support/core_ext/hash/reverse_merge'
19
- require 'active_support/core_ext/hash/slice'
20
- require 'active_support/core_ext/module/delegation'
14
+ require 'active_support/core_ext/module/delegation' # delegate_missing_to
21
15
  require 'active_support/core_ext/object/blank'
22
16
  require 'active_support/core_ext/object/deep_dup'
23
- require 'active_support/core_ext/object/try'
24
17
  require 'active_support/core_ext/object/duplicable'
25
- require 'active_support/core_ext/string/output_safety'
26
- require 'active_support/core_ext/string/exclude'
27
18
  require 'active_support/deprecation'
28
19
  require 'active_support/inflector'
29
20
  require 'active_support/ordered_options'
@@ -33,6 +24,7 @@ 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'
@@ -41,7 +33,6 @@ require 'rack'
41
33
  require 'rack/auth/basic'
42
34
  require 'rack/builder'
43
35
  require 'rack/head'
44
- require 'set'
45
36
  require 'singleton'
46
37
  require 'zeitwerk'
47
38
 
@@ -57,7 +48,10 @@ loader.setup
57
48
  I18n.load_path << File.expand_path('grape/locale/en.yml', __dir__)
58
49
 
59
50
  module Grape
60
- include ActiveSupport::Configurable
51
+ extend Dry::Configurable
52
+
53
+ setting :param_builder, default: :hash_with_indifferent_access
54
+ setting :lint, default: false
61
55
 
62
56
  HTTP_SUPPORTED_METHODS = [
63
57
  Rack::GET,
@@ -69,18 +63,30 @@ module Grape
69
63
  Rack::OPTIONS
70
64
  ].freeze
71
65
 
66
+ # Rack errors that should be rescued and wrapped as Grape::Exceptions::RequestError.
67
+ # Rack 3.1.0 introduced Rack::BadRequest as a marker module included by all bad request
68
+ # exception classes, allowing a single rescue entry to cover them all.
69
+ # Before, these errors are raised as individual exception classes.
70
+ RACK_ERRORS =
71
+ if Gem::Version.new(Rack.release) >= Gem::Version.new('3.1.0')
72
+ [EOFError, Rack::BadRequest]
73
+ else
74
+ [
75
+ EOFError,
76
+ Rack::Multipart::MultipartPartLimitError,
77
+ Rack::Multipart::MultipartTotalPartLimitError,
78
+ Rack::Utils::ParameterTypeError,
79
+ Rack::Utils::InvalidParameterError,
80
+ Rack::QueryParser::ParamsTooDeepError
81
+ ]
82
+ end.freeze
83
+
72
84
  def self.deprecator
73
85
  @deprecator ||= ActiveSupport::Deprecation.new('2.0', 'Grape')
74
86
  end
75
-
76
- configure do |config|
77
- config.param_builder = :hash_with_indifferent_access
78
- config.lint = false
79
- config.compile_methods!
80
- end
81
87
  end
82
88
 
83
89
  # https://api.rubyonrails.org/classes/ActiveSupport/Deprecation.html
84
90
  # adding Grape.deprecator to Rails App if any
85
- require 'grape/railtie' if defined?(Rails::Railtie) && ActiveSupport.gem_version >= Gem::Version.new('7.1')
91
+ require 'grape/railtie' if defined?(Rails::Railtie)
86
92
  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: 2.4.0
4
+ version: 3.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -15,14 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - ">="
17
17
  - !ruby/object:Gem::Version
18
- version: '6.1'
18
+ version: '7.2'
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: '6.1'
25
+ version: '7.2'
26
+ - !ruby/object:Gem::Dependency
27
+ name: dry-configurable
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
26
40
  - !ruby/object:Gem::Dependency
27
41
  name: dry-types
28
42
  requirement: !ruby/object:Gem::Requirement
@@ -95,14 +109,13 @@ files:
95
109
  - grape.png
96
110
  - lib/grape.rb
97
111
  - lib/grape/api.rb
98
- - lib/grape/api/helpers.rb
99
112
  - lib/grape/api/instance.rb
100
113
  - lib/grape/content_types.rb
101
114
  - lib/grape/cookies.rb
115
+ - lib/grape/declared_params_handler.rb
102
116
  - lib/grape/dry_types.rb
103
- - lib/grape/dsl/api.rb
104
117
  - lib/grape/dsl/callbacks.rb
105
- - lib/grape/dsl/configuration.rb
118
+ - lib/grape/dsl/declared.rb
106
119
  - lib/grape/dsl/desc.rb
107
120
  - lib/grape/dsl/headers.rb
108
121
  - lib/grape/dsl/helpers.rb
@@ -123,13 +136,10 @@ files:
123
136
  - lib/grape/error_formatter/txt.rb
124
137
  - lib/grape/error_formatter/xml.rb
125
138
  - lib/grape/exceptions/base.rb
126
- - lib/grape/exceptions/conflicting_types.rb
127
- - lib/grape/exceptions/empty_message_body.rb
128
139
  - lib/grape/exceptions/incompatible_option_values.rb
129
140
  - lib/grape/exceptions/invalid_accept_header.rb
130
141
  - lib/grape/exceptions/invalid_formatter.rb
131
142
  - lib/grape/exceptions/invalid_message_body.rb
132
- - lib/grape/exceptions/invalid_parameters.rb
133
143
  - lib/grape/exceptions/invalid_response.rb
134
144
  - lib/grape/exceptions/invalid_version_header.rb
135
145
  - lib/grape/exceptions/invalid_versioner_option.rb
@@ -137,12 +147,9 @@ files:
137
147
  - lib/grape/exceptions/method_not_allowed.rb
138
148
  - lib/grape/exceptions/missing_group_type.rb
139
149
  - lib/grape/exceptions/missing_mime_type.rb
140
- - lib/grape/exceptions/missing_option.rb
141
150
  - lib/grape/exceptions/missing_vendor_option.rb
142
- - lib/grape/exceptions/too_deep_parameters.rb
143
- - lib/grape/exceptions/too_many_multipart_files.rb
151
+ - lib/grape/exceptions/request_error.rb
144
152
  - lib/grape/exceptions/unknown_auth_strategy.rb
145
- - lib/grape/exceptions/unknown_options.rb
146
153
  - lib/grape/exceptions/unknown_parameter.rb
147
154
  - lib/grape/exceptions/unknown_params_builder.rb
148
155
  - lib/grape/exceptions/unknown_validator.rb
@@ -150,9 +157,6 @@ files:
150
157
  - lib/grape/exceptions/validation.rb
151
158
  - lib/grape/exceptions/validation_array_errors.rb
152
159
  - lib/grape/exceptions/validation_errors.rb
153
- - lib/grape/extensions/active_support/hash_with_indifferent_access.rb
154
- - lib/grape/extensions/hash.rb
155
- - lib/grape/extensions/hashie/mash.rb
156
160
  - lib/grape/formatter.rb
157
161
  - lib/grape/formatter/base.rb
158
162
  - lib/grape/formatter/json.rb
@@ -199,9 +203,10 @@ files:
199
203
  - lib/grape/serve_stream/file_body.rb
200
204
  - lib/grape/serve_stream/sendfile_response.rb
201
205
  - lib/grape/serve_stream/stream_response.rb
202
- - lib/grape/types/invalid_value.rb
206
+ - lib/grape/util/api_description.rb
203
207
  - lib/grape/util/base_inheritable.rb
204
208
  - lib/grape/util/cache.rb
209
+ - lib/grape/util/deep_freeze.rb
205
210
  - lib/grape/util/endpoint_configuration.rb
206
211
  - lib/grape/util/header.rb
207
212
  - lib/grape/util/inheritable_setting.rb
@@ -215,12 +220,13 @@ files:
215
220
  - lib/grape/util/registry.rb
216
221
  - lib/grape/util/reverse_stackable_values.rb
217
222
  - lib/grape/util/stackable_values.rb
218
- - lib/grape/util/strict_hash_configuration.rb
223
+ - lib/grape/util/translation.rb
219
224
  - lib/grape/validations.rb
220
- - lib/grape/validations/attributes_doc.rb
221
225
  - lib/grape/validations/attributes_iterator.rb
222
226
  - lib/grape/validations/contract_scope.rb
223
227
  - lib/grape/validations/multiple_attributes_iterator.rb
228
+ - lib/grape/validations/param_scope_tracker.rb
229
+ - lib/grape/validations/params_documentation.rb
224
230
  - lib/grape/validations/params_scope.rb
225
231
  - lib/grape/validations/single_attribute_iterator.rb
226
232
  - lib/grape/validations/types.rb
@@ -235,7 +241,6 @@ files:
235
241
  - lib/grape/validations/types/primitive_coercer.rb
236
242
  - lib/grape/validations/types/set_coercer.rb
237
243
  - lib/grape/validations/types/variant_collection_coercer.rb
238
- - lib/grape/validations/validator_factory.rb
239
244
  - lib/grape/validations/validators/all_or_none_of_validator.rb
240
245
  - lib/grape/validations/validators/allow_blank_validator.rb
241
246
  - lib/grape/validations/validators/as_validator.rb
@@ -248,7 +253,7 @@ files:
248
253
  - lib/grape/validations/validators/except_values_validator.rb
249
254
  - lib/grape/validations/validators/length_validator.rb
250
255
  - lib/grape/validations/validators/multiple_params_base.rb
251
- - lib/grape/validations/validators/mutual_exclusion_validator.rb
256
+ - lib/grape/validations/validators/mutually_exclusive_validator.rb
252
257
  - lib/grape/validations/validators/presence_validator.rb
253
258
  - lib/grape/validations/validators/regexp_validator.rb
254
259
  - lib/grape/validations/validators/same_as_validator.rb
@@ -260,9 +265,9 @@ licenses:
260
265
  - MIT
261
266
  metadata:
262
267
  bug_tracker_uri: https://github.com/ruby-grape/grape/issues
263
- changelog_uri: https://github.com/ruby-grape/grape/blob/v2.4.0/CHANGELOG.md
264
- documentation_uri: https://www.rubydoc.info/gems/grape/2.4.0
265
- source_code_uri: https://github.com/ruby-grape/grape/tree/v2.4.0
268
+ changelog_uri: https://github.com/ruby-grape/grape/blob/v3.2.1/CHANGELOG.md
269
+ documentation_uri: https://www.rubydoc.info/gems/grape/3.2.1
270
+ source_code_uri: https://github.com/ruby-grape/grape/tree/v3.2.1
266
271
  rubygems_mfa_required: 'true'
267
272
  rdoc_options: []
268
273
  require_paths:
@@ -271,14 +276,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
271
276
  requirements:
272
277
  - - ">="
273
278
  - !ruby/object:Gem::Version
274
- version: 2.7.0
279
+ version: '3.2'
275
280
  required_rubygems_version: !ruby/object:Gem::Requirement
276
281
  requirements:
277
282
  - - ">="
278
283
  - !ruby/object:Gem::Version
279
284
  version: '0'
280
285
  requirements: []
281
- rubygems_version: 3.6.9
286
+ rubygems_version: 4.0.3
282
287
  specification_version: 4
283
288
  summary: A simple Ruby framework for building REST-like APIs.
284
289
  test_files: []
@@ -1,9 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- class API
5
- module Helpers
6
- include Grape::DSL::Helpers::BaseHelper
7
- end
8
- end
9
- end
data/lib/grape/dsl/api.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module DSL
5
- module API
6
- extend ActiveSupport::Concern
7
-
8
- include Grape::DSL::Validations
9
- include Grape::DSL::Callbacks
10
- include Grape::DSL::Configuration
11
- include Grape::DSL::Helpers
12
- include Grape::DSL::Middleware
13
- include Grape::DSL::RequestResponse
14
- include Grape::DSL::Routing
15
- end
16
- end
17
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module DSL
5
- module Configuration
6
- extend ActiveSupport::Concern
7
-
8
- module ClassMethods
9
- include Grape::DSL::Settings
10
- include Grape::DSL::Logger
11
- include Grape::DSL::Desc
12
- end
13
- end
14
- end
15
- end
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Exceptions
5
- class ConflictingTypes < Base
6
- def initialize
7
- super(message: compose_message(:conflicting_types), status: 400)
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 EmptyMessageBody < Base
6
- def initialize(body_format)
7
- super(message: compose_message(:empty_message_body, body_format: body_format), status: 400)
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 InvalidParameters < Base
6
- def initialize
7
- super(message: compose_message(:invalid_parameters), status: 400)
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 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 TooDeepParameters < Base
6
- def initialize(limit)
7
- super(message: compose_message(:too_deep_parameters, limit: limit), status: 400)
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 TooManyMultipartFiles < Base
6
- def initialize(limit)
7
- super(message: compose_message(:too_many_multipart_files, limit: limit), status: 413)
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
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # only exists to make it shorter for external use
4
- module Grape
5
- module Types
6
- InvalidValue = Class.new(Grape::Validations::Types::InvalidValue)
7
- end
8
- end