rspec_api_documentation
rspec_api_documentation copied to clipboard
Extra parameters are passing to the controller
Hi!
Imagine you have an endpoint test like below :
post '/api/v0/users' do
parameter :email
parameter :role_ids, required: false
example 'do_req' do
do_request(email: [email protected])
end
end
# In related controller
params.keys.include?(:email) # => True
params[:email] # => "[email protected]"
params.keys.include?(:role_ids) # => True (why?)
params[:role_ids] # => nil
As you can see, params[:role_ids] exists although I don't pass it to do_request
Is there any option to disable this behaviour?
In my case, because of a bug in rails_params gem following validation fails when params[:role_id] is nil.
role_ids = param! :role_ids, Array do |array, index|
array.param! index, String
end
> NoMethodError:
> undefined method `each_with_index' for nil:NilClass
Ruby : 2.2.3 Rails : 4.2.6
+1 this is happening to me also! Not sure why, but looks happen in https://github.com/zipmark/rspec_api_documentation/blob/d3892cc7388460a98476734963face5a7a2ac158/lib/rspec_api_documentation/dsl/endpoint/set_param.rb#L11