我目前正在使用 Swagger 记录 Play 2.1 应用程序。我设法让它编译成功,但它没有显示任何关于生成的 JSON 的信息。
本地主机:9000/api-docs.json
{
apiVersion: "0.1",
swaggerVersion: "1.1",
basePath: "http://localhost:9000"
}
本地主机:9000/api-docs.json/items
{
code: 500,
message: "api listing for path /api-docs.json/items not found",
type: "unknown"
}
这是控制器对象的注释:
@Api(value = "/items", listingPath = "/api-docs.{format}/items", description = "Operations about Items")
object ItemController extends Controller {
这些是控制器方法的注释:
@ApiOperation(value = "Gets the item of a specific ID", notes = "Returns an Item", responseClass = "Item", httpMethod = "GET")
@ApiErrors(Array(
new ApiError(code = 400, reason = "Invalid ID supplied"),
new ApiError(code = 404, reason = "Item not found")))
def get(@ApiParam(value="Id of the Item to Fetch")@PathParam("id") id: Long) = Action{ request => controller.get(id: Long) }
这些是 application.conf 上所需的配置:
api.version="0.1"
swagger.api.basepath="http://localhost:9000"
#swagger.security.filter="security.AuthorizationFilter"
上面显示的代码遵循 Swagger 的文档提供的示例应用程序。您知道 Play 2.1 上的任何工作示例吗?关于什么是错的或缺少什么的任何线索?
提前致谢。
编辑:路由文件部分:
GET /api-docs.json controllers.ApiHelpController.getResources
GET /api-docs.json/items controllers.ApiHelpController.getResource(path = "/api-docs.json/items")