我正在尝试使用葡萄招摇的创意为我的葡萄API创建自动生成的文档。使用葡萄招摇的API文档问题
使用'grape'gem我创建了几个API。
实施例:
http://localhost:9292/api/v1/charges
此API工作正常。
以下文档'grape-sagger',我无法正确生成API文档。
我的步骤:
1)I在Gemfile中
gem 'grape-swagger'
2的下方加)我还通过在config.ru加入下面使用的机架CORS启用CORS
require 'rack/cors'
use Rack::Cors do
allow do
origins '*'
resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
end
end
还在gemfile中添加如下。
宝石 '机架CORS',:需要=> '机架/ CORS'
3)此外,我下面加在端部在我的API类
add_swagger_documentation
但是当我运行http://localhost:9292/api/v1/swagger_doc时,我没有得到正确的路径。 我需要API路径,如http://localhost:9292/api/v1/charges,但它返回为http://localhost:9292/api/v1/swagger_doc/charges
是否需要设置其他配置?
谢谢萨钦!如果我添加hide_documentation_path:true,swagger_doc的API路径将被删除。但我担心,我没有得到本地主机:9292/ap1/v1 /收费,因为它返回localhost:9292/api/v1/swagger /收费。有什么出路或者我犯了什么错误? – Kirity