richhollis / swagger-docs

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

Controller docs not being generated #151

Open PAMulligan opened 7 years ago

PAMulligan commented 7 years ago

I'm using Rails 4.2, and attempting to implement swagger-docs into my api. When I run rake swagger:docs, I get the application docs but none of the controller ones. Here's my controller:

class Api::V2::UsersController < ApplicationController
    before_action :authenticate_with_token!, only: [:update]
    respond_to :json
   swagger_controller :users, "User Management"

   swagger_api :create do
        summary "Creates a new User"
        param :form, :email, :string, :required, "Email address"
        param :form, :password, :string, :required, "Password"
        param :form, :password_confirmation, :string, :required, "Password confirmation"
        response :created
        response :unprocessable_entity
    end

    swagger_api :update do
        summary "Updates an existing User"
        param :path, :id, :integer, :required, "User Id"
        param :form, :email, :string, :optional, "Email address"
        param :form, :password, :string, :optional, "Password"
        param :form, :password_confirmation, :string, :optional, "Password confirmation"
        response :ok, "Success", :User
        response :unauthorized
        response :not_found
        response :unprocessable_entity
    end

    def create
        user = User.new(user_params) 
        if user.save
            render json: user, status: 201, location: [:api, user] 
        else
            render json: { errors: user.errors }, status: 422
        end
    end

    def update
        user = current_user

        if user.update(user_params)
            render json: user, status: 200, location: [:api, user] 
        else
            render json: { errors: user.errors }, status: 422
        end
    end

    private

        def user_params
            params.require(:user).permit(:email, :password, :password_confirmation) 
        end
end

We will also be using Azure's API management option, which allows you to point to a url to download a Swagger file, but I don't know where that would be or what the routing would look like.

PAMulligan commented 7 years ago

Is this product still supported?

toshitapandey commented 5 years ago

@PAMulligan Try running SD_LOG_LEVEL=1 rake swagger:docs, you'll get the reason of same.