ruby-grape / grape-rabl

Use rabl with grape
MIT License
136 stars 29 forks source link

grape 2.2.0 is incompatible with grape-rabl #53

Open znz opened 2 months ago

znz commented 2 months ago

grape-rabl 0.5.0 uses Grape::Formatter.formatter_for with one argument.

https://github.com/ruby-grape/grape-rabl/blob/b201ebdb0dc44906e5b42619f060fa3ac4e5bdfd/lib/grape-rabl/formatter.rb#L40-L41

But grape 2.2.0 changed its arity.

https://github.com/ruby-grape/grape/compare/v2.1.3...v2.2.0#diff-2332fb7b55e286e39346d06d8427673ae0dade2d41786327b23375cc30ef2ffaR17

So wrong number of arguments (given 1, expected 2) raised.

In our application, following monkey patch resolved the exception.

module Grape
  module Formatter
    module_function

    def formatter_for(api_format, formatters=nil)
      select_formatter(formatters, api_format) || DEFAULT_LAMBDA_FORMATTER
    end
  end
end
dblock commented 2 months ago

I am moving this to grape-rabl since it's really a problem with the latter.

Want to try and fix this here? Maybe start with https://github.com/ruby-grape/grape-rabl/issues/52.