From 9aa3fc03ed2bc6ac51c18cf25d111db611cd8f78 Mon Sep 17 00:00:00 2001 From: rayyildiz Date: Sat, 22 Aug 2015 14:45:21 +0300 Subject: [PATCH 1/6] scalaz repository added --- play-2.4/swagger-play2/project/Build.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/play-2.4/swagger-play2/project/Build.scala b/play-2.4/swagger-play2/project/Build.scala index d78a5f5..ebfdd33 100644 --- a/play-2.4/swagger-play2/project/Build.scala +++ b/play-2.4/swagger-play2/project/Build.scala @@ -76,6 +76,7 @@ object ApplicationBuild extends Build { "sonatype-snapshots" at "https://oss.sonatype.org/content/repositories/snapshots", "sonatype-releases" at "https://oss.sonatype.org/content/repositories/releases", "java-net" at "http://download.java.net/maven/2", + "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases", "Typesafe Snapshots" at "http://repo.typesafe.com/typesafe/snapshots/", "Typesafe Repository" at "http://repo.typesafe.com/typesafe/releases/")) } From 47947ea47573bdab6ed016283b0fb067a87a2bd0 Mon Sep 17 00:00:00 2001 From: rayyildiz Date: Sat, 22 Aug 2015 14:53:36 +0300 Subject: [PATCH 2/6] scalaz repository added --- play-2.4/swagger-play2/build.sbt | 1 + 1 file changed, 1 insertion(+) create mode 100644 play-2.4/swagger-play2/build.sbt diff --git a/play-2.4/swagger-play2/build.sbt b/play-2.4/swagger-play2/build.sbt new file mode 100644 index 0000000..d64cec1 --- /dev/null +++ b/play-2.4/swagger-play2/build.sbt @@ -0,0 +1 @@ +resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases" From 500b12c85295680014b2256b50735a17ede5f19d Mon Sep 17 00:00:00 2001 From: Ramazan Ayyildiz Date: Thu, 7 Sep 2017 15:53:22 +0200 Subject: [PATCH 3/6] refactored deprecated methods --- .../play/modules/swagger/PlayApiScanner.scala | 22 +++++++++---------- .../play/modules/swagger/SwaggerPlugin.scala | 22 +++++++++---------- play-2.6/swagger-play2/build.sbt | 1 + .../test/testdata/CatController.scala | 7 +++--- .../test/testdata/DocumentController.scala | 9 ++++---- .../test/testdata/DogController.scala | 7 ++++-- .../test/testdata/FlyController.scala | 6 +++-- .../testdata/PointOfInterestController.scala | 8 ++++--- 8 files changed, 46 insertions(+), 36 deletions(-) diff --git a/play-2.6/swagger-play2/app/play/modules/swagger/PlayApiScanner.scala b/play-2.6/swagger-play2/app/play/modules/swagger/PlayApiScanner.scala index 779ccc0..acec8cb 100644 --- a/play-2.6/swagger-play2/app/play/modules/swagger/PlayApiScanner.scala +++ b/play-2.6/swagger-play2/app/play/modules/swagger/PlayApiScanner.scala @@ -19,22 +19,22 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { private def updateInfoFromConfig(swagger: Swagger): Swagger = { - var info = new Info() + val info = new Info() val playSwaggerConfig = PlayConfigFactory.getConfig if (StringUtils.isNotBlank(playSwaggerConfig.description)) { - info.description(playSwaggerConfig.description); + info.description(playSwaggerConfig.description) } if (StringUtils.isNotBlank(playSwaggerConfig.title)) { - info.title(playSwaggerConfig.title); + info.title(playSwaggerConfig.title) } else { // title tag needs to be present to validate against schema - info.title(""); + info.title("") } if (StringUtils.isNotBlank(playSwaggerConfig.version)) { - info.version(playSwaggerConfig.version); + info.version(playSwaggerConfig.version) } if (StringUtils.isNotBlank(playSwaggerConfig.termsOfServiceUrl)) { @@ -43,12 +43,12 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { if (playSwaggerConfig.contact != null) { info.contact(new Contact() - .name(playSwaggerConfig.contact)); + .name(playSwaggerConfig.contact)) } if (playSwaggerConfig.license != null && playSwaggerConfig.licenseUrl != null) { info.license(new License() .name(playSwaggerConfig.license) - .url(playSwaggerConfig.licenseUrl)); + .url(playSwaggerConfig.licenseUrl)) } swagger.info(info) } @@ -60,7 +60,7 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { } updateInfoFromConfig(swagger) swagger.host(playSwaggerConfig.host) - swagger.basePath(playSwaggerConfig.basePath); + swagger.basePath(playSwaggerConfig.basePath) } @@ -72,7 +72,7 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { Logger("swagger").info("ControllerScanner - looking for controllers with API annotation") - var routes = RouteFactory.getRoute().getAll().toList + val routes = RouteFactory.getRoute().getAll().toList // get controller names from application routes val controllers = routes.map { case (_, route) => @@ -80,7 +80,7 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { }.distinct - var list = controllers.collect { + val list = controllers.collect { case className: String if { try { SwaggerContext.loadClass(className).getAnnotation(classOf[Api]) != null @@ -100,7 +100,7 @@ class PlayApiScanner() extends Scanner with SwaggerConfig { } override def getPrettyPrint(): Boolean = { - true; + true } override def setPrettyPrint(x: Boolean) {} diff --git a/play-2.6/swagger-play2/app/play/modules/swagger/SwaggerPlugin.scala b/play-2.6/swagger-play2/app/play/modules/swagger/SwaggerPlugin.scala index ddbf73f..2b51209 100644 --- a/play-2.6/swagger-play2/app/play/modules/swagger/SwaggerPlugin.scala +++ b/play-2.6/swagger-play2/app/play/modules/swagger/SwaggerPlugin.scala @@ -39,45 +39,45 @@ class SwaggerPluginImpl @Inject()(lifecycle: ApplicationLifecycle, router: Route val config = app.configuration logger.info("Swagger - starting initialisation...") - val apiVersion = config.getString("api.version") match { + val apiVersion = config.getOptional[String]("api.version") match { case None => "beta" case Some(value) => value } - val basePath = config.getString("swagger.api.basepath") + val basePath = config.getOptional[String]("swagger.api.basepath") .filter(path => !path.isEmpty) .getOrElse("/") - val host = config.getString("swagger.api.host") + val host = config.getOptional[String]("swagger.api.host") .filter(host => !host.isEmpty) .getOrElse("localhost:9000") - val title = config.getString("swagger.api.info.title") match { + val title = config.getOptional[String]("swagger.api.info.title") match { case None => "" case Some(value)=> value } - val description = config.getString("swagger.api.info.description") match { + val description = config.getOptional[String]("swagger.api.info.description") match { case None => "" case Some(value)=> value } - val termsOfServiceUrl = config.getString("swagger.api.info.termsOfServiceUrl") match { + val termsOfServiceUrl = config.getOptional[String]("swagger.api.info.termsOfServiceUrl") match { case None => "" case Some(value)=> value } - val contact = config.getString("swagger.api.info.contact") match { + val contact = config.getOptional[String]("swagger.api.info.contact") match { case None => "" case Some(value)=> value } - val license = config.getString("swagger.api.info.license") match { + val license = config.getOptional[String]("swagger.api.info.license") match { case None => "" case Some(value)=> value } - val licenseUrl = config.getString("swagger.api.info.licenseUrl") match { + val licenseUrl = config.getOptional[String]("swagger.api.info.licenseUrl") match { // licenceUrl needs to be a valid URL to validate against schema case None => "http://licenseUrl" case Some(value)=> value @@ -110,7 +110,7 @@ class SwaggerPluginImpl @Inject()(lifecycle: ApplicationLifecycle, router: Route val routesFile = config.underlying.hasPath("play.http.router") match { case false => "routes" - case true => config.getString("play.http.router") match { + case true => config.getOptional[String]("play.http.router") match { case None => "routes" case Some(value)=> playRoutesClassNameToFileName(value) } @@ -147,7 +147,7 @@ class SwaggerPluginImpl @Inject()(lifecycle: ApplicationLifecycle, router: Route val route = new RouteWrapper(routesRules) RouteFactory.setRoute(route) - app.configuration.getString("swagger.filter") match { + app.configuration.getOptional[String]("swagger.filter") match { case Some(e) if (e != "") => { try { FilterFactory setFilter SwaggerContext.loadClass(e).newInstance.asInstanceOf[SwaggerSpecFilter] diff --git a/play-2.6/swagger-play2/build.sbt b/play-2.6/swagger-play2/build.sbt index a7ff1d0..c8a02af 100644 --- a/play-2.6/swagger-play2/build.sbt +++ b/play-2.6/swagger-play2/build.sbt @@ -8,6 +8,7 @@ scalaVersion := "2.11.8" crossScalaVersions := Seq(scalaVersion.value, "2.12.2") libraryDependencies ++= Seq( + guice, "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.8.9", "org.slf4j" % "slf4j-api" % "1.7.21", "io.swagger" % "swagger-core" % "1.5.16", diff --git a/play-2.6/swagger-play2/test/testdata/CatController.scala b/play-2.6/swagger-play2/test/testdata/CatController.scala index 0f7b218..9a22aaa 100644 --- a/play-2.6/swagger-play2/test/testdata/CatController.scala +++ b/play-2.6/swagger-play2/test/testdata/CatController.scala @@ -1,11 +1,12 @@ package testdata -import io.swagger.annotations._ +import javax.inject.Inject -import play.api.mvc.{Action, Controller} +import io.swagger.annotations._ +import play.api.mvc._ @Api(value = "/apitest/cats", description = "play with cats") -class CatController extends Controller { +class CatController @Inject() () extends InjectedController { @ApiOperation(value = "addCat1", httpMethod = "PUT", diff --git a/play-2.6/swagger-play2/test/testdata/DocumentController.scala b/play-2.6/swagger-play2/test/testdata/DocumentController.scala index db41c33..2233990 100644 --- a/play-2.6/swagger-play2/test/testdata/DocumentController.scala +++ b/play-2.6/swagger-play2/test/testdata/DocumentController.scala @@ -1,12 +1,13 @@ package testdata -import io.swagger.annotations._ +import javax.inject.Inject -import play.api.mvc.Controller -import play.mvc.{Result, Http} +import io.swagger.annotations._ +import play.api.mvc.{InjectedController} +import play.mvc.{Http, Result} @Api(value = "/apitest/document", description = "documents", tags = Array("Documents")) -class DocumentController extends Controller { +class DocumentController @Inject() () extends InjectedController { @ApiOperation(value = "Register acceptance of a file on a settlement", notes = "Accept file", diff --git a/play-2.6/swagger-play2/test/testdata/DogController.scala b/play-2.6/swagger-play2/test/testdata/DogController.scala index 15b82a5..5b3ea17 100644 --- a/play-2.6/swagger-play2/test/testdata/DogController.scala +++ b/play-2.6/swagger-play2/test/testdata/DogController.scala @@ -1,7 +1,10 @@ package testdata +import javax.inject.Inject + import io.swagger.annotations._ -import play.api.mvc.{Action, Controller} +import play.api.mvc.{Action, Controller, InjectedController} + import scala.concurrent.Future // todo - test for these @@ -18,7 +21,7 @@ import scala.concurrent.Future )) ) ) -object DogController extends Controller { +class DogController @Inject() () extends InjectedController { @ApiOperation(value="addDog0") def add0(id:String) = Action { diff --git a/play-2.6/swagger-play2/test/testdata/FlyController.scala b/play-2.6/swagger-play2/test/testdata/FlyController.scala index 78e80c7..31de77e 100644 --- a/play-2.6/swagger-play2/test/testdata/FlyController.scala +++ b/play-2.6/swagger-play2/test/testdata/FlyController.scala @@ -1,8 +1,10 @@ package testdata -import play.api.mvc.{Action, Controller} +import javax.inject.Inject -object FlyController extends Controller { +import play.api.mvc.{InjectedController} + +class FlyController @Inject() () extends InjectedController { def list = Action { request => diff --git a/play-2.6/swagger-play2/test/testdata/PointOfInterestController.scala b/play-2.6/swagger-play2/test/testdata/PointOfInterestController.scala index 46f6805..fed1fc9 100644 --- a/play-2.6/swagger-play2/test/testdata/PointOfInterestController.scala +++ b/play-2.6/swagger-play2/test/testdata/PointOfInterestController.scala @@ -1,11 +1,13 @@ package testdata +import javax.inject.Inject + import io.swagger.annotations._ -import play.api.mvc.Controller -import play.mvc.{Result, Http} +import play.api.mvc.{InjectedController} +import play.mvc.{Http, Result} @Api(value = "/apitest/pointsofinterest", description = "Points of interest") -class PointOfInterestController extends Controller { +class PointOfInterestController @Inject() () extends InjectedController { @ApiOperation(value = "Get points of interest", notes = "Returns points of interest", From 0045e9138742255f16eb39fe85b5c36bf101835a Mon Sep 17 00:00:00 2001 From: rayyildiz Date: Thu, 7 Sep 2017 15:56:44 +0200 Subject: [PATCH 4/6] sbt upgrade to 0.13.15 --- play-2.6/swagger-play2/project/build.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/play-2.6/swagger-play2/project/build.properties b/play-2.6/swagger-play2/project/build.properties index 27e88aa..64317fd 100644 --- a/play-2.6/swagger-play2/project/build.properties +++ b/play-2.6/swagger-play2/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.13 +sbt.version=0.13.15 From 000c1ae1f879b0939b9becf334e9eafbc240ff09 Mon Sep 17 00:00:00 2001 From: rayyildiz Date: Thu, 7 Sep 2017 16:00:33 +0200 Subject: [PATCH 5/6] build error --- play-2.4/swagger-play2/build.sbt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/play-2.4/swagger-play2/build.sbt b/play-2.4/swagger-play2/build.sbt index abf14e8..397dbde 100644 --- a/play-2.4/swagger-play2/build.sbt +++ b/play-2.4/swagger-play2/build.sbt @@ -1,6 +1,3 @@ -<<<<<<< HEAD -resolvers += "scalaz-bintray" at "http://dl.bintray.com/scalaz/releases" -======= name := "swagger-play2" version := "1.5.4-SNAPSHOT" @@ -77,5 +74,4 @@ pomExtra := { } -lazy val root = (project in file(".")).enablePlugins(PlayScala) ->>>>>>> upstream/master +lazy val root = (project in file(".")).enablePlugins(PlayScala) \ No newline at end of file From dfb9e361d0fef278d351e450db6e025d1c6e851e Mon Sep 17 00:00:00 2001 From: Ramazan AYYILDIZ Date: Fri, 8 Sep 2017 00:38:16 +0200 Subject: [PATCH 6/6] enable travis-ci #156 --- README.md | 2 ++ play-1.2/README.md | 1 + play-2.1/swagger-play2/README.md | 1 + play-2.4/swagger-play2/README.md | 5 +++-- play-2.5/swagger-play2/README.md | 4 ++-- play-2.6/swagger-play2/README.md | 5 +++-- 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index beab318..6eb338b 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Swagger Play Integration +[![Build Status](https://travis-ci.org/swagger-api/swagger-play.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-play) + The goal of Swaggerâ„¢ is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined via Swagger, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interfaces have done for lower-level programming, Swagger removes the guesswork in calling the service. Swagger-play is an integration specifically for the Play framework. diff --git a/play-1.2/README.md b/play-1.2/README.md index 9098efd..05fc6d9 100644 --- a/play-1.2/README.md +++ b/play-1.2/README.md @@ -1,5 +1,6 @@ # Swagger Play 1.2.x Framework Module + **NOTE! This repository is available for historical reasons and the project is no longer supported** ## Overview diff --git a/play-2.1/swagger-play2/README.md b/play-2.1/swagger-play2/README.md index b3770c4..b0af0a4 100644 --- a/play-2.1/swagger-play2/README.md +++ b/play-2.1/swagger-play2/README.md @@ -1,5 +1,6 @@ # Swagger Play2 Module + ## Overview This is a module to support the play2 framework from [playframework](http://www.playframework.org). It is written in scala but can be used with either java or scala-based play2 applications. diff --git a/play-2.4/swagger-play2/README.md b/play-2.4/swagger-play2/README.md index 2597af8..26d4ac9 100644 --- a/play-2.4/swagger-play2/README.md +++ b/play-2.4/swagger-play2/README.md @@ -1,7 +1,8 @@ -[![Build Status](https://travis-ci.org/rayyildiz/swagger-play.svg?branch=master)](https://travis-ci.org/rayyildiz/swagger-play) - # Swagger Play2 Module +[![Build Status](https://travis-ci.org/swagger-api/swagger-play.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-play) + + ## Overview This is a module to support the play2 framework from [playframework](http://www.playframework.org). It is written in scala but can be used with either java or scala-based play2 applications. diff --git a/play-2.5/swagger-play2/README.md b/play-2.5/swagger-play2/README.md index 2597af8..a09ec33 100644 --- a/play-2.5/swagger-play2/README.md +++ b/play-2.5/swagger-play2/README.md @@ -1,7 +1,7 @@ -[![Build Status](https://travis-ci.org/rayyildiz/swagger-play.svg?branch=master)](https://travis-ci.org/rayyildiz/swagger-play) - # Swagger Play2 Module +[![Build Status](https://travis-ci.org/swagger-api/swagger-play.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-play) + ## Overview This is a module to support the play2 framework from [playframework](http://www.playframework.org). It is written in scala but can be used with either java or scala-based play2 applications. diff --git a/play-2.6/swagger-play2/README.md b/play-2.6/swagger-play2/README.md index 92acf4f..ff87974 100644 --- a/play-2.6/swagger-play2/README.md +++ b/play-2.6/swagger-play2/README.md @@ -1,7 +1,8 @@ -[![Build Status](https://travis-ci.org/rayyildiz/swagger-play.svg?branch=master)](https://travis-ci.org/rayyildiz/swagger-play) - # Swagger Play2 Module +[![Build Status](https://travis-ci.org/swagger-api/swagger-play.svg?branch=master)](https://travis-ci.org/swagger-api/swagger-play) + + ## Overview This is a module to support the play2 framework from [playframework](http://www.playframework.org). It is written in scala but can be used with either java or scala-based play2 applications.