2

I've been tried a lots ways, but I just stuck here.

Grape API can do post and get perfectly, but the swagger-ui encountered some problems.

I put swagger-ui in public folder, when I open it. It threw

Can't read swagger JSON from http://localhost:3000/v1/doc

Here is api.rb

module FruitAPI
  class API < Grape::API 
    version 'v1', using: :header, vendor: 'fruit_api'
    format :json
    prefix :api
    ...
    add_swagger_documentation(
      basd_path: "/v1",  #Swagger的base url
      mount_path: 'doc', 
      info: {
        title: 'Fruit API', 
        description: "A description of the API."
        },
        hide_documentation_path: true,
        hide_format: true,
        include_base_url: true
        )
  end
end
rj487
  • 4,476
  • 6
  • 47
  • 88

0 Answers0