grape 2.1.1 → 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/grape/api/instance.rb +1 -1
- data/lib/grape/api.rb +2 -2
- data/lib/grape/dsl/parameters.rb +1 -1
- data/lib/grape/endpoint.rb +2 -2
- data/lib/grape/exceptions/validation_errors.rb +1 -1
- data/lib/grape/middleware/base.rb +1 -1
- data/lib/grape/middleware/error.rb +2 -2
- data/lib/grape/middleware/stack.rb +2 -2
- data/lib/grape/validations/attributes_iterator.rb +1 -0
- data/lib/grape/validations/params_scope.rb +5 -9
- data/lib/grape/validations/validators/exactly_one_of_validator.rb +1 -1
- data/lib/grape/version.rb +1 -1
- metadata +5 -6
- data/lib/grape/util/accept/header.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 024e352cc91ca60c4f0750b852ce4fba0dc574b33d647ef10958b4db12fc7090
|
4
|
+
data.tar.gz: d9fb3be3da671011a1bed81d5f986a1688d411903bcf550c9d6ea83c7dcb6e0f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6172f2a8d7567edcbebb7289d5e41bed65f66ffa9309dd37b03b57cf199bc84945cdfd241df84e6a92ecf28f9099b18b9fe08516470b38721cb256fce5de8a34
|
7
|
+
data.tar.gz: d5ce8b9292bc9e596a955ac0c748cb2c278daf68246192556a1ee91e726026bdced1586ea4b73818727ff3fd2b0f32df57f3674d7a5f585703cd91c7630f5b71
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
### 2.1.2 (2024-06-28)
|
2
|
+
|
3
|
+
#### Fixes
|
4
|
+
|
5
|
+
* [#2459](https://github.com/ruby-grape/grape/pull/2459): Autocorrect cops - [@ericproulx](https://github.com/ericproulx).
|
6
|
+
* [#3458](https://github.com/ruby-grape/grape/pull/2458): Remove unused Grape::Util::Accept::Header - [@ericproulx](https://github.com/ericproulx).
|
7
|
+
* [#2463](https://github.com/ruby-grape/grape/pull/2463): Fix error message indices - [@ericproulx](https://github.com/ericproulx).
|
8
|
+
|
1
9
|
### 2.1.1 (2024-06-22)
|
2
10
|
|
3
11
|
#### Features
|
data/README.md
CHANGED
@@ -157,7 +157,7 @@ Grape is a REST-like API framework for Ruby. It's designed to run on Rack or com
|
|
157
157
|
|
158
158
|
## Stable Release
|
159
159
|
|
160
|
-
You're reading the documentation for the stable release of Grape, **2.1.
|
160
|
+
You're reading the documentation for the stable release of Grape, **2.1.2**.
|
161
161
|
Please read [UPGRADING](UPGRADING.md) when upgrading from a previous version.
|
162
162
|
|
163
163
|
## Project Resources
|
data/lib/grape/api/instance.rb
CHANGED
@@ -46,7 +46,7 @@ module Grape
|
|
46
46
|
# Parses the API's definition and compiles it into an instance of
|
47
47
|
# Grape::API.
|
48
48
|
def compile
|
49
|
-
@instance ||= new
|
49
|
+
@instance ||= new # rubocop:disable Naming/MemoizedInstanceVariableName
|
50
50
|
end
|
51
51
|
|
52
52
|
# Wipe the compiled API so we can recompile after changes were made.
|
data/lib/grape/api.rb
CHANGED
@@ -32,7 +32,7 @@ module Grape
|
|
32
32
|
def inherited(api)
|
33
33
|
super
|
34
34
|
|
35
|
-
api.initial_setup(Grape::API
|
35
|
+
api.initial_setup(self == Grape::API ? Grape::API::Instance : @base_instance)
|
36
36
|
api.override_all_methods!
|
37
37
|
end
|
38
38
|
|
@@ -108,7 +108,7 @@ module Grape
|
|
108
108
|
end
|
109
109
|
|
110
110
|
def respond_to?(method, include_private = false)
|
111
|
-
super
|
111
|
+
super || base_instance.respond_to?(method, include_private)
|
112
112
|
end
|
113
113
|
|
114
114
|
def respond_to_missing?(method, include_private = false)
|
data/lib/grape/dsl/parameters.rb
CHANGED
data/lib/grape/endpoint.rb
CHANGED
@@ -231,8 +231,8 @@ module Grape
|
|
231
231
|
options[:app].endpoints if options[:app].respond_to?(:endpoints)
|
232
232
|
end
|
233
233
|
|
234
|
-
def equals?(
|
235
|
-
(options ==
|
234
|
+
def equals?(endpoint)
|
235
|
+
(options == endpoint.options) && (inheritable_setting.to_hash == endpoint.inheritable_setting.to_hash)
|
236
236
|
end
|
237
237
|
|
238
238
|
protected
|
@@ -74,7 +74,7 @@ module Grape
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def mime_types
|
77
|
-
@
|
77
|
+
@mime_types ||= content_types.each_pair.with_object({}) do |(k, v), types_without_params|
|
78
78
|
types_without_params[v.split(';').first] = k
|
79
79
|
end
|
80
80
|
end
|
@@ -74,8 +74,8 @@ module Grape
|
|
74
74
|
rack_response(status, headers, format_message(message, backtrace, original_exception))
|
75
75
|
end
|
76
76
|
|
77
|
-
def default_rescue_handler(
|
78
|
-
error_response(message:
|
77
|
+
def default_rescue_handler(exception)
|
78
|
+
error_response(message: exception.message, backtrace: exception.backtrace, original_exception: exception)
|
79
79
|
end
|
80
80
|
|
81
81
|
def rescue_handler_for_base_only_class(klass)
|
@@ -21,6 +21,7 @@ module Grape
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def do_each(params_to_process, parent_indicies = [], &block)
|
24
|
+
@scope.reset_index # gets updated depending on the size of params_to_process
|
24
25
|
params_to_process.each_with_index do |resource_params, index|
|
25
26
|
# when we get arrays of arrays it means that target element located inside array
|
26
27
|
# we need this because we want to know parent arrays indicies
|
@@ -93,9 +93,7 @@ module Grape
|
|
93
93
|
|
94
94
|
def meets_dependency?(params, request_params)
|
95
95
|
return true unless @dependent_on
|
96
|
-
|
97
96
|
return false if @parent.present? && !@parent.meets_dependency?(@parent.params(request_params), request_params)
|
98
|
-
|
99
97
|
return params.any? { |param| meets_dependency?(param, request_params) } if params.is_a?(Array)
|
100
98
|
|
101
99
|
meets_hash_dependency?(params)
|
@@ -103,7 +101,6 @@ module Grape
|
|
103
101
|
|
104
102
|
def attr_meets_dependency?(params)
|
105
103
|
return true unless @dependent_on
|
106
|
-
|
107
104
|
return false if @parent.present? && !@parent.attr_meets_dependency?(params)
|
108
105
|
|
109
106
|
meets_hash_dependency?(params)
|
@@ -169,6 +166,10 @@ module Grape
|
|
169
166
|
!@optional
|
170
167
|
end
|
171
168
|
|
169
|
+
def reset_index
|
170
|
+
@index = nil
|
171
|
+
end
|
172
|
+
|
172
173
|
protected
|
173
174
|
|
174
175
|
# Adds a parameter declaration to our list of validations.
|
@@ -297,12 +298,7 @@ module Grape
|
|
297
298
|
# `optional` invocation that opened this scope.
|
298
299
|
# @yield parameter scope
|
299
300
|
def new_group_scope(attrs, &block)
|
300
|
-
self.class.new(
|
301
|
-
api: @api,
|
302
|
-
parent: self,
|
303
|
-
group: attrs.first,
|
304
|
-
&block
|
305
|
-
)
|
301
|
+
self.class.new(api: @api, parent: self, group: attrs.first, &block)
|
306
302
|
end
|
307
303
|
|
308
304
|
# Pushes declared params to parent or settings
|
@@ -7,7 +7,7 @@ module Grape
|
|
7
7
|
def validate_params!(params)
|
8
8
|
keys = keys_in_common(params)
|
9
9
|
return if keys.length == 1
|
10
|
-
raise Grape::Exceptions::Validation.new(params: all_keys, message: message(:exactly_one)) if keys.
|
10
|
+
raise Grape::Exceptions::Validation.new(params: all_keys, message: message(:exactly_one)) if keys.empty?
|
11
11
|
|
12
12
|
raise Grape::Exceptions::Validation.new(params: keys, message: message(:mutual_exclusion))
|
13
13
|
end
|
data/lib/grape/version.rb
CHANGED
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: 2.1.
|
4
|
+
version: 2.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Bleigh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-06-
|
11
|
+
date: 2024-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -189,7 +189,6 @@ files:
|
|
189
189
|
- lib/grape/serve_stream/sendfile_response.rb
|
190
190
|
- lib/grape/serve_stream/stream_response.rb
|
191
191
|
- lib/grape/types/invalid_value.rb
|
192
|
-
- lib/grape/util/accept/header.rb
|
193
192
|
- lib/grape/util/accept_header_handler.rb
|
194
193
|
- lib/grape/util/base_inheritable.rb
|
195
194
|
- lib/grape/util/cache.rb
|
@@ -252,9 +251,9 @@ licenses:
|
|
252
251
|
- MIT
|
253
252
|
metadata:
|
254
253
|
bug_tracker_uri: https://github.com/ruby-grape/grape/issues
|
255
|
-
changelog_uri: https://github.com/ruby-grape/grape/blob/v2.1.
|
256
|
-
documentation_uri: https://www.rubydoc.info/gems/grape/2.1.
|
257
|
-
source_code_uri: https://github.com/ruby-grape/grape/tree/v2.1.
|
254
|
+
changelog_uri: https://github.com/ruby-grape/grape/blob/v2.1.2/CHANGELOG.md
|
255
|
+
documentation_uri: https://www.rubydoc.info/gems/grape/2.1.2
|
256
|
+
source_code_uri: https://github.com/ruby-grape/grape/tree/v2.1.2
|
258
257
|
post_install_message:
|
259
258
|
rdoc_options: []
|
260
259
|
require_paths:
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Grape
|
4
|
-
module Util
|
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
|
-
end
|
18
|
-
end
|
19
|
-
end
|