Summary
Grape (ruby-grape/grape#2723) is moving Grape::DSL::Desc#desc to keyword arguments. Passing a positional options Hash still works but now emits a deprecation:
Passing a positional options Hash to desc is deprecated. Pass keyword arguments instead.
For apps that configure Grape.deprecator.behavior = :raise (the default in Grape's own test suite, and common in CI), this turns into an ActiveSupport::DeprecationException and add_swagger_documentation raises outright.
Where grape-swagger triggers it
grape-swagger 2.1.4 calls desc with a positional Hash in lib/grape-swagger/doc_methods.rb:
# ~line 96
desc api_doc.delete(:desc), api_doc
# ~line 108
desc specific_api_doc.delete(:desc), { params: specific_api_doc.delete(:params) || {}, **specific_api_doc }
Suggested fix
Double-splat the options Hash so they are passed as keyword arguments (backward compatible with current Grape):
desc api_doc.delete(:desc), **api_doc
desc specific_api_doc.delete(:desc), params: specific_api_doc.delete(:params) || {}, **specific_api_doc
Reproduction
require 'grape'
require 'grape-swagger'
Grape.deprecator.behavior = :raise
Class.new(Grape::API) { add_swagger_documentation }
# => ActiveSupport::DeprecationException: Passing a positional options Hash to `desc` is deprecated.
Tested against grape-swagger 2.1.4 with Grape from ruby-grape/grape#2723. That PR adds a grape-swagger integration job to Grape's CI to catch regressions like this going forward.
Summary
Grape (ruby-grape/grape#2723) is moving
Grape::DSL::Desc#descto keyword arguments. Passing a positional options Hash still works but now emits a deprecation:For apps that configure
Grape.deprecator.behavior = :raise(the default in Grape's own test suite, and common in CI), this turns into anActiveSupport::DeprecationExceptionandadd_swagger_documentationraises outright.Where grape-swagger triggers it
grape-swagger 2.1.4 calls
descwith a positional Hash inlib/grape-swagger/doc_methods.rb:Suggested fix
Double-splat the options Hash so they are passed as keyword arguments (backward compatible with current Grape):
Reproduction
Tested against grape-swagger 2.1.4 with Grape from ruby-grape/grape#2723. That PR adds a grape-swagger integration job to Grape's CI to catch regressions like this going forward.