diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java index d8c143aad1d..6ad296a0210 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaClientCodegen.java @@ -20,6 +20,9 @@ import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig { protected String invokerPackage = "io.swagger.client"; @@ -214,4 +217,17 @@ public class ScalaClientCodegen extends DefaultCodegen implements CodegenConfig return camelize(operationId, true); } + @Override + public Map postProcessModels(Map objs) { + // remove model imports to avoid warnings for importing class in the same package in Scala + List> imports = (List>) objs.get("imports"); + final String prefix = modelPackage() + "."; + Iterator> iterator = imports.iterator(); + while (iterator.hasNext()) { + String _import = iterator.next().get("import"); + if (_import.startsWith(prefix)) iterator.remove(); + } + return objs; + } + } diff --git a/modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache b/modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache index f432c2dc59e..9c2e9c073cd 100644 --- a/modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/apiInvoker.mustache @@ -141,7 +141,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, } case _ => null } - response.getClientResponseStatus().getStatusCode() match { + response.getStatusInfo().getStatusCode() match { case 204 => "" case code: Int if (Range(200, 299).contains(code)) => { response.hasEntity() match { @@ -155,7 +155,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, case false => "no data" } throw new ApiException( - response.getClientResponseStatus().getStatusCode(), + response.getStatusInfo().getStatusCode(), entity) } } @@ -172,7 +172,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, } } } - + def newClient(host: String): Client = asyncHttpClient match { case true => { import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig @@ -200,4 +200,3 @@ object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper, authPreemptive = {{authPreemptive}}) class ApiException(val code: Int, msg: String) extends RuntimeException(msg) - diff --git a/modules/swagger-codegen/src/main/resources/scala/pom.mustache b/modules/swagger-codegen/src/main/resources/scala/pom.mustache index 2d8a1257eb4..c6fe4a1f356 100644 --- a/modules/swagger-codegen/src/main/resources/scala/pom.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/pom.mustache @@ -72,6 +72,7 @@ org.codehaus.mojo build-helper-maven-plugin + 1.9.1 add_sources @@ -208,7 +209,7 @@ 2.10.4 1.2 2.2 - 1.7 + 1.19 1.5.0 1.0.5 1.0.0 @@ -216,6 +217,8 @@ 4.8.1 3.1.5 - 2.1.3 + 2.2.4 + + UTF-8 diff --git a/samples/client/petstore/scala/pom.xml b/samples/client/petstore/scala/pom.xml index 7e56a41c890..9f39f4e45ce 100644 --- a/samples/client/petstore/scala/pom.xml +++ b/samples/client/petstore/scala/pom.xml @@ -72,6 +72,7 @@ org.codehaus.mojo build-helper-maven-plugin + 1.9.1 add_sources @@ -208,7 +209,7 @@ 2.10.4 1.2 2.2 - 1.7 + 1.19 1.5.0 1.0.5 1.0.0 @@ -216,6 +217,8 @@ 4.8.1 3.1.5 - 2.1.3 + 2.2.4 + + 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 91ab98471e9..1f9d3c012d5 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 @@ -141,7 +141,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, } case _ => null } - response.getClientResponseStatus().getStatusCode() match { + response.getStatusInfo().getStatusCode() match { case 204 => "" case code: Int if (Range(200, 299).contains(code)) => { response.hasEntity() match { @@ -155,7 +155,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, case false => "no data" } throw new ApiException( - response.getClientResponseStatus().getStatusCode(), + response.getStatusInfo().getStatusCode(), entity) } } @@ -172,7 +172,7 @@ class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper, } } } - + def newClient(host: String): Client = asyncHttpClient match { case true => { import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig @@ -200,4 +200,3 @@ object ApiInvoker extends ApiInvoker(mapper = ScalaJsonUtil.getJsonMapper, authPreemptive = false) class ApiException(val code: Int, msg: String) extends RuntimeException(msg) - 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 430f6a3659c..30dc8750976 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 @@ -1,7 +1,5 @@ package io.swagger.client.model -import io.swagger.client.model.Category -import io.swagger.client.model.Tag