I am using Finatra on Scala 2.12 and I wanted to use Swagger.
I found this tutorial which is written for a previous library for swagger and finatra integration
https://medium.com/from-the-couch/writing-an-http-service-in-finatra-14239e9f3882
I am trying to modify the code of this tutorial to your library. Towards this I wrote the following code
build.sbt
val versions = new {
val finatra = "18.3.0"
val logback = "1.2.3"
val scalatest = "3.0.5"
val swagger = "1.0.5"
}
val p = (project in file(".")).settings(
name := "finatra-tut",
organization := "com.abhi",
scalaVersion := "2.12.5",
libraryDependencies ++= Seq(
"com.twitter" %% "finatra-http" % versions.finatra,
"ch.qos.logback" % "logback-classic" % versions.logback,
"org.scalatest" %% "scalatest" % versions.scalatest,
"io.paradoxical" %% "finatra-swagger" % versions.swagger
)
)
PingSwaggerDocument.scala
package com.abhi
import io.swagger.models.{Info, Swagger}
object PingSwaggerDocument extends Swagger
PingController.scala
package com.abhi
import com.twitter.finagle.http.Request
import com.twitter.finatra.http.Controller
import com.twitter.util.Future
import io.paradoxical.finatra.swagger.{SwaggerSupport}
class PingController extends Controller with SwaggerSupport {
implicit protected val swagger = PingSwaggerDocument
get("/ping", swagger { o =>
o.summary("This is GET PING request")
.tag("ping")
.responseWith[Pong](200, "The Pong Message")
}) { request: Request =>
info("ping")
val p = Pong("Result from GET /ping")
Future.value(p)
}
}
ExampleServer.scala
package com.abhi
import com.twitter.finagle.http.{Response, Request}
import com.twitter.finatra.http.HttpServer
import com.twitter.finatra.http.filters.{CommonFilters, LoggingMDCFilter, TraceIdMDCFilter}
import com.twitter.finatra.http.routing.HttpRouter
import io.paradoxical.finatra.swagger.SwaggerController
import io.swagger.models.Info
class ExampleServer extends HttpServer {
PingSwaggerDocument.info(new Info()
.description("Ping as a service")
.version("0.0.1")
.title("Pinged Piper")
)
override def defaultFinatraHttpPort = ":9999"
override def configureHttp(router: HttpRouter) = {
router
.filter[LoggingMDCFilter[Request, Response]]
.filter[TraceIdMDCFilter[Request, Response]]
.filter[CommonFilters]
.add(new SwaggerController(swagger = PingSwaggerDocument))
.add[PingController]
}
}
Models.scala
package com.abhi
case class Pong(message: String)
But this code doesn't compile. it gets an error
[error] /Users/abhsrivastava/IdeaProjects/finatra-tut/src/main/scala/com/abhi/PingController.scala:10:24: com.abhi.PingSwaggerDocument.type does not take parameters
[error] get("/ping", swagger { o =>
[error] ^
[error] one error found
[error] (Compile / compileIncremental) Compilation failed
What changes can I make here so that I can compile my code with your library. this will allow me to use Scala 2.12 along with Finatra and Swagger. the older library does not support Scala 2.12.
I am using Finatra on Scala 2.12 and I wanted to use Swagger.
I found this tutorial which is written for a previous library for swagger and finatra integration
https://medium.com/from-the-couch/writing-an-http-service-in-finatra-14239e9f3882
I am trying to modify the code of this tutorial to your library. Towards this I wrote the following code
build.sbt
PingSwaggerDocument.scala
PingController.scala
ExampleServer.scala
Models.scala
But this code doesn't compile. it gets an error
What changes can I make here so that I can compile my code with your library. this will allow me to use Scala 2.12 along with Finatra and Swagger. the older library does not support Scala 2.12.