我目前正在使用Swagger记录Play 2.1应用程序。我已经设法成功编译它,但它没有显示有关生成的JSON的任何信息。
本地主机:9000 / API-docs.json
{
apiVersion: "0.1",
swaggerVersion: "1.1",
basePath: "http://localhost:9000"
}
本地主机:9000 / API-docs.json /项
{
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")
答案 0 :(得分:0)
swagger-core for play2中的样本在播放2.1时运行良好:
https://github.com/wordnik/swagger-core/tree/scala_2.10.0/samples/scala-play2
看到你有最新的swagger-play2模块:
val appDependencies:Seq [sbt.ModuleID] = Seq( “com.wordnik”%%“swagger-play2”%“1.2.4”)
住在maven中心