Skip to content

Deprecates Grape's Extensions for ParamsBuilder in favor of build_with #2540

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 1, 2025

Conversation

ericproulx
Copy link
Contributor

@ericproulx ericproulx commented Feb 25, 2025

This PR refactors params_builder by using the same technique as validators, parsers, error formatters ... etc which is registration with a symbolized short name. IMO, it makes sense to follow the same pattern like other components that we have and the registration part ease the customization.

There are 3 ways to configure the params_builder:

  • Globally by callingGrape.config.params_builder
  • At the API level by including params_builder extensions concern
  • using build_with inside params scope

This PR is an hybrid meaning it does not remove the old way, its just deprecating it. Here are the deprecations:

  • Passing a class to build_with or Grape.config.param_builder
  • Including Grape's extensions like Grape::Extensions::Hashie::Mash::ParamBuilder

See UPGRADING.md

This PR also adds build_with a the API level since including the extensions concerns are deprecated.

@ericproulx ericproulx marked this pull request as ready for review February 26, 2025 20:46
@ericproulx ericproulx requested a review from dblock February 26, 2025 20:46
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.

Does this prevent one from defining their own ParamBuilder? I am not sure anybody would have, but it's still a public interface. 🤔

@ericproulx
Copy link
Contributor Author

Does this prevent one from defining their own ParamBuilder? I am not sure anybody would have, but it's still a public interface. 🤔

No, anyone can define their own. I've just reused the same technique as parsers, error_formatters, etc ...

@dblock dblock merged commit 45abe0d into ruby-grape:master Mar 1, 2025
63 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.

2 participants