Apipie / apipie-rails

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

`action` parameter isn't detected correctly #392

Open joevandyk opened 9 years ago

joevandyk commented 9 years ago

Say you have

  api :GET, 'whatever'
  param :action,      String, required: true

Rails will populates params[:action] with the name of the controller action, which probably isn't what you want.

A fix would probably be to use request.query_parameters[:action] || request.request_parameters[:action].

Same thing probably happens with a param called controller.

joshpfosi commented 9 years ago

I may be having a related issue with the parameter name resource_id. For an unknown reason, the call:

param :chassis_id, Fixnum, required: true
param :resource_id, Fixnum, required: true
error 422, 'Any error in association'

Results in the following validation error when attempting to call that endpoint:

Missing parameter resource

Looking closer,

# lib/apipie/dsl_definitions.rb:213
method_params = self.class._apipie_get_method_params(action_name)

returns ['chassis_id', 'resource'] as keys. It seems as if resource_id is a keyword for Apipie and mucking things up.