0

I am testing the Swagger Codegen capabilities using the Pet Store demo application (http://petstore.swagger.io/) so I got myself a client generated for Scala.

While trying to test in a test class I got this compilation error:

[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

This is my test class:

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)
    }
  }
}

I have tried to import the classes indicated by the error message as well as coding a dummy implementation of ClientResponseReader. I am pretty noob with Scala and I don´t control much how the Implicits work.

Anyone can spot what I am missing here?

Thanks!

Victor
  • 2,450
  • 2
  • 23
  • 54
  • 1
    Which version of code gen are you using? you may want to try the latest master as there are a few enhancements/bug fixes to the scala generator. In 2.3.0, we try to consolidate `async-scala`, `scala`, `akka-scala` into a single scala generator. – William Cheng May 15 '17 at 03:43
  • Hi @wing328! Actually I was using the version deployed online (http://editor.swagger.io/#/) . I dunno what version is, but the used 'swagger-async-httpclient' is 0.3.5. I´ll try to download the 2.3.0 version of the codegen and try as you suggest. Thank you! – Victor May 15 '17 at 06:35
  • editor.swagger.io is not running the latest master. Usually it runs the latest stable version (which is 2.2.2 as of this writing). If you need further assistance, please report via https://github.com/swagger-api/swagger-codegen/issues/new – William Cheng May 15 '17 at 07:58

0 Answers0