Apipie / apipie-rails

Ruby on Rails API documentation tool
Apache License 2.0
2.47k stars 463 forks source link

Support rails 5 - ActionController::Parameters is no longer a Hash #456

Open karloku opened 8 years ago

karloku commented 8 years ago

In rails 5 / ActiveSupport 5, ActionController::Parameters is no longer a subclass of ActiveSupport::HashWithIndifferentAccess (see Edge Document).

validator.rb#L305

return false !value.is_a? Hash

It will always return false.

seanhandley commented 8 years ago

👍 I'm seeing this behaviour too. I've decided to disable validations as a result.

vkeziah commented 8 years ago

any solution for this , I need validation support in rails 5

iNecas commented 8 years ago

Hi, I've started with making Apipie working against Rails 5 just now, should be fixed soon

vkeziah commented 8 years ago

@iNecas any solution ?

iNecas commented 8 years ago

Solution in progress (the famous 80%-20% problem)

On 10 August 2016 at 09:52, Ratnakar notifications@github.com wrote:

@iNecas https://github.com/iNecas any solution ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Apipie/apipie-rails/issues/456#issuecomment-238791977, or mute the thread https://github.com/notifications/unsubscribe-auth/AALn64jb5QwPXvWbqJP-i_QHXdvdNUIRks5qeYMlgaJpZM4ISsgr .

kumasento commented 8 years ago

@iNecas Hi, is there any work around for this issue?

I simply replaced Hash with ActionController::Paramters, but I hope there would be a better one :)

allanbreyes commented 8 years ago

Changing to ActionController::Parameters actually also prevents parameter expansion in the docs. I ended up using config.validate = :explicitly and then:

  # controller
  before_action :apipie_validations, except: [:create, :update]

Not terrible IMO, especially if you also run:

  # application.rb
  config.action_controller.action_on_unpermitted_parameters = :raise

Looking forward to the Rails 5 release!

pejrich commented 8 years ago

Changing ln 305 in validator.rb worked for me.

# return false if !value.is_a? Hash
return false if !value.respond_to? :keys

Until the gem is fixed, you can paste this into your initializer.

https://gist.github.com/pejrich/a9fd67eec3d71909deee6454c3964311

asnad commented 7 years ago

any update?

iNecas commented 7 years ago

This should have been fixed