richhollis / swagger-docs

Generates swagger-ui json files for Rails APIs with a simple DSL.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

klass.methods doesn't include :swagger_config

ayudemura opened this issue · comments

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"
      }
    }
  }
})

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.

I have this same problem

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

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

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?