我目前正在使用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")
发布于 2013-07-18 07:35:55
play2的swagger-core中的示例在play 2.1中工作得很好:
https://github.com/wordnik/swagger-core/tree/scala_2.10.0/samples/scala-play2
确保您拥有最新的swagger-play2模块:
val appDependencies: Seqsbt.ModuleID = Seq( "com.wordnik“%% "swagger-play2”% "1.2.4“)
它住在maven central
发布于 2015-08-25 15:51:54
GET /api-docs.json/items controllers.ApiHelpController.getResource(path = "/api-docs.json/items")
应该是
GET /api-docs.json/items controllers.ApiHelpController.getResource(path = "/items")
https://stackoverflow.com/questions/17529089
复制相似问题