我正在使用 Pet Store 演示应用程序 ( http://petstore.swagger.io/ ) 测试 Swagger Codegen 功能,因此我为自己获得了一个为 Scala 生成的客户端。
在尝试在测试类中进行测试时,我得到了这个编译错误:
[error] C:\code\scala\async-scala-client\src\test\scala\io.swagger.client\SwaggerClientSuite.scala:37: No ClientResponseReader found for type io.swagger.client.model.Inline_response_200_1. Try to implement an implicit ClientResponseReader for this type, or perhaps you're just missing an import like ClientResponseReader._.
[error] val response = swaggerClient.pet.getPetById(1l)
[error] ^
[error] one error found
[error] (test:compileIncremental) Compilation failed
这是我的测试课:
package io.swagger.client
import com.wordnik.swagger.client.{SwaggerConfig}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.FunSuite
import scala.util.{Failure, Success}
import scala.concurrent.ExecutionContext.Implicits._
@RunWith(classOf[JUnitRunner])
class SwaggerClientSuite extends FunSuite {
val swaggerClient = new SwaggerClient(SwaggerConfig.forUrl(new java.net.URI("http://petstore.swagger.io/")))
test("dummy") {
val response = swaggerClient.pet.getPetById(1l)
response onComplete {
case Success(response) => println("Success: " + response)
case Failure(t) => println("An error has occured: " + t.getMessage)
}
}
}
我尝试导入错误消息指示的类以及编写ClientResponseReader
. 我对 Scala 非常陌生,而且我不太控制 Implicits 的工作方式。
任何人都可以发现我在这里缺少什么?
谢谢!