Skip to content

Commit 42a8514

Browse files
committed
updated to scalatra 2.3
1 parent ffca1e2 commit 42a8514

File tree

8 files changed

+563
-29
lines changed

8 files changed

+563
-29
lines changed

samples/server-generator/scalatra/ScalatraServerGenerator.scala

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,13 @@ object ScalatraServerGenerator extends BasicScalaGenerator {
3737

3838
override def apiPackage = Some("apis")
3939

40-
40+
additionalParams ++= Map(
41+
"appName" -> "Swagger Sample",
42+
"appDescription" -> "A sample swagger server",
43+
"infoUrl" -> "http://developers.helloreverb.com",
44+
"infoEmail" -> "[email protected]",
45+
"licenseInfo" -> "All rights reserved",
46+
"licenseUrl" -> "http://apache.org/licenses/LICENSE-2.0.html")
4147

4248
// supporting classes
4349
override def supportingFiles = List(
@@ -48,7 +54,8 @@ object ScalatraServerGenerator extends BasicScalaGenerator {
4854
("Bootstrap.mustache", destinationDir, "ScalatraBootstrap.scala"),
4955
("ServletApp.mustache", destinationDir, "ServletApp.scala"),
5056
("project/build.properties", outputFolder, "project/build.properties"),
51-
("project/plugins.sbt", outputFolder, "project/plugins.sbt"))
57+
("project/plugins.sbt", outputFolder, "project/plugins.sbt"),
58+
("sbt", outputFolder, "sbt"))
5259

5360
override def processApiMap(m: Map[String, AnyRef]): Map[String, AnyRef] = {
5461
val mutable = scala.collection.mutable.Map() ++ m

samples/server-generator/scalatra/templates/Bootstrap.mustache

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {{apiPackage}}._
2+
import akka.actor.ActorSystem
23
import com.wordnik.swagger.app.{ResourcesApp, SwaggerApp}
34
import javax.servlet.ServletContext
45
import org.scalatra.LifeCycle
@@ -7,6 +8,7 @@ class ScalatraBootstrap extends LifeCycle {
78
implicit val swagger = new SwaggerApp
89
910
override def init(context: ServletContext) {
11+
implicit val system = ActorSystem("mySystem")
1012
try {
1113
{{#apis}}
1214
context mount (new {{className}}, "/{{name}}/*")

samples/server-generator/scalatra/templates/ServletApp.mustache

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
package com.wordnik.swagger.app
22

3-
import com.wordnik.swagger.core.SwaggerSpec
3+
import _root_.akka.actor.ActorSystem
4+
5+
import org.scalatra.swagger.{ ApiInfo, SwaggerWithAuth, Swagger }
46
import org.scalatra.swagger.{JacksonSwaggerBase, Swagger}
57
import org.scalatra.ScalatraServlet
68
import org.json4s.{DefaultFormats, Formats}
79

8-
class ResourcesApp(implicit val swagger: Swagger) extends ScalatraServlet with JacksonSwaggerBase {
10+
class ResourcesApp(implicit protected val system: ActorSystem, val swagger: SwaggerApp)
11+
extends ScalatraServlet with JacksonSwaggerBase {
912
before() {
1013
response.headers += ("Access-Control-Allow-Origin" -> "*")
1114
}
@@ -23,4 +26,14 @@ class ResourcesApp(implicit val swagger: Swagger) extends ScalatraServlet with J
2326
}
2427
}
2528

26-
class SwaggerApp extends Swagger(SwaggerSpec.version, "1")
29+
class SwaggerApp extends Swagger(apiInfo = ApiSwagger.apiInfo, apiVersion = "1.0", swaggerVersion = "1.2")
30+
31+
object ApiSwagger {
32+
val apiInfo = ApiInfo(
33+
"{{{appName}}}",
34+
"{{{appDescription}}}",
35+
"{{{infoUrl}}}",
36+
"{{{infoEmail}}}",
37+
"{{{licenseInfo}}}",
38+
"{{{licenseUrl}}}")
39+
}

samples/server-generator/scalatra/templates/api.mustache

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package {{package}}
22

33
{{#imports}}import {{import}}
44
{{/imports}}
5-
import com.wordnik.swagger.core.ApiPropertiesReader
65

76
import org.scalatra.{ TypedParamSupport, ScalatraServlet }
87
import org.scalatra.swagger._

samples/server-generator/scalatra/templates/build.sbt

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import AssemblyKeys._ // put this at the top of the file
2-
import com.github.siasia.PluginKeys._
2+
3+
import NativePackagerKeys._
4+
5+
packageArchetype.java_server
36

47
assemblySettings
58

@@ -13,25 +16,22 @@ name := "scalatra-sample"
1316

1417
version := "0.1.0-SNAPSHOT"
1518

16-
scalaVersion := "2.9.2"
19+
scalaVersion := "2.10.0"
1720

1821
libraryDependencies ++= Seq(
19-
"org.scalatest" %% "scalatest" % "1.6.1" % "test",
20-
"org.scalatra" % "scalatra" % "2.2.0",
21-
"org.scalatra" % "scalatra-auth" % "2.2.0",
22-
"org.scalatra" % "scalatra-scalate" % "2.2.0",
23-
"org.scalatra" % "scalatra-json" % "2.2.0",
24-
"org.scalatra" % "scalatra-fileupload" % "2.2.0",
25-
"org.scalatra" % "scalatra-swagger" % "2.2.0",
26-
"org.scalatra" % "scalatra-swagger-ext" % "2.2.0",
27-
"org.scalatra" % "scalatra-slf4j" % "2.2.0",
28-
"org.scalatra" % "scalatra-specs2" % "2.2.0" % "test",
22+
"org.scalatest" %% "scalatest" % "2.0" % "test",
23+
"org.scalatra" %% "scalatra" % "2.3.0.M1",
24+
"org.scalatra" %% "scalatra-scalate" % "2.3.0.M1",
25+
"org.scalatra" %% "scalatra-json" % "2.3.0.M1",
26+
"org.scalatra" %% "scalatra-swagger" % "2.3.0.M1",
27+
"org.scalatra" %% "scalatra-swagger-ext" % "2.3.0.M1",
28+
"org.scalatra" %% "scalatra-slf4j" % "2.3.0.M1",
2929
"org.json4s" %% "json4s-jackson" % "3.1.0",
3030
"org.json4s" %% "json4s-ext" % "3.1.0",
3131
"commons-codec" % "commons-codec" % "1.7",
3232
"net.databinder.dispatch" %% "dispatch-core" % "0.9.5",
3333
"net.databinder.dispatch" %% "json4s-jackson" % "0.9.5",
34-
"com.typesafe.akka" % "akka-actor" % "2.0.2",
34+
"com.typesafe.akka" %% "akka-actor" % "2.1.0",
3535
"org.eclipse.jetty" % "jetty-server" % "8.1.7.v20120910" % "container;provided",
3636
"org.eclipse.jetty" % "jetty-webapp" % "8.1.7.v20120910" % "container;provided",
3737
"org.eclipse.jetty.orbit" % "javax.servlet" % "3.0.0.v201112011016" % "container;compile;provided;test" artifacts (Artifact("javax.servlet", "jar", "jar"))
@@ -55,4 +55,3 @@ mergeStrategy in assembly <<= (mergeStrategy in assembly) { (old) =>
5555
case x => old(x)
5656
}
5757
}
58-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.12.0
1+
sbt.version=0.13.0
Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
1-
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.8.4")
1+
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.10.1")
22

3-
libraryDependencies <+= sbtVersion(v => v match {
4-
case "0.11.0" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.0-0.2.8"
5-
case "0.11.1" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.1-0.2.10"
6-
case "0.11.2" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.2-0.2.11"
7-
case "0.11.3" => "com.github.siasia" %% "xsbt-web-plugin" % "0.11.3-0.2.11.1"
8-
case x if (x.startsWith("0.12")) => "com.github.siasia" %% "xsbt-web-plugin" % "0.12.0-0.2.11.1"
9-
})
3+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.4")
4+
5+
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "0.6.0")

0 commit comments

Comments
 (0)