You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*[#2535](https://github.com/ruby-grape/grape/pull/2535): Delegates calls to inner objects - [@ericproulx](https://github.com/ericproulx).
7
+
*[#2537](https://github.com/ruby-grape/grape/pull/2537): Use activesupport `try` pattern - [@ericproulx](https://github.com/ericproulx).
8
+
*[#2536](https://github.com/ruby-grape/grape/pull/2536): Update normalize_path like Rails - [@ericproulx](https://github.com/ericproulx).
9
+
*[#2540](https://github.com/ruby-grape/grape/pull/2540): Introduce Params builder with symbolized short name - [@ericproulx](https://github.com/ericproulx).
10
+
*[#2550](https://github.com/ruby-grape/grape/pull/2550): Drop ActiveSupport 6.0 - [@ericproulx](https://github.com/ericproulx).
11
+
*[#2549](https://github.com/ruby-grape/grape/pull/2549): Delegate cookies management to `Grape::Request` - [@ericproulx](https://github.com/ericproulx).
*[#2543](https://github.com/ruby-grape/grape/pull/2543): Fix array allocation on mount - [@ericproulx](https://github.com/ericproulx).
18
+
*[#2546](https://github.com/ruby-grape/grape/pull/2546): Fix middleware with keywords - [@ericproulx](https://github.com/ericproulx).
19
+
*[#2547](https://github.com/ruby-grape/grape/pull/2547): Remove jsonapi related code - [@ericproulx](https://github.com/ericproulx).
20
+
*[#2548](https://github.com/ruby-grape/grape/pull/2548): Formatting from header acts like versioning from header - [@ericproulx](https://github.com/ericproulx).
*[#2521](https://github.com/ruby-grape/grape/pull/2521): Fixed typo in README - [@datpmt](https://github.com/datpmt).
45
+
*[#2525](https://github.com/ruby-grape/grape/pull/2525): Require logger before active_support - [@ericproulx](https://github.com/ericproulx).
46
+
*[#2524](https://github.com/ruby-grape/grape/pull/2524): Fix validators bad encoding - [@ericproulx](https://github.com/ericproulx).
47
+
*[#2530](https://github.com/ruby-grape/grape/pull/2530): Fix endpoint's status when rescue_from without a block - [@ericproulx](https://github.com/ericproulx).
48
+
*[#2529](https://github.com/ruby-grape/grape/pull/2529): Fix missing settings on mounted routes (when settings are identical) - [@Haerezis](https://github.com/Haerezis).
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
Contributing to Grape
2
2
=====================
3
3
4
-
Grape is work of [hundreds of contributors](https://github.com/ruby-grape/grape/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape/issues). When in doubt, ask a question in the [Grape Google Group](http://groups.google.com/group/ruby-grape).
4
+
Grape is work of [hundreds of contributors](https://github.com/ruby-grape/grape/graphs/contributors). You're encouraged to submit [pull requests](https://github.com/ruby-grape/grape/pulls), [propose features and discuss issues](https://github.com/ruby-grape/grape/issues).
[](https://gitter.im/ruby-grape/grape?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
9
6
10
7
## Table of Contents
11
8
@@ -157,14 +154,14 @@ Grape is a REST-like API framework for Ruby. It's designed to run on Rack or com
157
154
158
155
## Stable Release
159
156
160
-
You're reading the documentation for the next release of Grape, which should be 2.3.0.
161
-
The current stable release is [2.2.0](https://github.com/ruby-grape/grape/blob/v2.2.0/README.md).
157
+
You're reading the documentation for the next release of Grape, which should be 2.4.0.
158
+
The current stable release is [2.3.0](https://github.com/ruby-grape/grape/blob/v2.3.0/README.md).
@@ -803,16 +803,15 @@ The class can also be overridden on individual parameter blocks using `build_wit
803
803
804
804
```ruby
805
805
params do
806
-
build_with Grape::Extensions::Hash::ParamBuilder
806
+
build_with :hash
807
807
optional :color, type:String
808
808
end
809
809
```
810
810
811
-
Or globally with the [Configuration](#configuration)`Grape.configure.param_builder`.
812
-
813
811
In the example above, `params["color"]` will return `nil` since `params` is a plain `Hash`.
814
812
815
-
Available parameter builders are `Grape::Extensions::Hash::ParamBuilder`, `Grape::Extensions::ActiveSupport::HashWithIndifferentAccess::ParamBuilder` and `Grape::Extensions::Hashie::Mash::ParamBuilder`.
813
+
Available parameter builders are `:hash`, `:hash_with_indifferent_access`, and `:hashie_mash`.
814
+
See [params_builder](lib/grape/params_builder).
816
815
817
816
### Declared
818
817
@@ -2046,7 +2045,7 @@ end
2046
2045
```ruby
2047
2046
params do
2048
2047
requires :code, type:String, length: { is:2, message:'code is expected to be exactly 2 characters long' }
2049
-
requires :str, type:String, length: { min:5, message:'str is expected to be atleast 5 characters long' }
2048
+
requires :str, type:String, length: { min:5, message:'str is expected to be at least 5 characters long' }
2050
2049
requires :list, type: [Integer], length: { min:2, max:3, message:'list is expected to have between 2 and 3 elements' }
2051
2050
end
2052
2051
```
@@ -3536,8 +3535,8 @@ Please use `Route#xyz` instead.
3536
3535
3537
3536
Note that difference of `Route#options` and `Route#settings`.
3538
3537
3539
-
The `options` can be referred from your route, it should be set by specifing key and value on verb methods such as `get`, `post` and `put`.
3540
-
The `settings` can also be referred from your route, but it should be set by specifing key and value on `route_setting`.
3538
+
The `options` can be referred from your route, it should be set by specifying key and value on verb methods such as `get`, `post` and `put`.
3539
+
The `settings` can also be referred from your route, but it should be set by specifying key and value on `route_setting`.
Copy file name to clipboardExpand all lines: UPGRADING.md
+32Lines changed: 32 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,38 @@
1
1
Upgrading Grape
2
2
===============
3
3
4
+
#### Params Builder
5
+
6
+
- Passing a class to `build_with` or `Grape.config.param_builder` has been deprecated in favor of a symbolized short_name. See `SHORTNAME_LOOKUP` in [params_builder](lib/grape/params_builder.rb).
7
+
- Including Grape's extensions like `Grape::Extensions::Hashie::Mash::ParamBuilder` has been deprecated in favor of using `build_with` at the route level.
8
+
9
+
#### Accept Header Negotiation Harmonized
10
+
11
+
[Accept](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Accept) header is now fully interpreted through `Rack::Utils.best_q_match` which is following [RFC2616 14.1](https://datatracker.ietf.org/doc/html/rfc2616#section-14.1). Since [Grape 2.1.0](https://github.com/ruby-grape/grape/blob/master/CHANGELOG.md#210-20240615), the [header versioning strategy](https://github.com/ruby-grape/grape?tab=readme-ov-file#header) was adhering to it, but `Grape::Middleware::Formatter` never did.
12
+
13
+
Your API might act differently since it will strictly follow the [RFC2616 14.1](https://datatracker.ietf.org/doc/html/rfc2616#section-14.1) when interpreting the `Accept` header. Here are the differences:
14
+
15
+
###### Invalid or missing quality ranking
16
+
The following used to yield `application/xml` and now will yield `application/json` as the preferred media type:
For the invalid case, the value `invalid` was automatically `to_f` and `invalid.to_f` equals `0.0`. Now, since it doesn't match [Rack's regex](https://github.com/rack/rack/blob/3-1-stable/lib/rack/utils.rb#L138), its interpreted as non provided and its quality ranking equals 1.0.
21
+
22
+
For the non provided case, 1.0 was automatically assigned and in a case of multiple best matches, the first was returned based on Ruby's sort_by `quality`. Now, 1.0 is still assigned and the last is returned in case of multiple best matches. See [Rack's implementation](https://github.com/rack/rack/blob/e8f47608668d507e0f231a932fa37c9ca551c0a5/lib/rack/utils.rb#L167) of the RFC.
23
+
24
+
###### Considering the closest generic when vendor tree
25
+
Excluding the [header versioning strategy](https://github.com/ruby-grape/grape?tab=readme-ov-file#header), whenever a media type with the [vendor tree](https://datatracker.ietf.org/doc/html/rfc6838#section-3.2) leading facet `vnd.` like `application/vnd.api+json` was provided, Grape would also consider its closest generic when negotiating. In that case, `application/json` was added to the negotiation. Now, it will just consider the provided media types without considering any closest generics, and you'll need to [register](https://github.com/ruby-grape/grape?tab=readme-ov-file#api-formats) it.
26
+
You can find the official vendor tree registrations on [IANA](https://www.iana.org/assignments/media-types/media-types.xhtml)
27
+
28
+
### Upgrading to >= 2.4.0
29
+
30
+
#### Custom Validators
31
+
32
+
If you now receive an error of `'Grape::Validations.require_validator': unknown validator: your_custom_validation (Grape::Exceptions::UnknownValidator)` after upgrading to 2.4.0 then you will need to ensure that you require the `your_custom_validation` file before your Grape API code is loaded.
33
+
34
+
See [2533](https://github.com/ruby-grape/grape/issues/2533) for more information.
0 commit comments