title: How to fix the Routes not found error in server error in swagger-blocks gem, even thought the routes exists in routes.rb
body: <p>I am using swagger-blocks gem for API documentation. And when I try to test the API from the swagger UI it is giving me a response with status <strong>404</strong>, and in the server it is saying.</p>
  
  <pre><code>ActionController::RoutingError (No route matches [POST] "/api/v1/vendors"):
  </code></pre>
  
  <p>also the output of <strong>rake routes | grep vendors</strong></p>
  
  <pre><code>api_v1_vendors POST   /api/v1/vendors(.:format)                             
  </code></pre>
  
  <p>The swagger UI is giving me the curl command.</p>
  
  <pre><code>curl -X POST "http://localhost:3000/api/v1/vendors" -H "accept: application/json" -H "Content-Type: application/json" -d "{ \"w_flow_id\": \"112268_1\", \"service_type\": { \"translation\": [], \"editing\": [], \"lqa_proofreading\": [] }, \"vendors\": [ { \"email\": \"admin@example.com\", \"first_name\": \"admin\", \"last_name\": \"admin\" } ]}"
  </code></pre>
  
  <p>which on running on the terminal is giving me the response</p>
  
  <pre><code>{"error":"Invalid authentication.","status":401}
  </code></pre>
  
  <p>which was the expected output in swagger UI.</p>
  
  <p>In <strong>/api/v1/vendors_controller.rb</strong> I have define the swagger path like</p>
  
  <pre><code>  swagger_path '/vendor_corrals' do
      operation :post do
        key :summary, 'Add vendor to the corral'
        key :description, 'Post the vendor with given params to vendor corral for particular workflow'
        # key :consumes, ['application/json']
        key :produces, ['application/json']
        key :tags, ['Vendor Corral']
  
        security 'Authentication-Token': []
  
        parameter name: :body, in: :body, required: true do
          schema type: :object do
            property :w_flow_id, type: :string, example: '112268_1'
            property :service_type, type: :object do
              property :translation, type: :array, example: [] do
                items type: :string
              end
              property :editing, type: :array, example: [] do
                items type: :string
              end
              property :lqa_proofreading, type: :array, example: [] do
                items type: :string
              end
            end
            property :vendors, type: :array do
              items type: :object do
                property :email, type: :string, example: 'admin@example.com'
                property :first_name, type: :string, example: 'admin'
                property :last_name, type: :string, example: 'admin'
              end
            end
          end
        end
  
        response 200 do
          key :description, 'Vendor Corral Response'
        end
  
        response 401 do
          key :description, 'Not Authorized'
        end
  
        response 422 do
          key :description, 'Unprocessable Entry'
        end
  
        response 500 do
          key :description, 'Internal Server Error'
        end
      end
    end
  </code></pre>
  
  <p>In <strong>apidocs_controller.rb</strong> I have</p>
  
  <pre><code>class ApidocsController &lt; ApplicationController
    include Swagger::Blocks
    skip_before_action :authenticate_user!, only: [:index]
  
    swagger_root do
      key :swagger, '2.0'
      info do
        key :version, 'v1'
        key :title, 'R3 API Documentation'
      end
  
      key :host, 'localhost:3000'
      key :basePath, '/api/v1'
      key :schemes, [ 'http', 'https' ]
      key :consumes, ['application/json']
      key :produces, ['application/json']
  
      security_definition :'Authentication-Token', type: :apiKey do
        key :name, :'Authentication-Token'
        key :in, :header
      end
    end
  
    SWAGGERED_CLASSES = [
      Api::V1::VendorsController,
      self
    ].freeze
  
    def index
      render json: Swagger::Blocks.build_root_json(SWAGGERED_CLASSES)
    end
  end
  </code></pre>
  
  <p>Can anyone explain to me, why I am getting this behavior from swagger-blocks and what is the best practice to follow while using swagger-blocks gem?</p>