richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.
MIT License
750 stars 150 forks source link

base_api_controller/base_api_controllers config not work #115

Closed anonymelon closed 8 years ago

anonymelon commented 9 years ago

I have a requirement to specify a subclass of ActionController::Base eg MyAPIController, so I add a config base_api_controller: MyAPIController, but it not work. I have read the source code, just replace the base_api_controller method's default value to MyAPIController, it works as expected.

I'm wondering how to use this config, can anyone give me a example?

And I find a hidden config controller_base_path, I use it to specify the controller path which I want to generate docs, it works, but this solution seems not official :(

wintondeshong commented 9 years ago

+1 I am also experiencing this issue. I was able to just delete the base_api_controller/s config line and it started working again.

CQBinh commented 9 years ago

From docs, you can config like this:

class Swagger::Docs::Config
  def self.base_api_controller
    ActionController::API  
  end
end

Swagger::Docs::Config.register_apis({
  "1.0" => {
    :controller_base_path => "",
    :api_file_path => "public"
  }
})

And then test by printing to console:

p Swagger::Docs::Config.base_api_controller

Run rake swagger:docs to see what happen. In addition, you can see on issue #75

Swagger::Docs::Config.base_api_controller = ActionController::API 
richhollis commented 8 years ago

Closing - please re-open if still an issue.