Skip to content

Deprecate positional options Hash for desc; add grape-swagger integration spec#2723

Merged
ericproulx merged 2 commits into
masterfrom
test/grape-swagger-integration
May 16, 2026
Merged

Deprecate positional options Hash for desc; add grape-swagger integration spec#2723
ericproulx merged 2 commits into
masterfrom
test/grape-swagger-integration

Conversation

@ericproulx
Copy link
Copy Markdown
Contributor

Summary

Grape::DSL::Desc#desc now accepts its options as keyword arguments. Passing a positional options Hash still works but emits a deprecation warning via Grape.deprecator, so downstream callers keep functioning through the deprecation cycle.

# preferred
desc 'Create a user', detail: 'creates a user', tags: %w[users]

# still works, now deprecated
desc 'Create a user', { detail: 'creates a user', tags: %w[users] }

grape-swagger integration coverage

Adds spec/integration/grape_swagger/grape_swagger_spec.rb, a gemfiles/grape_swagger.gemfile, and a dedicated CI matrix entry (mirroring the existing grape_entity / dry_validation integration jobs).

The spec stands up a real API with add_swagger_documentation and asserts the generated OpenAPI 2.0 document (paths, descriptions carried from desc, success: responses, declared params, per-resource /swagger_doc/:name).

It also documents why the shim matters: grape-swagger 2.1.4 still calls desc 'text', options_hash internally (lib/grape-swagger/doc_methods.rb), so without the compatibility path the latest grape-swagger would break outright under the keyword-only signature. An upstream issue has been opened on ruby-grape/grape-swagger to migrate to keyword arguments.

Tests

  • New grape-swagger integration spec: green under gemfiles/grape_swagger.gemfile
  • spec/grape/dsl/desc_spec.rb: covers the keyword form and the deprecated positional form (warns + still works when silenced)
  • All desc-exercising specs pass under the default gemfile

🤖 Generated with Claude Code

…tion spec

`Grape::DSL::Desc#desc` now takes its options as keyword arguments.
Passing a positional options Hash still works but emits a deprecation
warning, so downstream callers (e.g. grape-swagger) keep functioning.

Adds a grape-swagger integration spec plus a CI matrix entry and
`gemfiles/grape_swagger.gemfile`. The spec exercises
`add_swagger_documentation` and asserts the generated OpenAPI document,
guarding the compatibility shim: grape-swagger 2.1.4 still passes a
positional Hash to `desc` internally.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ericproulx
Copy link
Copy Markdown
Contributor Author

Upstream grape-swagger issue for the internal positional-Hash desc usage: ruby-grape/grape-swagger#977

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

Danger Report

No issues found.

View run

@ericproulx ericproulx merged commit e1df793 into master May 16, 2026
81 checks passed
@ericproulx ericproulx deleted the test/grape-swagger-integration branch May 16, 2026 21:48
ericproulx added a commit that referenced this pull request May 17, 2026
`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>
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