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

1.0: 0 processed / 1 skipped #168

Open
flaviolpgjr opened this issue Aug 31, 2017 · 8 comments
Open

1.0: 0 processed / 1 skipped #168

flaviolpgjr opened this issue Aug 31, 2017 · 8 comments

Comments

@flaviolpgjr
Copy link

Hi, can anyone help me please, already tried in all possible ways, but this is returning the same error: 1.0: 0 processed / 4 skipped, when running :

SD_LOG_LEVEL=1 rake swagger:docs

swagger-docs.rb:

# config/initializers/swagger-docs.rb
Swagger::Docs::Config.base_api_controller = ActionController::API
Swagger::Docs::Config.register_apis({
  "1.0" => {
    # location where our api doc files will be generated, as of now we will store files under public directory
    :api_file_path => "public/",
    # base path url of our application
    # while using production mode, point it to production url
    :base_path => "http://localhost:3000",
    # setting this option true tells swagger to clean all files generated in api_file_path directory before any files are generated
    :clean_directory => true,
    # As we are using Rails-API, our ApplicationController inherits ActionController::API instead of ActionController::Base
    # Hence, we need to add ActionController::API instead of default ActionController::Base
    :base_api_controller => ActionController::API,
    :attributes => {
      :info => {
        "title" => "Swagger Demo",
        "description" => "How Swagger works",
        "contact" => "[email protected]",
        "license" => "Apache 2.0",
        "licenseUrl" => "http://www.apache.org/licenses/LICENSE-2.0.html"
      }
    }
  }
})

users_controller.rb

class Api::V1::UsersController < ApplicationController
  before_action :set_api_v1_user, only: [:show, :update, :destroy]

  swagger_controller :users, "User Management"

   # POST /users
  swagger_api :create do
    summary "To create user"
    notes "Implementation notes, such as required params, example queries for apis are written here."
    param :form, "user[name]", :string, :required, "Name of user"
    param :form, "user[age]", :integer, :optional, "Age of user"
    param_list :form, "user[status]", :string, :required, "Status of user, can be active or inactive"
    response :success
    response :unprocessable_entity
    response :500, "Internal Error"
  end

  # POST /api/v1/users
  def create
    @api_v1_user = Api::V1::User.new(api_v1_user_params)

    if @api_v1_user.save
      render json: @api_v1_user, status: :created, location: @api_v1_user
    else
      render json: @api_v1_user.errors, status: :unprocessable_entity
    end
  end
end
@zhandao
Copy link

zhandao commented Sep 8, 2017

try :base_api_controller => ActionController

@flaviolpgjr
Copy link
Author

Thank you very much, I have decided to add in config/routes.rb

namespace :api do
    namespace :v1 do
      resources :users
    end
  end

@fercreek
Copy link

#147 (comment)

I solved the issue in this way

@flaviolpgjr
Copy link
Author

Thank you Friends

@msdundar
Copy link

same issue here! I'm using Rails 5 API, and workarounds are not working.

@fercreek
Copy link

@msdundar did you try with my solution?

@msdundar
Copy link

@fercreek yes it has fixed the issue! thanks.

@fercreek
Copy link

@msdundar great! I'm glad for you.
@richhollis can you check if this is the best solution for this issue?

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