diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache
index e7fedfd4d4b..32b8ff5fa51 100644
--- a/modules/swagger-codegen/src/main/resources/scala/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache
@@ -31,6 +31,8 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
+import org.json4s._
+
{{#operations}}
class {{classname}}(
val defBasePath: String = "{{{basePath}}}",
diff --git a/samples/client/petstore-security-test/scala/.swagger-codegen/VERSION b/samples/client/petstore-security-test/scala/.swagger-codegen/VERSION
index f9f7450d135..cc6612c36e0 100644
--- a/samples/client/petstore-security-test/scala/.swagger-codegen/VERSION
+++ b/samples/client/petstore-security-test/scala/.swagger-codegen/VERSION
@@ -1 +1 @@
-2.3.0-SNAPSHOT
\ No newline at end of file
+2.3.0
\ No newline at end of file
diff --git a/samples/client/petstore-security-test/scala/build.sbt b/samples/client/petstore-security-test/scala/build.sbt
index bececaf181b..c6b665a0c8a 100644
--- a/samples/client/petstore-security-test/scala/build.sbt
+++ b/samples/client/petstore-security-test/scala/build.sbt
@@ -1,22 +1,20 @@
-version := "1.0.0"
-
-name := "swagger-scala-client"
-
-organization := "io.swagger"
-
-scalaVersion := "2.11.8"
+version := "1.0.0"
+name := "swagger-scala-client"
+organization := "io.swagger"
+scalaVersion := "2.11.12"
libraryDependencies ++= Seq(
- "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.4.2",
- "com.sun.jersey" % "jersey-core" % "1.19",
- "com.sun.jersey" % "jersey-client" % "1.19",
- "com.sun.jersey.contribs" % "jersey-multipart" % "1.19",
+ "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.2",
+ "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.2",
+ "com.sun.jersey" % "jersey-core" % "1.19.4",
+ "com.sun.jersey" % "jersey-client" % "1.19.4",
+ "com.sun.jersey.contribs" % "jersey-multipart" % "1.19.4",
"org.jfarcand" % "jersey-ahc-client" % "1.0.5",
"io.swagger" % "swagger-core" % "1.5.8",
- "joda-time" % "joda-time" % "2.2",
- "org.joda" % "joda-convert" % "1.2",
- "org.scalatest" %% "scalatest" % "2.2.4" % "test",
- "junit" % "junit" % "4.8.1" % "test",
+ "joda-time" % "joda-time" % "2.9.9",
+ "org.joda" % "joda-convert" % "1.9.2",
+ "org.scalatest" %% "scalatest" % "3.0.4" % "test",
+ "junit" % "junit" % "4.12" % "test",
"com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.5"
)
diff --git a/samples/client/petstore-security-test/scala/pom.xml b/samples/client/petstore-security-test/scala/pom.xml
index 66cd2a4003a..2a1715f4f02 100644
--- a/samples/client/petstore-security-test/scala/pom.xml
+++ b/samples/client/petstore-security-test/scala/pom.xml
@@ -1,235 +1,255 @@
- 4.0.0
- io.swagger
- swagger-scala-client
- jar
- swagger-scala-client
- 1.0.0
-
- 2.2.0
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ io.swagger
+ swagger-scala-client
+ jar
+ swagger-scala-client
+ 1.0.0
-
-
- maven-mongodb-plugin-repo
- maven mongodb plugin repository
- http://maven-mongodb-plugin.googlecode.com/svn/maven/repo
- default
-
-
+
+
+ maven-mongodb-plugin-repo
+ maven mongodb plugin repository
+ http://maven-mongodb-plugin.googlecode.com/svn/maven/repo
+ default
+
+
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.12
-
-
-
- loggerPath
- conf/log4j.properties
-
-
- -Xms512m -Xmx1500m
- methods
- pertest
-
-
-
- maven-dependency-plugin
-
-
- package
-
- copy-dependencies
-
-
- ${project.build.directory}/lib
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.0.0-M1
+
+
+ enforce-maven
+
+ enforce
+
+
+
+
+ 2.2.0
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.12
+
+
+
+ loggerPath
+ conf/log4j.properties
+
+
+ -Xms512m -Xmx1500m
+ methods
+ pertest
+
+
+
+ maven-dependency-plugin
+
+
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/lib
+
+
+
+
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.2
-
-
-
- jar
- test-jar
-
-
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.2
+
+
+
+ jar
+ test-jar
+
+
+
+
+
+
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.9.1
-
-
- add_sources
- generate-sources
-
- add-source
-
-
-
- src/main/java
-
-
-
-
- add_test_sources
- generate-test-sources
-
- add-test-source
-
-
-
- src/test/java
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.1
-
- 1.7
- 1.7
-
-
-
- net.alchim31.maven
- scala-maven-plugin
- ${scala-maven-plugin-version}
-
-
- scala-compile-first
- process-resources
-
- add-source
- compile
-
-
-
- scala-test-compile
- process-test-resources
-
- testCompile
-
-
-
-
-
- -Xms128m
- -Xmx1500m
-
-
-
-
-
-
-
-
- org.scala-tools
- maven-scala-plugin
-
- ${scala-version}
-
-
-
-
-
-
- com.fasterxml.jackson.module
- jackson-module-scala_2.11
- ${jackson-version}
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-joda
- ${jackson-version}
-
-
- com.sun.jersey
- jersey-client
- ${jersey-version}
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${jersey-version}
-
-
- org.jfarcand
- jersey-ahc-client
- ${jersey-async-version}
- compile
-
-
- org.scala-lang
- scala-library
- ${scala-version}
-
-
- io.swagger
- swagger-core
- ${swagger-core-version}
-
-
- org.scalatest
- scalatest_2.11
- ${scala-test-version}
- test
-
-
- junit
- junit
- ${junit-version}
- test
-
-
- joda-time
- joda-time
- ${joda-time-version}
-
-
- org.joda
- joda-convert
- ${joda-version}
-
-
- com.wordnik.swagger
- swagger-async-httpclient_2.11
- ${swagger-async-httpclient-version}
-
-
-
- 2.11.12
- 1.2
- 2.2
- 1.19
- 1.5.16
- 1.0.5
- 1.0.0
- 2.8.9
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.9.1
+
+
+ add_sources
+ generate-sources
+
+ add-source
+
+
+
+
+ src/main/java
+
+
+
+
+ add_test_sources
+ generate-test-sources
+
+ add-test-source
+
+
+
+
+ src/test/java
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+
+ 1.7
+ 1.7
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+ ${scala-maven-plugin-version}
+
+
+ scala-compile-first
+ process-resources
+
+ add-source
+ compile
+
+
+
+ scala-test-compile
+ process-test-resources
+
+ testCompile
+
+
+
+
+
+ -Xms128m
+ -Xmx1500m
+
+
+
+
+
+
+
+
+ org.scala-tools
+ maven-scala-plugin
+
+ ${scala-version}
+
+
+
+
+
+
+ com.fasterxml.jackson.module
+ jackson-module-scala_2.11
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-joda
+ ${jackson-version}
+
+
+ com.sun.jersey
+ jersey-client
+ ${jersey-version}
+
+
+ com.sun.jersey.contribs
+ jersey-multipart
+ ${jersey-version}
+
+
+ org.jfarcand
+ jersey-ahc-client
+ ${jersey-async-version}
+ compile
+
+
+ org.scala-lang
+ scala-library
+ ${scala-version}
+
+
+ io.swagger
+ swagger-core
+ ${swagger-core-version}
+
+
+ org.scalatest
+ scalatest_2.11
+ ${scala-test-version}
+ test
+
+
+ junit
+ junit
+ ${junit-version}
+ test
+
+
+ joda-time
+ joda-time
+ ${joda-time-version}
+
+
+ org.joda
+ joda-convert
+ ${joda-version}
+
+
+ com.wordnik.swagger
+ swagger-async-httpclient_2.11
+ ${swagger-async-httpclient-version}
+
+
+
+ 2.11.12
+ 1.9.2
+ 2.9.9
+ 1.19.4
+ 1.5.16
+ 1.0.5
+ 1.0.0
+ 2.9.2
- 4.8.1
- 3.1.5
- 2.2.4
- 0.3.5
+ 4.12
+ 3.1.5
+ 3.0.4
+ 0.3.5
- UTF-8
-
+ UTF-8
+
diff --git a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/ApiInvoker.scala b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
index 5d31e36a762..38916b55d44 100644
--- a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
+++ b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
@@ -38,7 +38,7 @@ import com.fasterxml.jackson.annotation._
import com.fasterxml.jackson.databind.annotation.JsonSerialize
object ScalaJsonUtil {
- def getJsonMapper = {
+ def getJsonMapper: ObjectMapper = {
val mapper = new ObjectMapper()
mapper.registerModule(new DefaultScalaModule())
mapper.registerModule(new JodaModule())
@@ -130,9 +130,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
val builder = client.resource(host + path + querystring).accept(contentType)
headerParams.map(p => builder.header(p._1, p._2))
defaultHeaders.foreach(p => {
- headerParams.contains(p._1) match {
- case true => // override default with supplied header
- case false => if (p._2 != null) builder.header(p._1, p._2)
+ if (!headerParams.contains(p._1) && p._2 != null) {
+ builder.header(p._1, p._2)
}
})
var formData: MultivaluedMapImpl = null
@@ -142,7 +141,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
}
val response: ClientResponse = method match {
- case "GET" => builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
+ case "GET" => builder.get(classOf[ClientResponse])
case "POST" =>
if (formData != null && formData.size() > 0) {
builder.post(classOf[ClientResponse], formData)
@@ -181,46 +180,48 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
response.getStatusInfo.getStatusCode match {
case 204 => ""
case code: Int if Range(200, 299).contains(code) =>
- response.hasEntity match {
- case true => response.getEntity(classOf[String])
- case false => ""
+ if (response.hasEntity) {
+ response.getEntity(classOf[String])
+ } else {
+ ""
}
case _ =>
- val entity = response.hasEntity match {
- case true => response.getEntity(classOf[String])
- case false => "no data"
+ val entity = if (response.hasEntity) {
+ response.getEntity(classOf[String])
+ } else {
+ "no data"
}
throw new ApiException(response.getStatusInfo.getStatusCode, entity)
}
}
def getClient(host: String): Client = {
- hostMap.contains(host) match {
- case true => hostMap(host)
- case false =>
- val client = newClient(host)
- // client.addFilter(new LoggingFilter())
- hostMap += host -> client
- client
- }
+ if (hostMap.contains(host)) {
+ hostMap(host)
+ } else {
+ val client = newClient(host)
+ // client.addFilter(new LoggingFilter())
+ hostMap += host -> client
+ client
+ }
}
- def newClient(host: String): Client = asyncHttpClient match {
- case true =>
- import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
- import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
- import com.ning.http.client.Realm
-
- val config: DefaultAhcConfig = new DefaultAhcConfig()
- if (!authScheme.isEmpty) {
- val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
- config
- .getAsyncHttpClientConfigBuilder
- .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
- .setUsePreemptiveAuth(authPreemptive).build)
- }
- AhcHttpClient.create(config)
- case _ => Client.create()
+ def newClient(host: String): Client = if (asyncHttpClient) {
+ import com.ning.http.client.Realm
+ import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
+ import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
+
+ val config: DefaultAhcConfig = new DefaultAhcConfig()
+ if (!authScheme.isEmpty) {
+ val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
+ config
+ .getAsyncHttpClientConfigBuilder
+ .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
+ .setUsePreemptiveAuth(authPreemptive).build)
+ }
+ AhcHttpClient.create(config)
+ } else {
+ Client.create()
}
}
diff --git a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/AsyncClient.scala b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/AsyncClient.scala
index c518277f577..44b642c913c 100644
--- a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/AsyncClient.scala
+++ b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/AsyncClient.scala
@@ -7,8 +7,8 @@ import com.wordnik.swagger.client._
import java.io.Closeable
class AsyncClient(config: SwaggerConfig) extends Closeable {
- val locator = config.locator
- val name = config.name
+ lazy val locator: ServiceLocator = config.locator
+ lazy val name: String = config.name
private[this] val client = transportClient
diff --git a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/api/FakeApi.scala b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/api/FakeApi.scala
index 05a73b29609..0aaed4e8e81 100644
--- a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/api/FakeApi.scala
+++ b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/api/FakeApi.scala
@@ -40,6 +40,8 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
+import org.json4s._
+
class FakeApi(
val defBasePath: String = "https://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
defApiInvoker: ApiInvoker = ApiInvoker
@@ -48,12 +50,12 @@ class FakeApi(
implicit val formats = new org.json4s.DefaultFormats {
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
}
- implicit val stringReader = ClientResponseReaders.StringReader
- implicit val unitReader = ClientResponseReaders.UnitReader
- implicit val jvalueReader = ClientResponseReaders.JValueReader
- implicit val jsonReader = JsonFormatsReader
- implicit val stringWriter = RequestWriters.StringWriter
- implicit val jsonWriter = JsonFormatsWriter
+ implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
+ implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
+ implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
+ implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
+ implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
+ implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
var basePath: String = defBasePath
var apiInvoker: ApiInvoker = defApiInvoker
@@ -62,13 +64,14 @@ class FakeApi(
apiInvoker.defaultHeaders += key -> value
}
- val config = SwaggerConfig.forUrl(new URI(defBasePath))
+ val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
val client = new RestClient(config)
val helper = new FakeApiAsyncHelper(client, config)
/**
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
*
+ *
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
* @return void
*/
@@ -83,9 +86,10 @@ class FakeApi(
/**
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r asynchronously
*
+ *
* @param testCodeInjectEndRnNR To test code injection *_/ ' \" =end -- \\r\\n \\n \\r (optional)
* @return Future(void)
- */
+ */
def testCodeInject * ' " =end rn n rAsync(testCodeInjectEndRnNR: Option[String] = None) = {
helper.testCodeInject * ' " =end rn n r(testCodeInjectEndRnNR)
}
diff --git a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala
index b2ce925e121..61527518a18 100644
--- a/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala
+++ b/samples/client/petstore-security-test/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala
@@ -14,7 +14,7 @@ package io.swagger.client.model
case class ModelReturn (
- /* property description *_/ ' \" =end -- \\r\\n \\n \\r */
+ // property description *_/ ' \" =end -- \\r\\n \\n \\r
_return: Option[Integer] = None
)
diff --git a/samples/client/petstore/scala/.swagger-codegen/VERSION b/samples/client/petstore/scala/.swagger-codegen/VERSION
index f9f7450d135..cc6612c36e0 100644
--- a/samples/client/petstore/scala/.swagger-codegen/VERSION
+++ b/samples/client/petstore/scala/.swagger-codegen/VERSION
@@ -1 +1 @@
-2.3.0-SNAPSHOT
\ No newline at end of file
+2.3.0
\ No newline at end of file
diff --git a/samples/client/petstore/scala/build.sbt b/samples/client/petstore/scala/build.sbt
index bececaf181b..c6b665a0c8a 100644
--- a/samples/client/petstore/scala/build.sbt
+++ b/samples/client/petstore/scala/build.sbt
@@ -1,22 +1,20 @@
-version := "1.0.0"
-
-name := "swagger-scala-client"
-
-organization := "io.swagger"
-
-scalaVersion := "2.11.8"
+version := "1.0.0"
+name := "swagger-scala-client"
+organization := "io.swagger"
+scalaVersion := "2.11.12"
libraryDependencies ++= Seq(
- "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.4.2",
- "com.sun.jersey" % "jersey-core" % "1.19",
- "com.sun.jersey" % "jersey-client" % "1.19",
- "com.sun.jersey.contribs" % "jersey-multipart" % "1.19",
+ "com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.2",
+ "com.fasterxml.jackson.datatype" % "jackson-datatype-joda" % "2.9.2",
+ "com.sun.jersey" % "jersey-core" % "1.19.4",
+ "com.sun.jersey" % "jersey-client" % "1.19.4",
+ "com.sun.jersey.contribs" % "jersey-multipart" % "1.19.4",
"org.jfarcand" % "jersey-ahc-client" % "1.0.5",
"io.swagger" % "swagger-core" % "1.5.8",
- "joda-time" % "joda-time" % "2.2",
- "org.joda" % "joda-convert" % "1.2",
- "org.scalatest" %% "scalatest" % "2.2.4" % "test",
- "junit" % "junit" % "4.8.1" % "test",
+ "joda-time" % "joda-time" % "2.9.9",
+ "org.joda" % "joda-convert" % "1.9.2",
+ "org.scalatest" %% "scalatest" % "3.0.4" % "test",
+ "junit" % "junit" % "4.12" % "test",
"com.wordnik.swagger" %% "swagger-async-httpclient" % "0.3.5"
)
diff --git a/samples/client/petstore/scala/pom.xml b/samples/client/petstore/scala/pom.xml
index 66cd2a4003a..2a1715f4f02 100644
--- a/samples/client/petstore/scala/pom.xml
+++ b/samples/client/petstore/scala/pom.xml
@@ -1,235 +1,255 @@
- 4.0.0
- io.swagger
- swagger-scala-client
- jar
- swagger-scala-client
- 1.0.0
-
- 2.2.0
-
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ 4.0.0
+ io.swagger
+ swagger-scala-client
+ jar
+ swagger-scala-client
+ 1.0.0
-
-
- maven-mongodb-plugin-repo
- maven mongodb plugin repository
- http://maven-mongodb-plugin.googlecode.com/svn/maven/repo
- default
-
-
+
+
+ maven-mongodb-plugin-repo
+ maven mongodb plugin repository
+ http://maven-mongodb-plugin.googlecode.com/svn/maven/repo
+ default
+
+
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
- 2.12
-
-
-
- loggerPath
- conf/log4j.properties
-
-
- -Xms512m -Xmx1500m
- methods
- pertest
-
-
-
- maven-dependency-plugin
-
-
- package
-
- copy-dependencies
-
-
- ${project.build.directory}/lib
-
-
-
-
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 3.0.0-M1
+
+
+ enforce-maven
+
+ enforce
+
+
+
+
+ 2.2.0
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.12
+
+
+
+ loggerPath
+ conf/log4j.properties
+
+
+ -Xms512m -Xmx1500m
+ methods
+ pertest
+
+
+
+ maven-dependency-plugin
+
+
+ package
+
+ copy-dependencies
+
+
+ ${project.build.directory}/lib
+
+
+
+
-
-
- org.apache.maven.plugins
- maven-jar-plugin
- 2.2
-
-
-
- jar
- test-jar
-
-
-
-
-
-
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+ 2.2
+
+
+
+ jar
+ test-jar
+
+
+
+
+
+
-
- org.codehaus.mojo
- build-helper-maven-plugin
- 1.9.1
-
-
- add_sources
- generate-sources
-
- add-source
-
-
-
- src/main/java
-
-
-
-
- add_test_sources
- generate-test-sources
-
- add-test-source
-
-
-
- src/test/java
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.6.1
-
- 1.7
- 1.7
-
-
-
- net.alchim31.maven
- scala-maven-plugin
- ${scala-maven-plugin-version}
-
-
- scala-compile-first
- process-resources
-
- add-source
- compile
-
-
-
- scala-test-compile
- process-test-resources
-
- testCompile
-
-
-
-
-
- -Xms128m
- -Xmx1500m
-
-
-
-
-
-
-
-
- org.scala-tools
- maven-scala-plugin
-
- ${scala-version}
-
-
-
-
-
-
- com.fasterxml.jackson.module
- jackson-module-scala_2.11
- ${jackson-version}
-
-
- com.fasterxml.jackson.datatype
- jackson-datatype-joda
- ${jackson-version}
-
-
- com.sun.jersey
- jersey-client
- ${jersey-version}
-
-
- com.sun.jersey.contribs
- jersey-multipart
- ${jersey-version}
-
-
- org.jfarcand
- jersey-ahc-client
- ${jersey-async-version}
- compile
-
-
- org.scala-lang
- scala-library
- ${scala-version}
-
-
- io.swagger
- swagger-core
- ${swagger-core-version}
-
-
- org.scalatest
- scalatest_2.11
- ${scala-test-version}
- test
-
-
- junit
- junit
- ${junit-version}
- test
-
-
- joda-time
- joda-time
- ${joda-time-version}
-
-
- org.joda
- joda-convert
- ${joda-version}
-
-
- com.wordnik.swagger
- swagger-async-httpclient_2.11
- ${swagger-async-httpclient-version}
-
-
-
- 2.11.12
- 1.2
- 2.2
- 1.19
- 1.5.16
- 1.0.5
- 1.0.0
- 2.8.9
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ 1.9.1
+
+
+ add_sources
+ generate-sources
+
+ add-source
+
+
+
+
+ src/main/java
+
+
+
+
+ add_test_sources
+ generate-test-sources
+
+ add-test-source
+
+
+
+
+ src/test/java
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.6.1
+
+
+ 1.7
+ 1.7
+
+
+
+ net.alchim31.maven
+ scala-maven-plugin
+ ${scala-maven-plugin-version}
+
+
+ scala-compile-first
+ process-resources
+
+ add-source
+ compile
+
+
+
+ scala-test-compile
+ process-test-resources
+
+ testCompile
+
+
+
+
+
+ -Xms128m
+ -Xmx1500m
+
+
+
+
+
+
+
+
+ org.scala-tools
+ maven-scala-plugin
+
+ ${scala-version}
+
+
+
+
+
+
+ com.fasterxml.jackson.module
+ jackson-module-scala_2.11
+ ${jackson-version}
+
+
+ com.fasterxml.jackson.datatype
+ jackson-datatype-joda
+ ${jackson-version}
+
+
+ com.sun.jersey
+ jersey-client
+ ${jersey-version}
+
+
+ com.sun.jersey.contribs
+ jersey-multipart
+ ${jersey-version}
+
+
+ org.jfarcand
+ jersey-ahc-client
+ ${jersey-async-version}
+ compile
+
+
+ org.scala-lang
+ scala-library
+ ${scala-version}
+
+
+ io.swagger
+ swagger-core
+ ${swagger-core-version}
+
+
+ org.scalatest
+ scalatest_2.11
+ ${scala-test-version}
+ test
+
+
+ junit
+ junit
+ ${junit-version}
+ test
+
+
+ joda-time
+ joda-time
+ ${joda-time-version}
+
+
+ org.joda
+ joda-convert
+ ${joda-version}
+
+
+ com.wordnik.swagger
+ swagger-async-httpclient_2.11
+ ${swagger-async-httpclient-version}
+
+
+
+ 2.11.12
+ 1.9.2
+ 2.9.9
+ 1.19.4
+ 1.5.16
+ 1.0.5
+ 1.0.0
+ 2.9.2
- 4.8.1
- 3.1.5
- 2.2.4
- 0.3.5
+ 4.12
+ 3.1.5
+ 3.0.4
+ 0.3.5
- UTF-8
-
+ UTF-8
+
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/ApiInvoker.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
index 75f0833d51f..26e7215ca31 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/ApiInvoker.scala
@@ -38,7 +38,7 @@ import com.fasterxml.jackson.annotation._
import com.fasterxml.jackson.databind.annotation.JsonSerialize
object ScalaJsonUtil {
- def getJsonMapper = {
+ def getJsonMapper: ObjectMapper = {
val mapper = new ObjectMapper()
mapper.registerModule(new DefaultScalaModule())
mapper.registerModule(new JodaModule())
@@ -130,9 +130,8 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
val builder = client.resource(host + path + querystring).accept(contentType)
headerParams.map(p => builder.header(p._1, p._2))
defaultHeaders.foreach(p => {
- headerParams.contains(p._1) match {
- case true => // override default with supplied header
- case false => if (p._2 != null) builder.header(p._1, p._2)
+ if (!headerParams.contains(p._1) && p._2 != null) {
+ builder.header(p._1, p._2)
}
})
var formData: MultivaluedMapImpl = null
@@ -142,7 +141,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
}
val response: ClientResponse = method match {
- case "GET" => builder.get(classOf[ClientResponse]).asInstanceOf[ClientResponse]
+ case "GET" => builder.get(classOf[ClientResponse])
case "POST" =>
if (formData != null && formData.size() > 0) {
builder.post(classOf[ClientResponse], formData)
@@ -181,46 +180,48 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
response.getStatusInfo.getStatusCode match {
case 204 => ""
case code: Int if Range(200, 299).contains(code) =>
- response.hasEntity match {
- case true => response.getEntity(classOf[String])
- case false => ""
+ if (response.hasEntity) {
+ response.getEntity(classOf[String])
+ } else {
+ ""
}
case _ =>
- val entity = response.hasEntity match {
- case true => response.getEntity(classOf[String])
- case false => "no data"
+ val entity = if (response.hasEntity) {
+ response.getEntity(classOf[String])
+ } else {
+ "no data"
}
throw new ApiException(response.getStatusInfo.getStatusCode, entity)
}
}
def getClient(host: String): Client = {
- hostMap.contains(host) match {
- case true => hostMap(host)
- case false =>
- val client = newClient(host)
- // client.addFilter(new LoggingFilter())
- hostMap += host -> client
- client
- }
+ if (hostMap.contains(host)) {
+ hostMap(host)
+ } else {
+ val client = newClient(host)
+ // client.addFilter(new LoggingFilter())
+ hostMap += host -> client
+ client
+ }
}
- def newClient(host: String): Client = asyncHttpClient match {
- case true =>
- import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
- import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
- import com.ning.http.client.Realm
-
- val config: DefaultAhcConfig = new DefaultAhcConfig()
- if (!authScheme.isEmpty) {
- val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
- config
- .getAsyncHttpClientConfigBuilder
- .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
- .setUsePreemptiveAuth(authPreemptive).build)
- }
- AhcHttpClient.create(config)
- case _ => Client.create()
+ def newClient(host: String): Client = if (asyncHttpClient) {
+ import com.ning.http.client.Realm
+ import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
+ import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
+
+ val config: DefaultAhcConfig = new DefaultAhcConfig()
+ if (!authScheme.isEmpty) {
+ val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
+ config
+ .getAsyncHttpClientConfigBuilder
+ .setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
+ .setUsePreemptiveAuth(authPreemptive).build)
+ }
+ AhcHttpClient.create(config)
+ } else {
+ Client.create()
}
}
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/AsyncClient.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/AsyncClient.scala
index c518277f577..44b642c913c 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/AsyncClient.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/AsyncClient.scala
@@ -7,8 +7,8 @@ import com.wordnik.swagger.client._
import java.io.Closeable
class AsyncClient(config: SwaggerConfig) extends Closeable {
- val locator = config.locator
- val name = config.name
+ lazy val locator: ServiceLocator = config.locator
+ lazy val name: String = config.name
private[this] val client = transportClient
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
index bdada6d0e63..7ee97e2ae40 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/PetApi.scala
@@ -43,6 +43,8 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
+import org.json4s._
+
class PetApi(
val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker
@@ -51,12 +53,12 @@ class PetApi(
implicit val formats = new org.json4s.DefaultFormats {
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
}
- implicit val stringReader = ClientResponseReaders.StringReader
- implicit val unitReader = ClientResponseReaders.UnitReader
- implicit val jvalueReader = ClientResponseReaders.JValueReader
- implicit val jsonReader = JsonFormatsReader
- implicit val stringWriter = RequestWriters.StringWriter
- implicit val jsonWriter = JsonFormatsWriter
+ implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
+ implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
+ implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
+ implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
+ implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
+ implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
var basePath: String = defBasePath
var apiInvoker: ApiInvoker = defApiInvoker
@@ -65,13 +67,14 @@ class PetApi(
apiInvoker.defaultHeaders += key -> value
}
- val config = SwaggerConfig.forUrl(new URI(defBasePath))
+ val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
val client = new RestClient(config)
val helper = new PetApiAsyncHelper(client, config)
/**
* Add a new pet to the store
*
+ *
* @param body Pet object that needs to be added to the store
* @return void
*/
@@ -86,9 +89,10 @@ class PetApi(
/**
* Add a new pet to the store asynchronously
*
+ *
* @param body Pet object that needs to be added to the store
* @return Future(void)
- */
+ */
def addPetAsync(body: Pet) = {
helper.addPet(body)
}
@@ -96,6 +100,7 @@ class PetApi(
/**
* Deletes a pet
*
+ *
* @param petId Pet id to delete
* @param apiKey (optional)
* @return void
@@ -111,10 +116,11 @@ class PetApi(
/**
* Deletes a pet asynchronously
*
+ *
* @param petId Pet id to delete
* @param apiKey (optional)
* @return Future(void)
- */
+ */
def deletePetAsync(petId: Long, apiKey: Option[String] = None) = {
helper.deletePet(petId, apiKey)
}
@@ -122,6 +128,7 @@ class PetApi(
/**
* Finds Pets by status
* Multiple status values can be provided with comma separated strings
+ *
* @param status Status values that need to be considered for filter
* @return List[Pet]
*/
@@ -136,9 +143,10 @@ class PetApi(
/**
* Finds Pets by status asynchronously
* Multiple status values can be provided with comma separated strings
+ *
* @param status Status values that need to be considered for filter
* @return Future(List[Pet])
- */
+ */
def findPetsByStatusAsync(status: List[String]): Future[List[Pet]] = {
helper.findPetsByStatus(status)
}
@@ -146,6 +154,7 @@ class PetApi(
/**
* Finds Pets by tags
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ *
* @param tags Tags to filter by
* @return List[Pet]
*/
@@ -160,9 +169,10 @@ class PetApi(
/**
* Finds Pets by tags asynchronously
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
+ *
* @param tags Tags to filter by
* @return Future(List[Pet])
- */
+ */
def findPetsByTagsAsync(tags: List[String]): Future[List[Pet]] = {
helper.findPetsByTags(tags)
}
@@ -170,6 +180,7 @@ class PetApi(
/**
* Find pet by ID
* Returns a single pet
+ *
* @param petId ID of pet to return
* @return Pet
*/
@@ -184,9 +195,10 @@ class PetApi(
/**
* Find pet by ID asynchronously
* Returns a single pet
+ *
* @param petId ID of pet to return
* @return Future(Pet)
- */
+ */
def getPetByIdAsync(petId: Long): Future[Pet] = {
helper.getPetById(petId)
}
@@ -194,6 +206,7 @@ class PetApi(
/**
* Update an existing pet
*
+ *
* @param body Pet object that needs to be added to the store
* @return void
*/
@@ -208,9 +221,10 @@ class PetApi(
/**
* Update an existing pet asynchronously
*
+ *
* @param body Pet object that needs to be added to the store
* @return Future(void)
- */
+ */
def updatePetAsync(body: Pet) = {
helper.updatePet(body)
}
@@ -218,6 +232,7 @@ class PetApi(
/**
* Updates a pet in the store with form data
*
+ *
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet (optional)
* @param status Updated status of the pet (optional)
@@ -234,11 +249,12 @@ class PetApi(
/**
* Updates a pet in the store with form data asynchronously
*
+ *
* @param petId ID of pet that needs to be updated
* @param name Updated name of the pet (optional)
* @param status Updated status of the pet (optional)
* @return Future(void)
- */
+ */
def updatePetWithFormAsync(petId: Long, name: Option[String] = None, status: Option[String] = None) = {
helper.updatePetWithForm(petId, name, status)
}
@@ -246,6 +262,7 @@ class PetApi(
/**
* uploads an image
*
+ *
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
@@ -262,11 +279,12 @@ class PetApi(
/**
* uploads an image asynchronously
*
+ *
* @param petId ID of pet to update
* @param additionalMetadata Additional data to pass to server (optional)
* @param file file to upload (optional)
* @return Future(ApiResponse)
- */
+ */
def uploadFileAsync(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): Future[ApiResponse] = {
helper.uploadFile(petId, additionalMetadata, file)
}
@@ -296,7 +314,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/pet/{petId}")
- replaceAll ("\\{" + "petId" + "\\}",petId.toString))
+ replaceAll("\\{" + "petId" + "\\}", petId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -350,7 +368,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = {
// create path and map variables
val path = (addFmt("/pet/{petId}")
- replaceAll ("\\{" + "petId" + "\\}",petId.toString))
+ replaceAll("\\{" + "petId" + "\\}", petId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -385,7 +403,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/pet/{petId}")
- replaceAll ("\\{" + "petId" + "\\}",petId.toString))
+ replaceAll("\\{" + "petId" + "\\}", petId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -404,7 +422,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
)(implicit reader: ClientResponseReader[ApiResponse]): Future[ApiResponse] = {
// create path and map variables
val path = (addFmt("/pet/{petId}/uploadImage")
- replaceAll ("\\{" + "petId" + "\\}",petId.toString))
+ replaceAll("\\{" + "petId" + "\\}", petId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala
index 87a3364ceb5..1d467b4c97b 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/StoreApi.scala
@@ -41,6 +41,8 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
+import org.json4s._
+
class StoreApi(
val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker
@@ -49,12 +51,12 @@ class StoreApi(
implicit val formats = new org.json4s.DefaultFormats {
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
}
- implicit val stringReader = ClientResponseReaders.StringReader
- implicit val unitReader = ClientResponseReaders.UnitReader
- implicit val jvalueReader = ClientResponseReaders.JValueReader
- implicit val jsonReader = JsonFormatsReader
- implicit val stringWriter = RequestWriters.StringWriter
- implicit val jsonWriter = JsonFormatsWriter
+ implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
+ implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
+ implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
+ implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
+ implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
+ implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
var basePath: String = defBasePath
var apiInvoker: ApiInvoker = defApiInvoker
@@ -63,13 +65,14 @@ class StoreApi(
apiInvoker.defaultHeaders += key -> value
}
- val config = SwaggerConfig.forUrl(new URI(defBasePath))
+ val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
val client = new RestClient(config)
val helper = new StoreApiAsyncHelper(client, config)
/**
* Delete purchase order by ID
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ *
* @param orderId ID of the order that needs to be deleted
* @return void
*/
@@ -84,9 +87,10 @@ class StoreApi(
/**
* Delete purchase order by ID asynchronously
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
+ *
* @param orderId ID of the order that needs to be deleted
* @return Future(void)
- */
+ */
def deleteOrderAsync(orderId: String) = {
helper.deleteOrder(orderId)
}
@@ -94,6 +98,7 @@ class StoreApi(
/**
* Returns pet inventories by status
* Returns a map of status codes to quantities
+ *
* @return Map[String, Integer]
*/
def getInventory(): Option[Map[String, Integer]] = {
@@ -107,8 +112,9 @@ class StoreApi(
/**
* Returns pet inventories by status asynchronously
* Returns a map of status codes to quantities
+ *
* @return Future(Map[String, Integer])
- */
+ */
def getInventoryAsync(): Future[Map[String, Integer]] = {
helper.getInventory()
}
@@ -116,6 +122,7 @@ class StoreApi(
/**
* Find purchase order by ID
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ *
* @param orderId ID of pet that needs to be fetched
* @return Order
*/
@@ -130,9 +137,10 @@ class StoreApi(
/**
* Find purchase order by ID asynchronously
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
+ *
* @param orderId ID of pet that needs to be fetched
* @return Future(Order)
- */
+ */
def getOrderByIdAsync(orderId: Long): Future[Order] = {
helper.getOrderById(orderId)
}
@@ -140,6 +148,7 @@ class StoreApi(
/**
* Place an order for a pet
*
+ *
* @param body order placed for purchasing the pet
* @return Order
*/
@@ -154,9 +163,10 @@ class StoreApi(
/**
* Place an order for a pet asynchronously
*
+ *
* @param body order placed for purchasing the pet
* @return Future(Order)
- */
+ */
def placeOrderAsync(body: Order): Future[Order] = {
helper.placeOrder(body)
}
@@ -168,7 +178,7 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
def deleteOrder(orderId: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/store/order/{orderId}")
- replaceAll ("\\{" + "orderId" + "\\}",orderId.toString))
+ replaceAll("\\{" + "orderId" + "\\}", orderId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -201,7 +211,7 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
def getOrderById(orderId: Long)(implicit reader: ClientResponseReader[Order]): Future[Order] = {
// create path and map variables
val path = (addFmt("/store/order/{orderId}")
- replaceAll ("\\{" + "orderId" + "\\}",orderId.toString))
+ replaceAll("\\{" + "orderId" + "\\}", orderId.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala
index 21a510f9a4f..e223e9287b0 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/api/UserApi.scala
@@ -41,6 +41,8 @@ import scala.concurrent._
import scala.concurrent.duration._
import scala.util.{Failure, Success, Try}
+import org.json4s._
+
class UserApi(
val defBasePath: String = "http://petstore.swagger.io/v2",
defApiInvoker: ApiInvoker = ApiInvoker
@@ -49,12 +51,12 @@ class UserApi(
implicit val formats = new org.json4s.DefaultFormats {
override def dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS+0000")
}
- implicit val stringReader = ClientResponseReaders.StringReader
- implicit val unitReader = ClientResponseReaders.UnitReader
- implicit val jvalueReader = ClientResponseReaders.JValueReader
- implicit val jsonReader = JsonFormatsReader
- implicit val stringWriter = RequestWriters.StringWriter
- implicit val jsonWriter = JsonFormatsWriter
+ implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
+ implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
+ implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
+ implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
+ implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
+ implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
var basePath: String = defBasePath
var apiInvoker: ApiInvoker = defApiInvoker
@@ -63,13 +65,14 @@ class UserApi(
apiInvoker.defaultHeaders += key -> value
}
- val config = SwaggerConfig.forUrl(new URI(defBasePath))
+ val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
val client = new RestClient(config)
val helper = new UserApiAsyncHelper(client, config)
/**
* Create user
* This can only be done by the logged in user.
+ *
* @param body Created user object
* @return void
*/
@@ -84,9 +87,10 @@ class UserApi(
/**
* Create user asynchronously
* This can only be done by the logged in user.
+ *
* @param body Created user object
* @return Future(void)
- */
+ */
def createUserAsync(body: User) = {
helper.createUser(body)
}
@@ -94,6 +98,7 @@ class UserApi(
/**
* Creates list of users with given input array
*
+ *
* @param body List of user object
* @return void
*/
@@ -108,9 +113,10 @@ class UserApi(
/**
* Creates list of users with given input array asynchronously
*
+ *
* @param body List of user object
* @return Future(void)
- */
+ */
def createUsersWithArrayInputAsync(body: List[User]) = {
helper.createUsersWithArrayInput(body)
}
@@ -118,6 +124,7 @@ class UserApi(
/**
* Creates list of users with given input array
*
+ *
* @param body List of user object
* @return void
*/
@@ -132,9 +139,10 @@ class UserApi(
/**
* Creates list of users with given input array asynchronously
*
+ *
* @param body List of user object
* @return Future(void)
- */
+ */
def createUsersWithListInputAsync(body: List[User]) = {
helper.createUsersWithListInput(body)
}
@@ -142,6 +150,7 @@ class UserApi(
/**
* Delete user
* This can only be done by the logged in user.
+ *
* @param username The name that needs to be deleted
* @return void
*/
@@ -156,9 +165,10 @@ class UserApi(
/**
* Delete user asynchronously
* This can only be done by the logged in user.
+ *
* @param username The name that needs to be deleted
* @return Future(void)
- */
+ */
def deleteUserAsync(username: String) = {
helper.deleteUser(username)
}
@@ -166,6 +176,7 @@ class UserApi(
/**
* Get user by user name
*
+ *
* @param username The name that needs to be fetched. Use user1 for testing.
* @return User
*/
@@ -180,9 +191,10 @@ class UserApi(
/**
* Get user by user name asynchronously
*
+ *
* @param username The name that needs to be fetched. Use user1 for testing.
* @return Future(User)
- */
+ */
def getUserByNameAsync(username: String): Future[User] = {
helper.getUserByName(username)
}
@@ -190,6 +202,7 @@ class UserApi(
/**
* Logs user into the system
*
+ *
* @param username The user name for login
* @param password The password for login in clear text
* @return String
@@ -205,10 +218,11 @@ class UserApi(
/**
* Logs user into the system asynchronously
*
+ *
* @param username The user name for login
* @param password The password for login in clear text
* @return Future(String)
- */
+ */
def loginUserAsync(username: String, password: String): Future[String] = {
helper.loginUser(username, password)
}
@@ -216,6 +230,7 @@ class UserApi(
/**
* Logs out current logged in user session
*
+ *
* @return void
*/
def logoutUser() = {
@@ -229,8 +244,9 @@ class UserApi(
/**
* Logs out current logged in user session asynchronously
*
+ *
* @return Future(void)
- */
+ */
def logoutUserAsync() = {
helper.logoutUser()
}
@@ -238,6 +254,7 @@ class UserApi(
/**
* Updated user
* This can only be done by the logged in user.
+ *
* @param username name that need to be deleted
* @param body Updated user object
* @return void
@@ -253,10 +270,11 @@ class UserApi(
/**
* Updated user asynchronously
* This can only be done by the logged in user.
+ *
* @param username name that need to be deleted
* @param body Updated user object
* @return Future(void)
- */
+ */
def updateUserAsync(username: String, body: User) = {
helper.updateUser(username, body)
}
@@ -316,7 +334,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
def deleteUser(username: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/user/{username}")
- replaceAll ("\\{" + "username" + "\\}",username.toString))
+ replaceAll("\\{" + "username" + "\\}", username.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -334,7 +352,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
def getUserByName(username: String)(implicit reader: ClientResponseReader[User]): Future[User] = {
// create path and map variables
val path = (addFmt("/user/{username}")
- replaceAll ("\\{" + "username" + "\\}",username.toString))
+ replaceAll("\\{" + "username" + "\\}", username.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
@@ -390,7 +408,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
// create path and map variables
val path = (addFmt("/user/{username}")
- replaceAll ("\\{" + "username" + "\\}",username.toString))
+ replaceAll("\\{" + "username" + "\\}", username.toString))
// query params
val queryParams = new mutable.HashMap[String, String]
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Order.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Order.scala
index fae3fddacb1..56670631540 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Order.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Order.scala
@@ -19,7 +19,7 @@ case class Order (
petId: Option[Long] = None,
quantity: Option[Integer] = None,
shipDate: Option[Date] = None,
- /* Order Status */
+ // Order Status
status: Option[String] = None,
complete: Option[Boolean] = None
)
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Pet.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Pet.scala
index 88c868637e9..b1fdd85d799 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Pet.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Pet.scala
@@ -19,7 +19,7 @@ case class Pet (
name: String,
photoUrls: List[String],
tags: Option[List[Tag]] = None,
- /* pet status in the store */
+ // pet status in the store
status: Option[String] = None
)
diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/User.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/User.scala
index 46183e94547..b327c74ae50 100644
--- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/User.scala
+++ b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/User.scala
@@ -21,7 +21,7 @@ case class User (
email: Option[String] = None,
password: Option[String] = None,
phone: Option[String] = None,
- /* User Status */
+ // User Status
userStatus: Option[Integer] = None
)