Skip to content

Conversation

@ericproulx
Copy link
Contributor

@ericproulx ericproulx commented Oct 26, 2025

Migrate from ActiveSupport::Configurable to Dry::Configurable

This PR migrates Grape's configuration system from ActiveSupport::Configurable to Dry::Configurable, since its deprecated (see #2616)

Changes Made

Dependencies

  • Added dry-configurable dependency to grape.gemspec
  • Removed dependency on active_support/configurable

Core Changes

  • Replaced ActiveSupport::Configurable with Dry::Configurable in the main Grape module
  • Updated configuration syntax from config.param_builder = :value to setting :param_builder, default: :value
  • Migrated existing configuration settings:
  • param_builder (default: :hash_with_indifferent_access)
  • lint (default: false)

Code Changes

# Before (ActiveSupport::Configurable)
module Grape
  include ActiveSupport::Configurable

  configure do |config|
    config.param_builder = :hash_with_indifferent_access
    config.lint = false
    config.compile_methods!
  end
end

# After (Dry::Configurable)
module Grape
  extend Dry::Configurable

  setting :param_builder, default: :hash_with_indifferent_access
  setting :lint, default: false
end

Benefits

  1. Reduced Dependencies: Removes dependency on active_support/configurable, reducing the overall dependency footprint
  2. Better Performance: Dry::Configurable is more lightweight and focused specifically on configuration needs
  3. Cleaner API: The new syntax is more declarative and easier to understand
  4. Maintained Compatibility: All existing configuration options remain available with the same names

Documentation Updates Needed

The following documentation files will need to be updated in a follow-up PR:

  • README.md - Update configuration examples
  • UPGRADING.md - Add migration guide for configuration changes

Testing

  • All existing tests pass without modification
  • Configuration functionality is fully preserved
  • The api_remount_spec.rb tests that use dynamic configuration continue to work as expected

@ericproulx ericproulx force-pushed the migrate-to-dry-configurable branch 3 times, most recently from 4df6529 to 1f8c36b Compare October 26, 2025 18:24
@ericproulx ericproulx requested a review from dblock October 26, 2025 18:42
Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some missing ... periods ;) Feel free to merge after.

UPGRADING.md Outdated
### Endpoint execution simplified and `return` deprecated
#### Configuration API Migration from ActiveSupport::Configurable to Dry::Configurable

Grape has migrated from `ActiveSupport::Configurable` to `Dry::Configurable` for its configuration system since its [deprecated](https://github.com/rails/rails/blob/1cdd190a25e483b65f1f25bbd0f13a25d696b461/activesupport/lib/active_support/configurable.rb#L3-L7)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Grape has migrated from `ActiveSupport::Configurable` to `Dry::Configurable` for its configuration system since its [deprecated](https://github.com/rails/rails/blob/1cdd190a25e483b65f1f25bbd0f13a25d696b461/activesupport/lib/active_support/configurable.rb#L3-L7)
Grape has migrated from `ActiveSupport::Configurable` to `Dry::Configurable` for its configuration system since its [deprecated](https://github.com/rails/rails/blob/1cdd190a25e483b65f1f25bbd0f13a25d696b461/activesupport/lib/active_support/configurable.rb#L3-L7).

CHANGELOG.md Outdated
* [#2615](https://github.com/ruby-grape/grape/pull/2615): Remove manual toc and tod danger check - [@alexanderadam](https://github.com/alexanderadam).
* Your contribution here.
* [#2612](https://github.com/ruby-grape/grape/pull/2612): Avoid multiple mount pollution - [@alexanderadam](https://github.com/alexanderadam).
* [#2617](https://github.com/ruby-grape/grape/pull/2617): Migrate from ActiveSupport::Configurable to Dry::Configurable - [@ericproulx](https://github.com/ericproulx).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [#2617](https://github.com/ruby-grape/grape/pull/2617): Migrate from ActiveSupport::Configurable to Dry::Configurable - [@ericproulx](https://github.com/ericproulx).
* [#2617](https://github.com/ruby-grape/grape/pull/2617): Migrate from `ActiveSupport::Configurable` to `Dry::Configurable` - [@ericproulx](https://github.com/ericproulx).

Copy link
Member

@dblock dblock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, I think we can preserve this to avoid a breaking change?

Grape.configure do |config|
  config.param_builder = :hashie_mash
  config.lint = true
end
``

@ericproulx ericproulx force-pushed the migrate-to-dry-configurable branch from 1f8c36b to 9a8a4c6 Compare October 26, 2025 21:46
@ericproulx
Copy link
Contributor Author

Actually, I think we can preserve this to avoid a breaking change?

Grape.configure do |config|
  config.param_builder = :hashie_mash
  config.lint = true
end
``

It's a lie from AI. It's still working.

@dblock dblock merged commit 9060dd0 into master Oct 26, 2025
103 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants