Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* [#2782](https://github.com/ruby-grape/grape/pull/2782): Remove the dead `format` keyword from `Grape::Router::Pattern` - [@ericproulx](https://github.com/ericproulx).
* [#2783](https://github.com/ruby-grape/grape/pull/2783): Read a route's `version`, `anchor` and `requirements` from its pattern instead of storing them again on the route - [@ericproulx](https://github.com/ericproulx).
* [#2784](https://github.com/ruby-grape/grape/pull/2784): Move HEAD route creation into `Grape::Router::Route#to_head` - [@ericproulx](https://github.com/ericproulx).
* [#2787](https://github.com/ruby-grape/grape/pull/2787): Stop populating the write-only `namespace_setting(:description)` in `desc` - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

#### Fixes
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ The `:format` member was removed from the endpoint's internal `Options`. Nothing

`Grape::Router::Pattern#initialize` no longer accepts `format:` either. It was never given a non-`nil` value — a route's `:format` capture comes from the path suffix built by `Grape::Path`, not from the pattern — so the keyword was dead. `Grape::Router::Pattern.new(..., format: …)` now raises `unknown keyword: :format`.

#### `desc` no longer populates `namespace_setting(:description)`

`desc` used to store its settings under both the route scope (`route_setting(:description)`) and the namespace scope (`namespace_setting(:description)`). The namespace copy was write-only — the namespace scope isn't wired for inheritance and nothing in Grape or grape-swagger ever read it — so `desc` now writes only the route scope. `namespace_setting(:description)` returns `nil`; read a route's description through `route_setting(:description)` or the `route.description` reader.

### Upgrading to >= 3.3

#### Minimum required Ruby is now 3.3
Expand Down
4 changes: 3 additions & 1 deletion lib/grape/dsl/desc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def desc(description, *legacy_options, **options, &config_block)
else
options.merge(description:)
end
inheritable_setting.namespace[:description] = settings
# Only the route scope is consumed downstream (by +route+ and the
# route's readers, e.g. +http_codes+); the namespace scope was
# write-only, so it is no longer populated.
inheritable_setting.route[:description] = settings
end
end
Expand Down
6 changes: 3 additions & 3 deletions spec/grape/dsl/desc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
desc_text = 'The description'
options = { message: 'none' }
subject.desc desc_text, **options
expect(subject.namespace_setting(:description)).to eq(options.merge(description: desc_text))
expect(subject.route_setting(:description)).to eq(options.merge(description: desc_text))
expect(subject.namespace_setting(:description)).to be_nil
end

context 'when a positional options Hash is passed' do
Expand All @@ -31,8 +31,8 @@
Grape.deprecator.silence do
subject.desc desc_text, options
end
expect(subject.namespace_setting(:description)).to eq(options.merge(description: desc_text))
expect(subject.route_setting(:description)).to eq(options.merge(description: desc_text))
expect(subject.namespace_setting(:description)).to be_nil
end
end

Expand Down Expand Up @@ -103,8 +103,8 @@
security %w[array of security schemes]
end

expect(subject.namespace_setting(:description)).to eq(expected_options)
expect(subject.route_setting(:description)).to eq(expected_options)
expect(subject.namespace_setting(:description)).to be_nil
end
end
end
Expand Down
Loading