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
Copy file name to clipboardExpand all lines: CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,7 @@
7
7
#### Fixes
8
8
9
9
* Your contribution here.
10
+
*[#2103](https://github.com/ruby-grape/grape/pull/2103): Ensure complete declared params structure is present - [@tlconnor](https://github.com/tlconnor).
10
11
*[#2099](https://github.com/ruby-grape/grape/pull/2099): Added truffleruby to Travis-CI - [@gogainda](https://github.com/gogainda).
11
12
*[#2089](https://github.com/ruby-grape/grape/pull/2089): Specify order of mounting Grape with Rack::Cascade in README - [@jonmchan](https://github.com/jonmchan).
12
13
*[#2083](https://github.com/ruby-grape/grape/pull/2083): Set `Cache-Control` header only for streamed responses - [@stanhu](https://github.com/stanhu).
Copy file name to clipboardExpand all lines: README.md
+48-5
Original file line number
Diff line number
Diff line change
@@ -353,7 +353,7 @@ use Rack::Session::Cookie
353
353
run Rack::Cascade.new [Web, API]
354
354
```
355
355
356
-
Note that order of loading apps using `Rack::Cascade` matters. The grape application must be last if you want to raise custom 404 errors from grape (such as `error!('Not Found',404)`). If the grape application is not last and returns 404 or 405 response, [cascade utilizes that as a signal to try the next app](https://www.rubydoc.info/gems/rack/Rack/Cascade). This may lead to undesirable behavior showing the [wrong 404 page from the wrong app](https://github.com/ruby-grape/grape/issues/1515).
356
+
Note that order of loading apps using `Rack::Cascade` matters. The grape application must be last if you want to raise custom 404 errors from grape (such as `error!('Not Found',404)`). If the grape application is not last and returns 404 or 405 response, [cascade utilizes that as a signal to try the next app](https://www.rubydoc.info/gems/rack/Rack/Cascade). This may lead to undesirable behavior showing the [wrong 404 page from the wrong app](https://github.com/ruby-grape/grape/issues/1515).
357
357
358
358
359
359
### Rails
@@ -787,7 +787,12 @@ Available parameter builders are `Grape::Extensions::Hash::ParamBuilder`, `Grape
787
787
788
788
### Declared
789
789
790
-
Grape allows you to access only the parameters that have been declared by your `params` block. It filters out the params that have been passed, but are not allowed. Consider the following API endpoint:
790
+
Grape allows you to access only the parameters that have been declared by your `params` block. It will:
791
+
792
+
* Filter out the params that have been passed, but are not allowed.
793
+
* Include any optional params that are declared but not passed.
794
+
795
+
Consider the following API endpoint:
791
796
792
797
````ruby
793
798
format:json
@@ -820,9 +825,9 @@ Once we add parameters requirements, grape will start returning only the declare
Copy file name to clipboardExpand all lines: UPGRADING.md
+17-4
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,19 @@
1
1
Upgrading Grape
2
2
===============
3
3
4
+
### Upgrading to >= 1.4.1
5
+
6
+
Previous to 1.3.3, the `declared` helper would always return the complete params structure if `include_missing=true` was set. In 1.3.3 the behavior was changed, so a missing Hash with or without nested parameters would always resolve as `{}`.
7
+
8
+
In 1.4.1 this behavior is reverted, so the whole params structure will always be available via `declared`, regardless of whether any params are passed.
9
+
10
+
The following rules now apply to the `declared` helper when params are missing and `include_missing=true`:
11
+
12
+
* Hash params with childern will resolve as a hash with keys for each declared child.
13
+
* Hash params with no children will resolve as `{}`.
14
+
* Array params will resolve as `[]`.
15
+
* All other params will resolve as `null`.
16
+
4
17
### Upgrading to >= 1.4.0
5
18
6
19
#### Reworking stream and file and un-deprecating stream like-objects
@@ -28,17 +41,17 @@ class API < Grape::API
28
41
end
29
42
```
30
43
31
-
Or use `stream` to stream other kinds of content. In the following example a streamer class
44
+
Or use `stream` to stream other kinds of content. In the following example a streamer class
32
45
streams paginated data from a database.
33
46
34
47
```ruby
35
-
classMyObject
48
+
classMyObject
36
49
attr_accessor:result
37
50
38
51
definitialize(query)
39
52
@result= query
40
53
end
41
-
54
+
42
55
defeach
43
56
yield'['
44
57
# Do paginated DB fetches and return each page formatted
0 commit comments