Skip to content

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

Open
ericproulx wants to merge 1 commit into
masterfrom
test/grape-swagger-integration
Open

Deprecate positional options Hash for desc; add grape-swagger integration spec#2723
ericproulx wants to merge 1 commit 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

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.

1 participant