试图让游戏框架v2.4大摇大摆

时间:2016-03-09 15:34:58

标签: swagger playframework-2.3 swagger-ui swagger-2.0

我试图让swagger / swagger-ui与play framework v2.4(java app)一起工作。我做了以下事情:

a)将swagger-ui dist目录复制到/ public /目录, b)将index.html作为swagger.scala.html复制到app / views目录(同时添加play import语句,修改对静态资源的引用以及JS函数), c)对我的路线文件进行了更改(复制如下)和 d)添加了一个scala控制器(用于招摇)。

如果我错过任何步骤,有什么想法吗?

当我尝试编译应用程序时,我收到了下面复制的错误(我的印象是ApiHelpController是play-swagger模块的一部分,我不需要复制它。如果我没有关注,请分享步骤正确。

错误:

[error] /home/user/testapp/conf/routes:165: object ApiHelpController is not a member of package controllers
[error] Note: class ApiHelpController exists, but it has no companion object.
[error] GET         /api-docs.json               controllers.ApiHelpController.getResources
[error] /home/user/testapp/conf/routes:167: object ApiHelpController is not a member of package controllers
[error] Note: class ApiHelpController exists, but it has no companion object.
[error] GET         /api-docs.json/hello         controllers.ApiHelpController.getResource(path = "/accesses")
[error] two errors found
[error] (compile:compile) Compilation failed

路由文件

GET         /swagger                     @controllers.Application.swagger
GET         /api-docs.json               @controllers.ApiHelpController.getResources

GET         /api-docs.json/accesses         @controllers.ApiHelpController.getResource(path = "/accesses")

build.sbt

libraryDependencies ++= Seq(
  "io.swagger" %% "swagger-play2" % "1.5.1",
  "org.webjars" % "swagger-ui" % "2.1.8-M1"
)

application.conf

扬鞭

play.modules.enabled += "play.modules.swagger.SwaggerModule"

api.version="1.0"
swagger.api.basepath="http://localhost:9000"

控制器

package controllers


import play.api.mvc._

class Application extends Controller {

    def swagger = Action {
      request =>
        Ok(views.html.swagger())
    }

  }

更新 在认识到在v2.4中,我可以在路径文件中的控制器之前使用带有“@”的依赖注入路由器(但是我必须使用scala类而不是对象),我能够移动过去上一期。我现在收到以下错误:

[error] /home/user/testapp/app/controllers/TestController.java:40: error: cannot find symbol
[error] @Api(value = "/accesses", description = "Test for Accesses")
[error]  ^

另一次更新 第二个问题是由控制器中缺少import语句引起的。

在控制器中添加以下内容解决了它:

import io.swagger.annotations.*;

0 个答案:

没有答案