Skip to content
Merged
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 @@ -9,6 +9,7 @@
* [#2777](https://github.com/ruby-grape/grape/pull/2777): Add `Grape::Endpoint#mounted_app` reader and `app:` keyword - [@ericproulx](https://github.com/ericproulx).
* [#2778](https://github.com/ruby-grape/grape/pull/2778): Rename `Grape::Endpoint`'s `for:` keyword to `api:` and expose `#api` - [@ericproulx](https://github.com/ericproulx).
* [#2779](https://github.com/ruby-grape/grape/pull/2779): Promote route metadata (`version`, `namespace`, `prefix`, `requirements`, `anchor`, `settings`) to `Grape::Router::Route` keyword arguments, and drop the unused `Grape::Endpoint::Options` `format` member - [@ericproulx](https://github.com/ericproulx).
* [#2782](https://github.com/ruby-grape/grape/pull/2782): Remove the dead `format` keyword from `Grape::Router::Pattern` - [@ericproulx](https://github.com/ericproulx).
* Your contribution here.

#### Fixes
Expand Down
2 changes: 1 addition & 1 deletion UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ What changed is the raw bag. `route.options` now holds only what was declared fo

The `:format` member was removed from the endpoint's internal `Options`. Nothing ever passed `format:` to `Grape::Endpoint.new` — `config.format` was always `nil` — so this has no runtime effect (the `(.:format)`/`(.json)` route suffix comes from `Grape::Path`, not from this value). But `Grape::Endpoint.new(..., format: …)` now raises `unknown keyword: :format` instead of silently ignoring it.

`Grape::Router::Pattern#initialize` still accepts `format:` — it remains a valid capture constraint — but it is now optional (`format: nil`).
`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`.

### Upgrading to >= 3.3

Expand Down
7 changes: 3 additions & 4 deletions lib/grape/router/pattern.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class Pattern
def_delegators :to_regexp, :===
alias match? ===

def initialize(origin:, suffix:, anchor:, params:, version:, requirements:, format: nil)
def initialize(origin:, suffix:, anchor:, params:, version:, requirements:)
@origin = origin
@path = PatternCache[[build_path_from_pattern(@origin, anchor), suffix]]
@pattern = MustermannPattern.new(@path, uri_decode: true, params:, capture: extract_capture(format, version, requirements))
@pattern = MustermannPattern.new(@path, uri_decode: true, params:, capture: extract_capture(version, requirements))
@to_regexp = @pattern.to_regexp
end

Expand All @@ -28,9 +28,8 @@ def captures_default

private

def extract_capture(format, version, requirements)
def extract_capture(version, requirements)
capture = {}
capture[:format] = map_str(format) if format.present?
capture[:version] = map_str(version) if version.present?

return capture if requirements.blank?
Expand Down
1 change: 0 additions & 1 deletion spec/grape/router/route_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
suffix: '',
anchor: true,
params: {},
format: nil,
version: nil,
requirements: {}
)
Expand Down
Loading