1

I have used https://github.com/Apipie/apipie-rails for API docs.

This is working fine with rails 4 vestion after that I have updated my rails version to this rails 5.2.3 and it stoped working.

# app/controllers/api/v1/items_controller.rb
module Api
  module V1
    class ItemsController < API::V1::BaseApiController
      api :GET, '/items', 'All items'
      def index
        render json: @items
      end
    end
  end
end

I am getting this kind of error

Started GET "/api-doc/1.0/items/index.en.html" for ::1 at 2019-10-16 18:32:08 +0530
Processing by Apipie::ApipiesController#index as HTML
Parameters: {"version"=>"1.0", "resource"=>"items", "method"=>"index.en.html"}
Rendering /Users/sc/.rvm/gems/ruby-2.6.3/gems/apipie-rails-0.5.16/app/views/apipie/apipies/apipie_404.html.erb within layouts/apipie/apipie
Rendered /Users/sc/.rvm/gems/ruby-2.6.3/gems/apipie-rails-0.5.16/app/views/apipie/apipies/apipie_404.html.erb within layouts/apipie/apipie (2.1ms)
Completed 404 Not Found in 659ms (Views: 13.5ms | ActiveRecord: 0.0ms)
Pooja Mokariya
  • 1,970
  • 5
  • 21
  • 46
  • your index returns a json response but your requests is `.html`, also, I don't see how you do the request and how do you hande that `.en` from the url – arieljuod Oct 16 '19 at 13:37
  • This link is generated from the Apipie documentation, right? It uses the default locale which is `en`: do you have defined that locale? The error can only be caused when either the api-version, resource, method or language is not found in the api-documentation. – nathanvda Oct 16 '19 at 14:01

2 Answers2

1

Just add to "config/initialize/apipie.rb" one line of code:

config.translate = false
סטנלי גרונן
  • 2,917
  • 23
  • 46
  • 68
Renat
  • 53
  • 1
  • 6
0

In your config/initializers/apipie.rb add config.languages = ['en'] to the config block. So it should look something like this:

Apipie.configure do |config|
  config.app_name                = "MyApp"
  config.api_base_url            = "/api"
  config.doc_base_url            = "/apipie"
  config.languages = ['en']
  config.api_controllers_matcher = "#{Rails.root}/app/controllers/api/**/*.rb"
end

Then restart your rails server.

Mike Gorski
  • 1,228
  • 1
  • 8
  • 13