我已经尝试了很多方法,但我只是坚持到这里。
Grape API完全可以post
和get
,但是swagger-ui遇到了一些问题。
当我打开它时,我将swagger-ui
放在公共文件夹中。它扔了
Can't read swagger JSON from http://localhost:3000/v1/doc
这是 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