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

Common documentation not being generated

alienxp03 opened this issue · comments

commented

I'm following the documentation to setup some common params documentations, but running rake swagger:docs does not produce any documentation. Running SD_LOG_LEVEL=1 rake swagger:docs also does not show any errors either.

Base class

class Api::ApiController < ActionController::Base
  include ApplicationHelper

  class << self
    Swagger::Docs::Generator::set_real_methods

    def inherited(subclass)
      super
      subclass.class_eval do
        setup_basic_api_documentation
      end
    end

    private
    def setup_basic_api_documentation
      [:index, :show, :create, :update, :delete].each do |api_action|
        swagger_api api_action do
          param :form, :token, :integer, :required, 'Auth token'
        end
      end
    end
  end
end

Subclass

module Api
  class SessionsController < Api::ApiController
    swagger_controller :sessions, 'Sessions Management'

    swagger_api :create do
      summary 'Login a user based on their credentials'
      param :form, :email, :integer, :required, 'Email address'
      response :ok, 'Success'
    end
    def create
    end
end
commented

Just figured out that it works if I remove Swagger::Docs::Generator::set_real_methods