1
我第一次使用Swagger,並且無法獲取單個終端點在資源內的json響應中顯示的詳細信息。Swagger不顯示資源中的單個終端點
,簡體中文,我有:
# api.rb
require 'grape-swagger'
module API
class Base < Grape::API
version 'v1', using: :path
format :json
resource :items do
desc 'Operations about items'
get '/:id' do
desc 'retrieve data for a single item'
# do something here
end
end
end
在輸出中,我希望看到這樣的:
{
"apiVersion": "0.1",
"swaggerVersion": "1.2",
"produces":
[
"name": "application/json",
],
"resources":
[
{
"name": "items",
"description": "Operations about items",
"apis": [
{
"path": "/items/:id.{format}",
"description": "retrieve data for a single item"
}
]
}
]
}
相反,我得到:
{
"apiVersion": "0.1",
"swaggerVersion": "1.2",
"produces":
[
"application/json"
],
"apis":
[
{
"path": "/items.{format}",
"description": "Operations about items"
}
]
}
我在做什麼錯誤? (使用Rails 4.2,紅寶石2.1)
感謝。哪些需要放在示例代碼中?我得到一個項目 – CoupDeMistral
的單一常量錯誤'Items'被假定爲類,它在'resource'方法之前。通常每個資源都被分成它自己的文件,並且像「軌道控制器」一樣從「Base」繼承。 – jtzero