Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

klass.methods doesn't include :swagger_config #147

Open
ayudemura opened this issue Sep 6, 2016 · 5 comments
Open

klass.methods doesn't include :swagger_config #147

ayudemura opened this issue Sep 6, 2016 · 5 comments

Comments

@ayudemura
Copy link

I am experiencing the identical problem as #104 (which is closed)
I am hoping to get some help on config.

My swagger_docs.rb initialization is

Swagger::Docs::Config.register_apis({
  "1.0" => {
    :api_file_path => "public/api/v1/",
    :base_path => "https://app.x.net/api",
    :clean_directory => true,
    :parent_controller => ApplicationController,
    :base_api_controller => ActionController::API,
    :controller_base_path => "",
    :attributes => {
      :info => {
        "title" => "X API",
        "description" => "Documentation for X API.",
        "license" => "Apache 2.0",
        "licenseUrl" => "http://www.apache.org/licenses/LICENSE-2.0.html"
      }
    }
  }
})
@ayudemura ayudemura changed the title Method doesn't include :swagger_config kass.methods doesn't include :swagger_config Sep 6, 2016
@ayudemura ayudemura changed the title kass.methods doesn't include :swagger_config klass.methods doesn't include :swagger_config Sep 6, 2016
@ace
Copy link

ace commented Jan 12, 2017

I'm having the same error. The problem is that register_apis is not using the base_api_controller param, it's using its own default (ActionController::Base). If you use this controller as your base, everything works, but using ActionController::API fails.

As a workaround, adding a line before that call, setting the base controller, solves the problem:

Swagger::Docs::Config.base_api_controller = ActionController::API.

@fercreek
Copy link

I have this same problem

@fercreek
Copy link

I found two ways to solve this:

  • In swagger_docs.rb
include Swagger::Docs::ImpotentMethods

# Swagger::Docs::Config.register_apis({})

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

Or adding at the top of routes.rb

Swagger::Docs::Config.base_api_controller = ActionController::API
include Swagger::Docs::ImpotentMethods

@msdundar
Copy link

Same here! Workarounds are not working with Rails 5 using an ActionController::API.

@misa-itk
Copy link

Having same problem. Controllers without index action are not taken for making swagger file.
@fercreek did you tried with rails 5.2 api ?
@msdundar have you found the solution?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants