grape 1.8.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (210) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +65 -1
  3. data/README.md +377 -334
  4. data/UPGRADING.md +231 -6
  5. data/grape.gemspec +6 -10
  6. data/lib/grape/api/instance.rb +13 -10
  7. data/lib/grape/api.rb +17 -8
  8. data/lib/grape/content_types.rb +0 -2
  9. data/lib/grape/cookies.rb +2 -1
  10. data/lib/grape/dry_types.rb +0 -2
  11. data/lib/grape/dsl/desc.rb +23 -21
  12. data/lib/grape/dsl/headers.rb +1 -1
  13. data/lib/grape/dsl/inside_route.rb +47 -22
  14. data/lib/grape/dsl/parameters.rb +4 -3
  15. data/lib/grape/dsl/routing.rb +20 -4
  16. data/lib/grape/dsl/validations.rb +13 -0
  17. data/lib/grape/endpoint.rb +15 -10
  18. data/lib/grape/{util/env.rb → env.rb} +0 -5
  19. data/lib/grape/error_formatter/txt.rb +11 -10
  20. data/lib/grape/exceptions/base.rb +3 -3
  21. data/lib/grape/exceptions/missing_group_type.rb +1 -1
  22. data/lib/grape/exceptions/unsupported_group_type.rb +1 -1
  23. data/lib/grape/exceptions/validation.rb +0 -2
  24. data/lib/grape/exceptions/validation_array_errors.rb +1 -0
  25. data/lib/grape/exceptions/validation_errors.rb +1 -3
  26. data/lib/grape/extensions/hash.rb +5 -1
  27. data/lib/grape/http/headers.rb +18 -24
  28. data/lib/grape/{util/json.rb → json.rb} +1 -3
  29. data/lib/grape/locale/en.yml +3 -0
  30. data/lib/grape/middleware/auth/base.rb +0 -2
  31. data/lib/grape/middleware/auth/dsl.rb +0 -2
  32. data/lib/grape/middleware/auth/strategies.rb +1 -2
  33. data/lib/grape/middleware/base.rb +0 -2
  34. data/lib/grape/middleware/error.rb +55 -50
  35. data/lib/grape/middleware/formatter.rb +21 -18
  36. data/lib/grape/middleware/globals.rb +1 -3
  37. data/lib/grape/middleware/stack.rb +2 -3
  38. data/lib/grape/middleware/versioner/accept_version_header.rb +0 -2
  39. data/lib/grape/middleware/versioner/header.rb +17 -163
  40. data/lib/grape/middleware/versioner/param.rb +2 -4
  41. data/lib/grape/middleware/versioner/path.rb +1 -3
  42. data/lib/grape/namespace.rb +3 -4
  43. data/lib/grape/path.rb +24 -29
  44. data/lib/grape/railtie.rb +9 -0
  45. data/lib/grape/request.rb +3 -5
  46. data/lib/grape/router/base_route.rb +39 -0
  47. data/lib/grape/router/greedy_route.rb +20 -0
  48. data/lib/grape/router/pattern.rb +39 -30
  49. data/lib/grape/router/route.rb +22 -59
  50. data/lib/grape/router.rb +30 -36
  51. data/lib/grape/util/accept/header.rb +19 -0
  52. data/lib/grape/util/accept_header_handler.rb +105 -0
  53. data/lib/grape/util/base_inheritable.rb +4 -4
  54. data/lib/grape/util/cache.rb +0 -3
  55. data/lib/grape/util/endpoint_configuration.rb +1 -1
  56. data/lib/grape/util/header.rb +13 -0
  57. data/lib/grape/util/inheritable_values.rb +0 -2
  58. data/lib/grape/util/lazy/block.rb +29 -0
  59. data/lib/grape/util/lazy/object.rb +45 -0
  60. data/lib/grape/util/lazy/value.rb +38 -0
  61. data/lib/grape/util/lazy/value_array.rb +21 -0
  62. data/lib/grape/util/lazy/value_enumerable.rb +34 -0
  63. data/lib/grape/util/lazy/value_hash.rb +21 -0
  64. data/lib/grape/util/media_type.rb +70 -0
  65. data/lib/grape/util/reverse_stackable_values.rb +1 -6
  66. data/lib/grape/util/stackable_values.rb +1 -6
  67. data/lib/grape/util/strict_hash_configuration.rb +3 -3
  68. data/lib/grape/validations/attributes_doc.rb +38 -36
  69. data/lib/grape/validations/contract_scope.rb +71 -0
  70. data/lib/grape/validations/params_scope.rb +10 -9
  71. data/lib/grape/validations/types/array_coercer.rb +0 -2
  72. data/lib/grape/validations/types/build_coercer.rb +69 -71
  73. data/lib/grape/validations/types/dry_type_coercer.rb +1 -11
  74. data/lib/grape/validations/types/json.rb +0 -2
  75. data/lib/grape/validations/types/primitive_coercer.rb +0 -2
  76. data/lib/grape/validations/types/set_coercer.rb +0 -3
  77. data/lib/grape/validations/types.rb +0 -3
  78. data/lib/grape/validations/validators/base.rb +2 -1
  79. data/lib/grape/validations/validators/default_validator.rb +5 -1
  80. data/lib/grape/validations/validators/length_validator.rb +42 -0
  81. data/lib/grape/validations/validators/values_validator.rb +8 -3
  82. data/lib/grape/validations.rb +3 -7
  83. data/lib/grape/version.rb +1 -1
  84. data/lib/grape/{util/xml.rb → xml.rb} +1 -1
  85. data/lib/grape.rb +38 -269
  86. metadata +33 -274
  87. data/lib/grape/eager_load.rb +0 -20
  88. data/lib/grape/middleware/versioner/parse_media_type_patch.rb +0 -24
  89. data/lib/grape/router/attribute_translator.rb +0 -63
  90. data/lib/grape/util/lazy_block.rb +0 -27
  91. data/lib/grape/util/lazy_object.rb +0 -43
  92. data/lib/grape/util/lazy_value.rb +0 -91
  93. data/spec/grape/api/custom_validations_spec.rb +0 -213
  94. data/spec/grape/api/deeply_included_options_spec.rb +0 -56
  95. data/spec/grape/api/defines_boolean_in_params_spec.rb +0 -38
  96. data/spec/grape/api/documentation_spec.rb +0 -59
  97. data/spec/grape/api/inherited_helpers_spec.rb +0 -114
  98. data/spec/grape/api/instance_spec.rb +0 -103
  99. data/spec/grape/api/invalid_format_spec.rb +0 -45
  100. data/spec/grape/api/namespace_parameters_in_route_spec.rb +0 -38
  101. data/spec/grape/api/nested_helpers_spec.rb +0 -50
  102. data/spec/grape/api/optional_parameters_in_route_spec.rb +0 -43
  103. data/spec/grape/api/parameters_modification_spec.rb +0 -41
  104. data/spec/grape/api/patch_method_helpers_spec.rb +0 -79
  105. data/spec/grape/api/recognize_path_spec.rb +0 -21
  106. data/spec/grape/api/required_parameters_in_route_spec.rb +0 -37
  107. data/spec/grape/api/required_parameters_with_invalid_method_spec.rb +0 -26
  108. data/spec/grape/api/routes_with_requirements_spec.rb +0 -59
  109. data/spec/grape/api/shared_helpers_exactly_one_of_spec.rb +0 -41
  110. data/spec/grape/api/shared_helpers_spec.rb +0 -36
  111. data/spec/grape/api_remount_spec.rb +0 -509
  112. data/spec/grape/api_spec.rb +0 -4356
  113. data/spec/grape/dsl/callbacks_spec.rb +0 -45
  114. data/spec/grape/dsl/desc_spec.rb +0 -98
  115. data/spec/grape/dsl/headers_spec.rb +0 -62
  116. data/spec/grape/dsl/helpers_spec.rb +0 -100
  117. data/spec/grape/dsl/inside_route_spec.rb +0 -531
  118. data/spec/grape/dsl/logger_spec.rb +0 -24
  119. data/spec/grape/dsl/middleware_spec.rb +0 -60
  120. data/spec/grape/dsl/parameters_spec.rb +0 -180
  121. data/spec/grape/dsl/request_response_spec.rb +0 -225
  122. data/spec/grape/dsl/routing_spec.rb +0 -275
  123. data/spec/grape/dsl/settings_spec.rb +0 -261
  124. data/spec/grape/dsl/validations_spec.rb +0 -55
  125. data/spec/grape/endpoint/declared_spec.rb +0 -846
  126. data/spec/grape/endpoint_spec.rb +0 -1085
  127. data/spec/grape/entity_spec.rb +0 -336
  128. data/spec/grape/exceptions/base_spec.rb +0 -81
  129. data/spec/grape/exceptions/body_parse_errors_spec.rb +0 -185
  130. data/spec/grape/exceptions/invalid_accept_header_spec.rb +0 -358
  131. data/spec/grape/exceptions/invalid_formatter_spec.rb +0 -15
  132. data/spec/grape/exceptions/invalid_response_spec.rb +0 -11
  133. data/spec/grape/exceptions/invalid_versioner_option_spec.rb +0 -15
  134. data/spec/grape/exceptions/missing_group_type_spec.rb +0 -17
  135. data/spec/grape/exceptions/missing_mime_type_spec.rb +0 -17
  136. data/spec/grape/exceptions/missing_option_spec.rb +0 -15
  137. data/spec/grape/exceptions/unknown_options_spec.rb +0 -15
  138. data/spec/grape/exceptions/unknown_validator_spec.rb +0 -15
  139. data/spec/grape/exceptions/unsupported_group_type_spec.rb +0 -19
  140. data/spec/grape/exceptions/validation_errors_spec.rb +0 -92
  141. data/spec/grape/exceptions/validation_spec.rb +0 -19
  142. data/spec/grape/extensions/param_builders/hash_spec.rb +0 -83
  143. data/spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb +0 -105
  144. data/spec/grape/extensions/param_builders/hashie/mash_spec.rb +0 -79
  145. data/spec/grape/grape_spec.rb +0 -9
  146. data/spec/grape/integration/global_namespace_function_spec.rb +0 -29
  147. data/spec/grape/integration/rack_sendfile_spec.rb +0 -48
  148. data/spec/grape/integration/rack_spec.rb +0 -51
  149. data/spec/grape/loading_spec.rb +0 -44
  150. data/spec/grape/middleware/auth/base_spec.rb +0 -31
  151. data/spec/grape/middleware/auth/dsl_spec.rb +0 -60
  152. data/spec/grape/middleware/auth/strategies_spec.rb +0 -120
  153. data/spec/grape/middleware/base_spec.rb +0 -221
  154. data/spec/grape/middleware/error_spec.rb +0 -85
  155. data/spec/grape/middleware/exception_spec.rb +0 -294
  156. data/spec/grape/middleware/formatter_spec.rb +0 -461
  157. data/spec/grape/middleware/globals_spec.rb +0 -30
  158. data/spec/grape/middleware/stack_spec.rb +0 -155
  159. data/spec/grape/middleware/versioner/accept_version_header_spec.rb +0 -122
  160. data/spec/grape/middleware/versioner/header_spec.rb +0 -345
  161. data/spec/grape/middleware/versioner/param_spec.rb +0 -171
  162. data/spec/grape/middleware/versioner/path_spec.rb +0 -62
  163. data/spec/grape/middleware/versioner_spec.rb +0 -21
  164. data/spec/grape/named_api_spec.rb +0 -19
  165. data/spec/grape/parser_spec.rb +0 -86
  166. data/spec/grape/path_spec.rb +0 -252
  167. data/spec/grape/presenters/presenter_spec.rb +0 -71
  168. data/spec/grape/request_spec.rb +0 -126
  169. data/spec/grape/util/inheritable_setting_spec.rb +0 -242
  170. data/spec/grape/util/inheritable_values_spec.rb +0 -79
  171. data/spec/grape/util/reverse_stackable_values_spec.rb +0 -134
  172. data/spec/grape/util/stackable_values_spec.rb +0 -128
  173. data/spec/grape/util/strict_hash_configuration_spec.rb +0 -38
  174. data/spec/grape/validations/attributes_doc_spec.rb +0 -153
  175. data/spec/grape/validations/instance_behaivour_spec.rb +0 -43
  176. data/spec/grape/validations/multiple_attributes_iterator_spec.rb +0 -38
  177. data/spec/grape/validations/params_scope_spec.rb +0 -1420
  178. data/spec/grape/validations/single_attribute_iterator_spec.rb +0 -56
  179. data/spec/grape/validations/types/array_coercer_spec.rb +0 -33
  180. data/spec/grape/validations/types/primitive_coercer_spec.rb +0 -150
  181. data/spec/grape/validations/types/set_coercer_spec.rb +0 -32
  182. data/spec/grape/validations/types_spec.rb +0 -111
  183. data/spec/grape/validations/validators/all_or_none_spec.rb +0 -162
  184. data/spec/grape/validations/validators/allow_blank_spec.rb +0 -575
  185. data/spec/grape/validations/validators/at_least_one_of_spec.rb +0 -205
  186. data/spec/grape/validations/validators/base_spec.rb +0 -38
  187. data/spec/grape/validations/validators/coerce_spec.rb +0 -1261
  188. data/spec/grape/validations/validators/default_spec.rb +0 -463
  189. data/spec/grape/validations/validators/exactly_one_of_spec.rb +0 -233
  190. data/spec/grape/validations/validators/except_values_spec.rb +0 -192
  191. data/spec/grape/validations/validators/mutual_exclusion_spec.rb +0 -214
  192. data/spec/grape/validations/validators/presence_spec.rb +0 -315
  193. data/spec/grape/validations/validators/regexp_spec.rb +0 -161
  194. data/spec/grape/validations/validators/same_as_spec.rb +0 -57
  195. data/spec/grape/validations/validators/values_spec.rb +0 -733
  196. data/spec/grape/validations/validators/zh-CN.yml +0 -10
  197. data/spec/grape/validations_spec.rb +0 -2030
  198. data/spec/integration/eager_load/eager_load_spec.rb +0 -15
  199. data/spec/integration/multi_json/json_spec.rb +0 -7
  200. data/spec/integration/multi_xml/xml_spec.rb +0 -7
  201. data/spec/shared/deprecated_class_examples.rb +0 -16
  202. data/spec/shared/versioning_examples.rb +0 -215
  203. data/spec/spec_helper.rb +0 -52
  204. data/spec/support/basic_auth_encode_helpers.rb +0 -11
  205. data/spec/support/chunks.rb +0 -14
  206. data/spec/support/content_type_helpers.rb +0 -15
  207. data/spec/support/endpoint_faker.rb +0 -25
  208. data/spec/support/file_streamer.rb +0 -13
  209. data/spec/support/integer_helpers.rb +0 -13
  210. data/spec/support/versioned_helpers.rb +0 -55
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: 1.8.0
4
+ version: 2.1.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: 2023-08-30 00:00:00.000000000 Z
11
+ date: 2024-06-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -16,28 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '5'
19
+ version: '6'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '5'
27
- - !ruby/object:Gem::Dependency
28
- name: builder
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - ">="
39
- - !ruby/object:Gem::Version
40
- version: '0'
26
+ version: '6'
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: dry-types
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -58,30 +44,30 @@ dependencies:
58
44
  requirements:
59
45
  - - "~>"
60
46
  - !ruby/object:Gem::Version
61
- version: 1.0.0
47
+ version: 1.1.0
62
48
  type: :runtime
63
49
  prerelease: false
64
50
  version_requirements: !ruby/object:Gem::Requirement
65
51
  requirements:
66
52
  - - "~>"
67
53
  - !ruby/object:Gem::Version
68
- version: 1.0.0
54
+ version: 1.1.0
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: rack
71
57
  requirement: !ruby/object:Gem::Requirement
72
58
  requirements:
73
59
  - - ">="
74
60
  - !ruby/object:Gem::Version
75
- version: 1.3.0
61
+ version: '2'
76
62
  type: :runtime
77
63
  prerelease: false
78
64
  version_requirements: !ruby/object:Gem::Requirement
79
65
  requirements:
80
66
  - - ">="
81
67
  - !ruby/object:Gem::Version
82
- version: 1.3.0
68
+ version: '2'
83
69
  - !ruby/object:Gem::Dependency
84
- name: rack-accept
70
+ name: zeitwerk
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -129,8 +115,8 @@ files:
129
115
  - lib/grape/dsl/routing.rb
130
116
  - lib/grape/dsl/settings.rb
131
117
  - lib/grape/dsl/validations.rb
132
- - lib/grape/eager_load.rb
133
118
  - lib/grape/endpoint.rb
119
+ - lib/grape/env.rb
134
120
  - lib/grape/error_formatter.rb
135
121
  - lib/grape/error_formatter/base.rb
136
122
  - lib/grape/error_formatter/json.rb
@@ -168,6 +154,7 @@ files:
168
154
  - lib/grape/formatter/txt.rb
169
155
  - lib/grape/formatter/xml.rb
170
156
  - lib/grape/http/headers.rb
157
+ - lib/grape/json.rb
171
158
  - lib/grape/locale/en.yml
172
159
  - lib/grape/middleware/auth/base.rb
173
160
  - lib/grape/middleware/auth/dsl.rb
@@ -184,7 +171,6 @@ files:
184
171
  - lib/grape/middleware/versioner/accept_version_header.rb
185
172
  - lib/grape/middleware/versioner/header.rb
186
173
  - lib/grape/middleware/versioner/param.rb
187
- - lib/grape/middleware/versioner/parse_media_type_patch.rb
188
174
  - lib/grape/middleware/versioner/path.rb
189
175
  - lib/grape/namespace.rb
190
176
  - lib/grape/parser.rb
@@ -192,33 +178,40 @@ files:
192
178
  - lib/grape/parser/xml.rb
193
179
  - lib/grape/path.rb
194
180
  - lib/grape/presenters/presenter.rb
181
+ - lib/grape/railtie.rb
195
182
  - lib/grape/request.rb
196
183
  - lib/grape/router.rb
197
- - lib/grape/router/attribute_translator.rb
184
+ - lib/grape/router/base_route.rb
185
+ - lib/grape/router/greedy_route.rb
198
186
  - lib/grape/router/pattern.rb
199
187
  - lib/grape/router/route.rb
200
188
  - lib/grape/serve_stream/file_body.rb
201
189
  - lib/grape/serve_stream/sendfile_response.rb
202
190
  - lib/grape/serve_stream/stream_response.rb
203
191
  - lib/grape/types/invalid_value.rb
192
+ - lib/grape/util/accept/header.rb
193
+ - lib/grape/util/accept_header_handler.rb
204
194
  - lib/grape/util/base_inheritable.rb
205
195
  - lib/grape/util/cache.rb
206
196
  - lib/grape/util/endpoint_configuration.rb
207
- - lib/grape/util/env.rb
197
+ - lib/grape/util/header.rb
208
198
  - lib/grape/util/inheritable_setting.rb
209
199
  - lib/grape/util/inheritable_values.rb
210
- - lib/grape/util/json.rb
211
- - lib/grape/util/lazy_block.rb
212
- - lib/grape/util/lazy_object.rb
213
- - lib/grape/util/lazy_value.rb
200
+ - lib/grape/util/lazy/block.rb
201
+ - lib/grape/util/lazy/object.rb
202
+ - lib/grape/util/lazy/value.rb
203
+ - lib/grape/util/lazy/value_array.rb
204
+ - lib/grape/util/lazy/value_enumerable.rb
205
+ - lib/grape/util/lazy/value_hash.rb
206
+ - lib/grape/util/media_type.rb
214
207
  - lib/grape/util/registrable.rb
215
208
  - lib/grape/util/reverse_stackable_values.rb
216
209
  - lib/grape/util/stackable_values.rb
217
210
  - lib/grape/util/strict_hash_configuration.rb
218
- - lib/grape/util/xml.rb
219
211
  - lib/grape/validations.rb
220
212
  - lib/grape/validations/attributes_doc.rb
221
213
  - lib/grape/validations/attributes_iterator.rb
214
+ - lib/grape/validations/contract_scope.rb
222
215
  - lib/grape/validations/multiple_attributes_iterator.rb
223
216
  - lib/grape/validations/params_scope.rb
224
217
  - lib/grape/validations/single_attribute_iterator.rb
@@ -245,6 +238,7 @@ files:
245
238
  - lib/grape/validations/validators/default_validator.rb
246
239
  - lib/grape/validations/validators/exactly_one_of_validator.rb
247
240
  - lib/grape/validations/validators/except_values_validator.rb
241
+ - lib/grape/validations/validators/length_validator.rb
248
242
  - lib/grape/validations/validators/multiple_params_base.rb
249
243
  - lib/grape/validations/validators/mutual_exclusion_validator.rb
250
244
  - lib/grape/validations/validators/presence_validator.rb
@@ -252,132 +246,15 @@ files:
252
246
  - lib/grape/validations/validators/same_as_validator.rb
253
247
  - lib/grape/validations/validators/values_validator.rb
254
248
  - lib/grape/version.rb
255
- - spec/grape/api/custom_validations_spec.rb
256
- - spec/grape/api/deeply_included_options_spec.rb
257
- - spec/grape/api/defines_boolean_in_params_spec.rb
258
- - spec/grape/api/documentation_spec.rb
259
- - spec/grape/api/inherited_helpers_spec.rb
260
- - spec/grape/api/instance_spec.rb
261
- - spec/grape/api/invalid_format_spec.rb
262
- - spec/grape/api/namespace_parameters_in_route_spec.rb
263
- - spec/grape/api/nested_helpers_spec.rb
264
- - spec/grape/api/optional_parameters_in_route_spec.rb
265
- - spec/grape/api/parameters_modification_spec.rb
266
- - spec/grape/api/patch_method_helpers_spec.rb
267
- - spec/grape/api/recognize_path_spec.rb
268
- - spec/grape/api/required_parameters_in_route_spec.rb
269
- - spec/grape/api/required_parameters_with_invalid_method_spec.rb
270
- - spec/grape/api/routes_with_requirements_spec.rb
271
- - spec/grape/api/shared_helpers_exactly_one_of_spec.rb
272
- - spec/grape/api/shared_helpers_spec.rb
273
- - spec/grape/api_remount_spec.rb
274
- - spec/grape/api_spec.rb
275
- - spec/grape/dsl/callbacks_spec.rb
276
- - spec/grape/dsl/desc_spec.rb
277
- - spec/grape/dsl/headers_spec.rb
278
- - spec/grape/dsl/helpers_spec.rb
279
- - spec/grape/dsl/inside_route_spec.rb
280
- - spec/grape/dsl/logger_spec.rb
281
- - spec/grape/dsl/middleware_spec.rb
282
- - spec/grape/dsl/parameters_spec.rb
283
- - spec/grape/dsl/request_response_spec.rb
284
- - spec/grape/dsl/routing_spec.rb
285
- - spec/grape/dsl/settings_spec.rb
286
- - spec/grape/dsl/validations_spec.rb
287
- - spec/grape/endpoint/declared_spec.rb
288
- - spec/grape/endpoint_spec.rb
289
- - spec/grape/entity_spec.rb
290
- - spec/grape/exceptions/base_spec.rb
291
- - spec/grape/exceptions/body_parse_errors_spec.rb
292
- - spec/grape/exceptions/invalid_accept_header_spec.rb
293
- - spec/grape/exceptions/invalid_formatter_spec.rb
294
- - spec/grape/exceptions/invalid_response_spec.rb
295
- - spec/grape/exceptions/invalid_versioner_option_spec.rb
296
- - spec/grape/exceptions/missing_group_type_spec.rb
297
- - spec/grape/exceptions/missing_mime_type_spec.rb
298
- - spec/grape/exceptions/missing_option_spec.rb
299
- - spec/grape/exceptions/unknown_options_spec.rb
300
- - spec/grape/exceptions/unknown_validator_spec.rb
301
- - spec/grape/exceptions/unsupported_group_type_spec.rb
302
- - spec/grape/exceptions/validation_errors_spec.rb
303
- - spec/grape/exceptions/validation_spec.rb
304
- - spec/grape/extensions/param_builders/hash_spec.rb
305
- - spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb
306
- - spec/grape/extensions/param_builders/hashie/mash_spec.rb
307
- - spec/grape/grape_spec.rb
308
- - spec/grape/integration/global_namespace_function_spec.rb
309
- - spec/grape/integration/rack_sendfile_spec.rb
310
- - spec/grape/integration/rack_spec.rb
311
- - spec/grape/loading_spec.rb
312
- - spec/grape/middleware/auth/base_spec.rb
313
- - spec/grape/middleware/auth/dsl_spec.rb
314
- - spec/grape/middleware/auth/strategies_spec.rb
315
- - spec/grape/middleware/base_spec.rb
316
- - spec/grape/middleware/error_spec.rb
317
- - spec/grape/middleware/exception_spec.rb
318
- - spec/grape/middleware/formatter_spec.rb
319
- - spec/grape/middleware/globals_spec.rb
320
- - spec/grape/middleware/stack_spec.rb
321
- - spec/grape/middleware/versioner/accept_version_header_spec.rb
322
- - spec/grape/middleware/versioner/header_spec.rb
323
- - spec/grape/middleware/versioner/param_spec.rb
324
- - spec/grape/middleware/versioner/path_spec.rb
325
- - spec/grape/middleware/versioner_spec.rb
326
- - spec/grape/named_api_spec.rb
327
- - spec/grape/parser_spec.rb
328
- - spec/grape/path_spec.rb
329
- - spec/grape/presenters/presenter_spec.rb
330
- - spec/grape/request_spec.rb
331
- - spec/grape/util/inheritable_setting_spec.rb
332
- - spec/grape/util/inheritable_values_spec.rb
333
- - spec/grape/util/reverse_stackable_values_spec.rb
334
- - spec/grape/util/stackable_values_spec.rb
335
- - spec/grape/util/strict_hash_configuration_spec.rb
336
- - spec/grape/validations/attributes_doc_spec.rb
337
- - spec/grape/validations/instance_behaivour_spec.rb
338
- - spec/grape/validations/multiple_attributes_iterator_spec.rb
339
- - spec/grape/validations/params_scope_spec.rb
340
- - spec/grape/validations/single_attribute_iterator_spec.rb
341
- - spec/grape/validations/types/array_coercer_spec.rb
342
- - spec/grape/validations/types/primitive_coercer_spec.rb
343
- - spec/grape/validations/types/set_coercer_spec.rb
344
- - spec/grape/validations/types_spec.rb
345
- - spec/grape/validations/validators/all_or_none_spec.rb
346
- - spec/grape/validations/validators/allow_blank_spec.rb
347
- - spec/grape/validations/validators/at_least_one_of_spec.rb
348
- - spec/grape/validations/validators/base_spec.rb
349
- - spec/grape/validations/validators/coerce_spec.rb
350
- - spec/grape/validations/validators/default_spec.rb
351
- - spec/grape/validations/validators/exactly_one_of_spec.rb
352
- - spec/grape/validations/validators/except_values_spec.rb
353
- - spec/grape/validations/validators/mutual_exclusion_spec.rb
354
- - spec/grape/validations/validators/presence_spec.rb
355
- - spec/grape/validations/validators/regexp_spec.rb
356
- - spec/grape/validations/validators/same_as_spec.rb
357
- - spec/grape/validations/validators/values_spec.rb
358
- - spec/grape/validations/validators/zh-CN.yml
359
- - spec/grape/validations_spec.rb
360
- - spec/integration/eager_load/eager_load_spec.rb
361
- - spec/integration/multi_json/json_spec.rb
362
- - spec/integration/multi_xml/xml_spec.rb
363
- - spec/shared/deprecated_class_examples.rb
364
- - spec/shared/versioning_examples.rb
365
- - spec/spec_helper.rb
366
- - spec/support/basic_auth_encode_helpers.rb
367
- - spec/support/chunks.rb
368
- - spec/support/content_type_helpers.rb
369
- - spec/support/endpoint_faker.rb
370
- - spec/support/file_streamer.rb
371
- - spec/support/integer_helpers.rb
372
- - spec/support/versioned_helpers.rb
249
+ - lib/grape/xml.rb
373
250
  homepage: https://github.com/ruby-grape/grape
374
251
  licenses:
375
252
  - MIT
376
253
  metadata:
377
254
  bug_tracker_uri: https://github.com/ruby-grape/grape/issues
378
- changelog_uri: https://github.com/ruby-grape/grape/blob/v1.8.0/CHANGELOG.md
379
- documentation_uri: https://www.rubydoc.info/gems/grape/1.8.0
380
- source_code_uri: https://github.com/ruby-grape/grape/tree/v1.8.0
255
+ changelog_uri: https://github.com/ruby-grape/grape/blob/v2.1.0/CHANGELOG.md
256
+ documentation_uri: https://www.rubydoc.info/gems/grape/2.1.0
257
+ source_code_uri: https://github.com/ruby-grape/grape/tree/v2.1.0
381
258
  post_install_message:
382
259
  rdoc_options: []
383
260
  require_paths:
@@ -386,133 +263,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
386
263
  requirements:
387
264
  - - ">="
388
265
  - !ruby/object:Gem::Version
389
- version: 2.6.0
266
+ version: 2.7.0
390
267
  required_rubygems_version: !ruby/object:Gem::Requirement
391
268
  requirements:
392
269
  - - ">="
393
270
  - !ruby/object:Gem::Version
394
271
  version: '0'
395
272
  requirements: []
396
- rubygems_version: 3.1.6
273
+ rubygems_version: 3.5.7
397
274
  signing_key:
398
275
  specification_version: 4
399
276
  summary: A simple Ruby framework for building REST-like APIs.
400
- test_files:
401
- - spec/spec_helper.rb
402
- - spec/integration/eager_load/eager_load_spec.rb
403
- - spec/integration/multi_xml/xml_spec.rb
404
- - spec/integration/multi_json/json_spec.rb
405
- - spec/shared/versioning_examples.rb
406
- - spec/shared/deprecated_class_examples.rb
407
- - spec/support/basic_auth_encode_helpers.rb
408
- - spec/support/endpoint_faker.rb
409
- - spec/support/chunks.rb
410
- - spec/support/file_streamer.rb
411
- - spec/support/versioned_helpers.rb
412
- - spec/support/content_type_helpers.rb
413
- - spec/support/integer_helpers.rb
414
- - spec/grape/middleware/error_spec.rb
415
- - spec/grape/middleware/globals_spec.rb
416
- - spec/grape/middleware/formatter_spec.rb
417
- - spec/grape/middleware/auth/strategies_spec.rb
418
- - spec/grape/middleware/auth/dsl_spec.rb
419
- - spec/grape/middleware/auth/base_spec.rb
420
- - spec/grape/middleware/stack_spec.rb
421
- - spec/grape/middleware/exception_spec.rb
422
- - spec/grape/middleware/versioner_spec.rb
423
- - spec/grape/middleware/versioner/accept_version_header_spec.rb
424
- - spec/grape/middleware/versioner/header_spec.rb
425
- - spec/grape/middleware/versioner/path_spec.rb
426
- - spec/grape/middleware/versioner/param_spec.rb
427
- - spec/grape/middleware/base_spec.rb
428
- - spec/grape/loading_spec.rb
429
- - spec/grape/endpoint_spec.rb
430
- - spec/grape/api_spec.rb
431
- - spec/grape/util/reverse_stackable_values_spec.rb
432
- - spec/grape/util/stackable_values_spec.rb
433
- - spec/grape/util/inheritable_setting_spec.rb
434
- - spec/grape/util/strict_hash_configuration_spec.rb
435
- - spec/grape/util/inheritable_values_spec.rb
436
- - spec/grape/integration/rack_spec.rb
437
- - spec/grape/integration/rack_sendfile_spec.rb
438
- - spec/grape/integration/global_namespace_function_spec.rb
439
- - spec/grape/validations_spec.rb
440
- - spec/grape/entity_spec.rb
441
- - spec/grape/exceptions/missing_group_type_spec.rb
442
- - spec/grape/exceptions/unsupported_group_type_spec.rb
443
- - spec/grape/exceptions/validation_spec.rb
444
- - spec/grape/exceptions/invalid_accept_header_spec.rb
445
- - spec/grape/exceptions/missing_option_spec.rb
446
- - spec/grape/exceptions/invalid_response_spec.rb
447
- - spec/grape/exceptions/body_parse_errors_spec.rb
448
- - spec/grape/exceptions/invalid_formatter_spec.rb
449
- - spec/grape/exceptions/missing_mime_type_spec.rb
450
- - spec/grape/exceptions/unknown_options_spec.rb
451
- - spec/grape/exceptions/validation_errors_spec.rb
452
- - spec/grape/exceptions/unknown_validator_spec.rb
453
- - spec/grape/exceptions/invalid_versioner_option_spec.rb
454
- - spec/grape/exceptions/base_spec.rb
455
- - spec/grape/presenters/presenter_spec.rb
456
- - spec/grape/validations/single_attribute_iterator_spec.rb
457
- - spec/grape/validations/types/primitive_coercer_spec.rb
458
- - spec/grape/validations/types/set_coercer_spec.rb
459
- - spec/grape/validations/types/array_coercer_spec.rb
460
- - spec/grape/validations/attributes_doc_spec.rb
461
- - spec/grape/validations/params_scope_spec.rb
462
- - spec/grape/validations/instance_behaivour_spec.rb
463
- - spec/grape/validations/multiple_attributes_iterator_spec.rb
464
- - spec/grape/validations/types_spec.rb
465
- - spec/grape/validations/validators/regexp_spec.rb
466
- - spec/grape/validations/validators/mutual_exclusion_spec.rb
467
- - spec/grape/validations/validators/exactly_one_of_spec.rb
468
- - spec/grape/validations/validators/except_values_spec.rb
469
- - spec/grape/validations/validators/presence_spec.rb
470
- - spec/grape/validations/validators/all_or_none_spec.rb
471
- - spec/grape/validations/validators/allow_blank_spec.rb
472
- - spec/grape/validations/validators/same_as_spec.rb
473
- - spec/grape/validations/validators/default_spec.rb
474
- - spec/grape/validations/validators/values_spec.rb
475
- - spec/grape/validations/validators/at_least_one_of_spec.rb
476
- - spec/grape/validations/validators/coerce_spec.rb
477
- - spec/grape/validations/validators/zh-CN.yml
478
- - spec/grape/validations/validators/base_spec.rb
479
- - spec/grape/extensions/param_builders/hashie/mash_spec.rb
480
- - spec/grape/extensions/param_builders/hash_spec.rb
481
- - spec/grape/extensions/param_builders/hash_with_indifferent_access_spec.rb
482
- - spec/grape/parser_spec.rb
483
- - spec/grape/request_spec.rb
484
- - spec/grape/endpoint/declared_spec.rb
485
- - spec/grape/api/parameters_modification_spec.rb
486
- - spec/grape/api/patch_method_helpers_spec.rb
487
- - spec/grape/api/required_parameters_with_invalid_method_spec.rb
488
- - spec/grape/api/nested_helpers_spec.rb
489
- - spec/grape/api/defines_boolean_in_params_spec.rb
490
- - spec/grape/api/invalid_format_spec.rb
491
- - spec/grape/api/required_parameters_in_route_spec.rb
492
- - spec/grape/api/instance_spec.rb
493
- - spec/grape/api/namespace_parameters_in_route_spec.rb
494
- - spec/grape/api/recognize_path_spec.rb
495
- - spec/grape/api/shared_helpers_exactly_one_of_spec.rb
496
- - spec/grape/api/inherited_helpers_spec.rb
497
- - spec/grape/api/shared_helpers_spec.rb
498
- - spec/grape/api/deeply_included_options_spec.rb
499
- - spec/grape/api/routes_with_requirements_spec.rb
500
- - spec/grape/api/custom_validations_spec.rb
501
- - spec/grape/api/optional_parameters_in_route_spec.rb
502
- - spec/grape/api/documentation_spec.rb
503
- - spec/grape/grape_spec.rb
504
- - spec/grape/api_remount_spec.rb
505
- - spec/grape/named_api_spec.rb
506
- - spec/grape/dsl/request_response_spec.rb
507
- - spec/grape/dsl/desc_spec.rb
508
- - spec/grape/dsl/logger_spec.rb
509
- - spec/grape/dsl/validations_spec.rb
510
- - spec/grape/dsl/parameters_spec.rb
511
- - spec/grape/dsl/helpers_spec.rb
512
- - spec/grape/dsl/middleware_spec.rb
513
- - spec/grape/dsl/headers_spec.rb
514
- - spec/grape/dsl/callbacks_spec.rb
515
- - spec/grape/dsl/settings_spec.rb
516
- - spec/grape/dsl/routing_spec.rb
517
- - spec/grape/dsl/inside_route_spec.rb
518
- - spec/grape/path_spec.rb
277
+ test_files: []
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Grape.eager_load!
4
- Grape::Http.eager_load!
5
- Grape::Exceptions.eager_load!
6
- Grape::Extensions.eager_load!
7
- Grape::Extensions::ActiveSupport.eager_load!
8
- Grape::Extensions::Hashie.eager_load!
9
- Grape::Middleware.eager_load!
10
- Grape::Middleware::Auth.eager_load!
11
- Grape::Middleware::Versioner.eager_load!
12
- Grape::Util.eager_load!
13
- Grape::ErrorFormatter.eager_load!
14
- Grape::Formatter.eager_load!
15
- Grape::Parser.eager_load!
16
- Grape::DSL.eager_load!
17
- Grape::API.eager_load!
18
- Grape::Presenters.eager_load!
19
- Grape::ServeStream.eager_load!
20
- Rack::Head # AutoLoads the Rack::Head
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'English'
4
- module Rack
5
- module Accept
6
- module Header
7
- ALLOWED_CHARACTERS = %r{^([a-z*]+)/([a-z0-9*&\^\-_#{$ERROR_INFO}.+]+)(?:;([a-z0-9=;]+))?$}.freeze
8
- class << self
9
- # Corrected version of https://github.com/mjackson/rack-accept/blob/master/lib/rack/accept/header.rb#L40-L44
10
- def parse_media_type(media_type)
11
- # see http://tools.ietf.org/html/rfc6838#section-4.2 for allowed characters in media type names
12
- m = media_type&.match(ALLOWED_CHARACTERS)
13
- m ? [m[1], m[2], m[3] || ''] : []
14
- end
15
- end
16
- end
17
-
18
- class MediaType
19
- def parse_media_type(media_type)
20
- Header.parse_media_type(media_type)
21
- end
22
- end
23
- end
24
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- class Router
5
- # this could be an OpenStruct, but doesn't work in Ruby 2.3.0, see https://bugs.ruby-lang.org/issues/12251
6
- class AttributeTranslator
7
- attr_reader :attributes
8
-
9
- ROUTE_ATTRIBUTES = %i[
10
- prefix
11
- version
12
- settings
13
- format
14
- description
15
- http_codes
16
- headers
17
- entity
18
- details
19
- requirements
20
- request_method
21
- namespace
22
- ].freeze
23
-
24
- ROUTER_ATTRIBUTES = %i[pattern index].freeze
25
-
26
- def initialize(**attributes)
27
- @attributes = attributes
28
- end
29
-
30
- (ROUTER_ATTRIBUTES + ROUTE_ATTRIBUTES).each do |attr|
31
- define_method attr do
32
- attributes[attr]
33
- end
34
- end
35
-
36
- def to_h
37
- attributes
38
- end
39
-
40
- def method_missing(method_name, *args)
41
- if setter?(method_name[-1])
42
- attributes[method_name[0..]] = *args
43
- else
44
- attributes[method_name]
45
- end
46
- end
47
-
48
- def respond_to_missing?(method_name, _include_private = false)
49
- if setter?(method_name[-1])
50
- true
51
- else
52
- @attributes.key?(method_name)
53
- end
54
- end
55
-
56
- private
57
-
58
- def setter?(method_name)
59
- method_name[-1] == '='
60
- end
61
- end
62
- end
63
- end
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Grape
4
- module Util
5
- class LazyBlock
6
- def initialize(&new_block)
7
- @block = new_block
8
- end
9
-
10
- def evaluate_from(configuration)
11
- @block.call(configuration)
12
- end
13
-
14
- def evaluate
15
- @block.call({})
16
- end
17
-
18
- def lazy?
19
- true
20
- end
21
-
22
- def to_s
23
- evaluate.to_s
24
- end
25
- end
26
- end
27
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Based on https://github.com/HornsAndHooves/lazy_object
4
-
5
- module Grape
6
- module Util
7
- class LazyObject < BasicObject
8
- attr_reader :callable
9
-
10
- def initialize(&callable)
11
- @callable = callable
12
- end
13
-
14
- def __target_object__
15
- @__target_object__ ||= callable.call
16
- end
17
-
18
- def ==(other)
19
- __target_object__ == other
20
- end
21
-
22
- def !=(other)
23
- __target_object__ != other
24
- end
25
-
26
- def !
27
- !__target_object__
28
- end
29
-
30
- def method_missing(method_name, *args, &block)
31
- if __target_object__.respond_to?(method_name)
32
- __target_object__.send(method_name, *args, &block)
33
- else
34
- super
35
- end
36
- end
37
-
38
- def respond_to_missing?(method_name, include_priv = false)
39
- __target_object__.respond_to?(method_name, include_priv)
40
- end
41
- end
42
- end
43
- end