Reputation: 4634
I am a beginner in Grape
, I want to show my api list by using swagger-ui
.
I put swagger html in public/swagger
, and I access localhost:3000/swagger
However, it keep showing 404 not found
. I thought it's causing by Grape configuration.
Here is api.rb
#app/api/twitter/api/api.rb
require 'grape'
module Twitter
class API < Grape::API
version 'v1', using: :header, vendor: 'twitter'
format :json
prefix :api
add_swagger_documentation
resource :statuses do
desc 'Return a public timeline.'
get :public_timeline do
Status.limit(20)
end
end
end
end
Upvotes: 0
Views: 896
Reputation: 769
You don't have to do it manually by putting swagger html somewhere.
You could use gem grape-swagger provided by Grape team, add two lines in you config.ru
.
require 'grape-swagger'
module API
class Root < Grape::API
format :json
...
add_swagger_documentation
end
end
then you could access swagger doc at http://localhost:3000/swagger_doc
Upvotes: 1