Deprecate positional options Hash in Auth DSL; use keyword arguments#2728
Open
ericproulx wants to merge 1 commit into
Open
Deprecate positional options Hash in Auth DSL; use keyword arguments#2728ericproulx wants to merge 1 commit into
ericproulx wants to merge 1 commit into
Conversation
`Grape::Middleware::Auth::DSL#auth`, `#http_basic` and `#http_digest` now take their options as keyword arguments. Passing a positional options Hash still works but emits a Grape.deprecator warning and is merged into the keyword options, so downstream callers keep working through the deprecation cycle. Internal delegation splats (`**options`) so the helper methods don't self-trigger the deprecation. Mirrors the `desc(description, **options)` deprecation (#2723). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3962bec to
d962c0b
Compare
Danger ReportNo issues found. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Grape::Middleware::Auth::DSL#auth,#http_basicand#http_digestnow take their options as keyword arguments. Passing a positional optionsHashstill works but emits aGrape.deprecatorwarning and is merged into the keyword options, so downstream callers keep working through the deprecation cycle.This mirrors the
desc(description, **options)deprecation from #2723.Details
merge_legacy_auth_options(method_name, legacy_options, options): no-op on the kwargs path; on a positional Hash it warns viaGrape.deprecatorand merges (kwargs win).authis preserved — thereturn … unless typeearly-return runs before any deprecation logic, so readingauthnever warns.**options(auth(:http_basic, **options, &)), sohttp_basic/http_digestdon't self-trigger the deprecation.reverse_mergeand theGrape::Middleware::Auth::Baseconsumption path are unchanged.Docs
UPGRADING.md: new>= 3.3entry documenting the kwargs migration and the deprecated positional form (styled like the existingwith/versionkwargs entries).Tests
spec/grape/middleware/auth/dsl_spec.rb: 3 new specs (one per method) — a positional Hash raisesActiveSupport::DeprecationException(suite runsdeprecator.behavior = :raise) and still produces the correct auth settings when silenced. Existing keyword/block specs unchanged.🤖 Generated with Claude Code