grape 3.3.4 → 3.3.5

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d4db45369305583b4816671ba1e0934dc034bda07ad61bc68b1b9d09d67d776
4
- data.tar.gz: fcb5fc7921a0f619f3d644a8c7caee4e306f71215c05f01770df4a94d301db34
3
+ metadata.gz: 88b3fe1928173a2d9b71c919863413baee3e1723865bce98ba8c1f10d970c85a
4
+ data.tar.gz: 5fb846fdaea070aa997ebcbda8746ebd1b1507a62589b1afe0027d3369e4b986
5
5
  SHA512:
6
- metadata.gz: ea6e0e3bab2b7f79e395e2aa649d5a15bfc0fef1d22be86465a650d1c92c73ed3cb6133fbb67d184aad3cf9ba0f7e920ec507e5d94bc3fb55b7ca9d0c54ea89a
7
- data.tar.gz: ab97e8a2ed312cfce30641914ed08986aeee8bad45742deabea86b7b41177c402daab21ffd16f023ea7be8e83d1e202407ad10bbbcf41703a0834ad9183f82cd
6
+ metadata.gz: 91f9c61cd123a0a5f8cc8bf457fa06ba7dc37591b7eeab09cdc4be7f5d97e1ec13eeccdb4167e976196b9a3d3322ab3eec63c875c3053b3b2f913d433ea02d5a
7
+ data.tar.gz: 5d859c1f5bbf13d553bbffd0bcf15433ba8aff40b4660db09b61790612f726e6f9fac90c9ab7d531ff4444d465ac440e28e2f3303be32c4a4c3886ae728e6f65
data/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ### 3.3.5 (2026-07-30)
2
+
3
+ #### Fixes
4
+
5
+ * [#2814](https://github.com/ruby-grape/grape/pull/2814): Fix `type: [A, B]` combined with `values:`/`except_values:` raising `IncompatibleOptionValues` at definition time - [@ericproulx](https://github.com/ericproulx).
6
+ * [#2833](https://github.com/ruby-grape/grape/pull/2833): Fix `Grape::API::Instance.to_s` returning an empty string instead of the class name when the instance has no base (regression since 3.0.0) - [@ericproulx](https://github.com/ericproulx).
7
+ * [#2834](https://github.com/ruby-grape/grape/pull/2834): Fix cascaded routes (`X-Cascade: pass`) leaking `route_info` and path captures into the next matched route's `route` and `params` - [@ericproulx](https://github.com/ericproulx).
8
+
1
9
  ### 3.3.4 (2026-07-25)
2
10
 
3
11
  #### Fixes
data/README.md CHANGED
@@ -10,7 +10,7 @@ Grape is a REST-like API framework for Ruby. It's designed to run on Rack or com
10
10
 
11
11
  ## Stable Release
12
12
 
13
- You're reading the documentation for the stable release of Grape, 3.3.4.
13
+ You're reading the documentation for the stable release of Grape, 3.3.5.
14
14
 
15
15
  ## Project Resources
16
16
 
@@ -21,11 +21,11 @@ module Grape
21
21
  Boolean = Grape::API::Boolean
22
22
 
23
23
  class << self
24
- extend Forwardable
25
-
26
24
  attr_accessor :configuration
27
25
 
28
- def_delegators :@base, :to_s
26
+ def to_s
27
+ @base&.to_s || super
28
+ end
29
29
 
30
30
  def base=(grape_api)
31
31
  @base = grape_api
data/lib/grape/router.rb CHANGED
@@ -126,10 +126,14 @@ module Grape
126
126
  !cascade
127
127
  end
128
128
 
129
+ # Routing args are rebuilt for every attempt: when a route cascades
130
+ # (X-Cascade pass), the next candidate must not observe the previous
131
+ # attempt's +route_info+ or path captures.
129
132
  def process_route(route, input, env, include_allow_header: false)
130
133
  route_params = route.params(input)
131
- env[Grape::Env::GRAPE_ROUTING_ARGS] ||= { route_info: route }
132
- env[Grape::Env::GRAPE_ROUTING_ARGS].merge!(route_params) if route_params.present?
134
+ routing_args = { route_info: route }
135
+ routing_args.merge!(route_params) if route_params.present?
136
+ env[Grape::Env::GRAPE_ROUTING_ARGS] = routing_args
133
137
  env[Grape::Env::GRAPE_ALLOWED_METHODS] = route.allow_header if include_allow_header
134
138
  route.call(env)
135
139
  end
@@ -6,6 +6,9 @@ module Grape
6
6
  # This class wraps {MultipleTypeCoercer}, for use with collections
7
7
  # that allow members of more than one type.
8
8
  class VariantCollectionCoercer
9
+ # @return [Array<Class>,Set<Class>] the member types as declared in the DSL
10
+ attr_reader :types
11
+
9
12
  # Construct a new coercer that will attempt to coerce
10
13
  # a list of values such that all members are of one of
11
14
  # the given types. The container may also optionally be
@@ -51,7 +51,7 @@ module Grape
51
51
  @allow_blank = resolve_value(raw[:allow_blank])
52
52
  @fail_fast = raw[:fail_fast] || false
53
53
 
54
- @guessed_coerce_type = guess_coerce_type(@coerce_type, @values, @except_values)
54
+ @guessed_coerce_type = guess_coerce_type(declared_coerce_type, @values, @except_values)
55
55
  @shared_opts = { allow_blank: @allow_blank, fail_fast: @fail_fast }.freeze
56
56
  @validator_entries = build_validator_entries(raw)
57
57
 
@@ -140,6 +140,16 @@ module Grape
140
140
  opt.is_a?(Hash) ? opt[:value] : opt
141
141
  end
142
142
 
143
+ # The type as written in the DSL. Identical to +@coerce_type+ except for
144
+ # a multiple-type declaration (+type: [Integer, String]+), where
145
+ # {#parse_coerce} wraps the declared list in a
146
+ # {Types::VariantCollectionCoercer} for runtime coercion — the
147
+ # definition-time coherence checks need the list back, since the wrapper
148
+ # matches nothing under +===+.
149
+ def declared_coerce_type
150
+ @coerce_type.is_a?(Types::VariantCollectionCoercer) ? @coerce_type.types : @coerce_type
151
+ end
152
+
143
153
  def guess_coerce_type(coerce_type, *values_list)
144
154
  return coerce_type unless coerce_type == Array
145
155
 
data/lib/grape/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Grape
4
- VERSION = '3.3.4'
4
+ VERSION = '3.3.5'
5
5
  end
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.3.4
4
+ version: 3.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Bleigh
@@ -282,9 +282,9 @@ licenses:
282
282
  - MIT
283
283
  metadata:
284
284
  bug_tracker_uri: https://github.com/ruby-grape/grape/issues
285
- changelog_uri: https://github.com/ruby-grape/grape/blob/v3.3.4/CHANGELOG.md
286
- documentation_uri: https://www.rubydoc.info/gems/grape/3.3.4
287
- source_code_uri: https://github.com/ruby-grape/grape/tree/v3.3.4
285
+ changelog_uri: https://github.com/ruby-grape/grape/blob/v3.3.5/CHANGELOG.md
286
+ documentation_uri: https://www.rubydoc.info/gems/grape/3.3.5
287
+ source_code_uri: https://github.com/ruby-grape/grape/tree/v3.3.5
288
288
  rubygems_mfa_required: 'true'
289
289
  rdoc_options: []
290
290
  require_paths: