Add Swagger support for Finatra (1.6 and 2.2.0) web framework.
It requires Java 8 from version 0.6.0.
repositories {
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
compile "com.github.xiaodongw:swagger-finatra_2.10:0.7.2"
compile "com.github.xiaodongw:swagger-finatra_2.11:0.7.2"
resolvers += "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/releases/"
libraryDependencies += "com.github.xiaodongw" %% "swagger-finatra" % "0.7.2"
object SampleSwagger extends Swagger
class SampleController extends Controller with SwaggerSupport {
implicit protected val swagger = SampleSwagger
getWithDoc("/students/:id") { o =>
o.summary("Read the detail information about the student")
.tag("Student")
.routeParam[String]("id", "the student id")
.responseWith[Student](200, "the student details")
.responseWith(404, "the student is not found")
} { request =>
...
}
object SampleApp extends HttpServer {
val info = new Info()
.description("The Student / Course management API, this is a sample for swagger document generation")
.version("1.0.1")
.title("Student / Course Management API")
SampleSwagger.info(info)
override def configureHttp(router: HttpRouter) {
router
.add[WebjarsController]
.add(new SwaggerController(swagger = SampleSwagger))
...
}
}
Swagger API document: http:https://localhost:8888/api-docs/model
Swagger UI: http:https://localhost:8888/api-docs/ui
Previous version of Finatra (1.6) is also supported, Check here for the guide.