我正在使用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的工作方式。
任何人都可以发现我在这里缺少的东西吗?
谢谢!