【发布时间】:2015-10-28 14:26:56
【问题描述】:
gem 'swagger-docs'
rake swagger:文档
轨道服务器
我的控制器在 app/controller/API/user_controller.rb
module Api
class UserController < ApplicationController
swagger_controller :users, "Users"
swagger_api :create do
summary "Creates a new User"
param :form, :name, :string, :required, "Name"
response :unauthorized
response :not_acceptable
end
def create
render json: {message: "success"},status: 401
end
end
结束
但是当我进入时
http://localhost:3000/api-docs.json
它无法正常工作。它不能显示正确的布局。而不是它给出的 json 代码。
{
"apiVersion": "1.0",
"swaggerVersion": "1.2",
"basePath": "/",
"apis": [
{
"path": "api/user.{format}",
"description": "Users"
}
]
}
【问题讨论】:
标签: ruby-on-rails ruby api swagger rails-api