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

How Can i User Swagger docs for devise sessions controller #163

Open
vishaltps opened this issue Apr 8, 2017 · 4 comments
Open

How Can i User Swagger docs for devise sessions controller #163

vishaltps opened this issue Apr 8, 2017 · 4 comments

Comments

@vishaltps
Copy link

I used rails swagger gem for documenting my rails api. it is working fine for all controller . but it is not working for devise::sessionsController.

Here is my code ,
I added 2 controller as base in my api
swagger_docs.rb
def self.base_api_controller [ActionController::API,ActionController::Base] end

In sessions_controller.rb

` include Swagger::Docs::Methods
swagger_controller :sessions, "Login"

swagger_api :create do
summary "Generate Access Token"
param :form, 'user[email]', :string, :required, "Email of user"
param :form, 'user[password]', :string ,:required, "Password of user"
response :unauthorized
response :not_acceptable
response :not_acceptable
response :not_found
end`

There is no any error. so my code is not effecting in sessions controller . what is the solution ? Thank you in advance .

@Uysim
Copy link

Uysim commented Aug 30, 2017

Found Solution Yet?

@vishaltps
Copy link
Author

Not yet

@SergeyMell
Copy link

SergeyMell commented Feb 14, 2018

I managed to fix this issue and successfully generated swagger docs for devise controllers. (Actually, I used devise_token_auth but the solution is the same)

# Overriden devise controller
class Devise::RegistrationsController < DeviseTokenAuth::RegistrationsController

  include Swagger::Docs::Methods

  swagger_controller :registrations, 'Registration Management'

  swagger_api :create do
    summary 'Sign Up'
    param :query, :title, :string, :required, 'Band Title'
    param :query, :page, :integer, :optional, 'Pagination page number'
    param :query, :per_page, :integer, :optional, 'Number of items per page'
  end

  def create
    super
  end

end
# initializers/swagger_docs.rb
Swagger::Docs::Config.register_apis({
                                      '1.0' => {
                                        controller_base_path: '',
                                        api_file_path: 'public/apidocs',
                                        base_api_controllers: [ActionController::Base, Devise::RegistrationsController],
                                        base_path: Rails.application.config.domain,
                                        clean_directory: true
                                      }
                                    })

@gisilbek
Copy link

Hi sergeymell How did you manage to implement swagger with devise? I couldn't, the message tells me that I am not authorized.

Thanks for your answer

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

4 participants