Closed
Description
Thanks for the gem/project.
In upgrading from 1.2.5 to 1.3.0, I've noticed that the way an empty string is coerced for a Date param has changed. Previously, it would be returned as nil
, now it is returned as ""
. Based on Upgrading.md it's not clear to me whether this change is desired or would be considered a bug.
Here is a script to demonstrate the discrepancy:
require 'bundler/inline'
gemfile do
# gem 'grape', git: '[email protected]:ruby-grape/grape' # returns { class: "String" }
# gem 'grape', '1.3.0' # returns { class: "String" }
# gem 'grape', '1.2.5' # returns { class: "NilClass" }
gem 'rack', '2.0.6'
end
class API < Grape::API
params do
requires :mydate, type: Date
end
get '/' do
{ class: params.fetch(:mydate).class.inspect }
end
end
Thread.new { Rack::Server.start(app: API, Port: 9292) }
sleep 2 # adjust as desired :P
require 'net/http'
puts Net::HTTP.get('localhost', '/?mydate=', 9292)
Thanks.