From 96708a078d733e4b9e93ee46089cb8a67fd873a1 Mon Sep 17 00:00:00 2001 From: Greg Marzouka Date: Thu, 28 Dec 2017 22:55:33 -0500 Subject: [PATCH 1/2] [Scala] Fix async helper methods when body is optional Closes #7272 --- modules/swagger-codegen/src/main/resources/scala/api.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache index e7fedfd4d4b..56bd14295d2 100644 --- a/modules/swagger-codegen/src/main/resources/scala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache @@ -93,7 +93,7 @@ class {{classname}}AsyncHelper(client: TransportClient, config: SwaggerConfig) e {{#operation}} def {{operationId}}({{#allParams}}{{^required}}{{paramName}}: Option[{{dataType}}] = {{#defaultValue}}Some({{defaultValue}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{#hasMore}},{{/hasMore}} {{/required}}{{#required}}{{paramName}}: {{dataType}}{{#defaultValue}} = {{{defaultValue}}}{{/defaultValue}}{{#hasMore}}, - {{/hasMore}}{{/required}}{{/allParams}})(implicit reader: ClientResponseReader[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]{{#bodyParams}}, writer: RequestWriter[{{dataType}}]{{/bodyParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = { + {{/hasMore}}{{/required}}{{/allParams}})(implicit reader: ClientResponseReader[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]{{#bodyParams}}, writer: RequestWriter[{{^required}}Option[{{dataType}}]{{/required}}{{#required}}{{dataType}}{{/required}}]{{/bodyParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = { // create path and map variables val path = (addFmt("{{path}}"){{#pathParams}} replaceAll("\\{" + "{{baseName}}" + "\\}", {{paramName}}.toString){{/pathParams}}) From eb443f55cc163d87b6c06dfd5a46791ff7c2b75f Mon Sep 17 00:00:00 2001 From: Greg Marzouka Date: Thu, 28 Dec 2017 23:56:30 -0500 Subject: [PATCH 2/2] Update petstore sample --- .../scala/.swagger-codegen/VERSION | 2 +- .../petstore-security-test/scala/build.sbt | 28 +- .../petstore-security-test/scala/pom.xml | 474 +++++++++--------- .../scala/io/swagger/client/ApiInvoker.scala | 71 +-- .../scala/io/swagger/client/AsyncClient.scala | 4 +- .../scala/io/swagger/client/api/FakeApi.scala | 18 +- .../io/swagger/client/model/ModelReturn.scala | 2 +- .../petstore/scala/.swagger-codegen/VERSION | 2 +- samples/client/petstore/scala/build.sbt | 28 +- samples/client/petstore/scala/pom.xml | 474 +++++++++--------- .../scala/io/swagger/client/ApiInvoker.scala | 71 +-- .../scala/io/swagger/client/AsyncClient.scala | 4 +- .../scala/io/swagger/client/api/PetApi.scala | 54 +- .../io/swagger/client/api/StoreApi.scala | 34 +- .../scala/io/swagger/client/api/UserApi.scala | 52 +- .../scala/io/swagger/client/model/Order.scala | 2 +- .../scala/io/swagger/client/model/Pet.scala | 2 +- .../scala/io/swagger/client/model/User.scala | 2 +- 18 files changed, 702 insertions(+), 622 deletions(-) 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..9021d4e6389 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 @@ -48,12 +48,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 +62,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 +84,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..27547e262b1 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 @@ -51,12 +51,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 +65,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 +87,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 +98,7 @@ class PetApi( /** * Deletes a pet * + * * @param petId Pet id to delete * @param apiKey (optional) * @return void @@ -111,10 +114,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 +126,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 +141,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 +152,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 +167,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 +178,7 @@ class PetApi( /** * Find pet by ID * Returns a single pet + * * @param petId ID of pet to return * @return Pet */ @@ -184,9 +193,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 +204,7 @@ class PetApi( /** * Update an existing pet * + * * @param body Pet object that needs to be added to the store * @return void */ @@ -208,9 +219,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 +230,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 +247,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 +260,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 +277,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 +312,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 +366,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 +401,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 +420,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..c081a19be90 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 @@ -49,12 +49,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 +63,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 +85,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 +96,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 +110,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 +120,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 +135,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 +146,7 @@ class StoreApi( /** * Place an order for a pet * + * * @param body order placed for purchasing the pet * @return Order */ @@ -154,9 +161,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 +176,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 +209,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..d0101d89032 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 @@ -49,12 +49,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 +63,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 +85,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 +96,7 @@ class UserApi( /** * Creates list of users with given input array * + * * @param body List of user object * @return void */ @@ -108,9 +111,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 +122,7 @@ class UserApi( /** * Creates list of users with given input array * + * * @param body List of user object * @return void */ @@ -132,9 +137,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 +148,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 +163,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 +174,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 +189,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 +200,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 +216,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 +228,7 @@ class UserApi( /** * Logs out current logged in user session * + * * @return void */ def logoutUser() = { @@ -229,8 +242,9 @@ class UserApi( /** * Logs out current logged in user session asynchronously * + * * @return Future(void) - */ + */ def logoutUserAsync() = { helper.logoutUser() } @@ -238,6 +252,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 +268,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 +332,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 +350,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 +406,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 )