diff --git a/bin/scala-async-petstore.sh b/bin/scala-async-petstore.sh index 1576cff65c5..5456c98b27a 100755 --- a/bin/scala-async-petstore.sh +++ b/bin/scala-async-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/asyncscala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l async-scala -o samples/client/petstore/async-scala" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/asyncscala -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l async-scala -o samples/client/petstore/async-scala" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/scala-petstore.sh b/bin/scala-petstore.sh index 390ca172395..b0ea4108160 100755 --- a/bin/scala-petstore.sh +++ b/bin/scala-petstore.sh @@ -26,6 +26,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.json -l scala -o samples/client/petstore/scala" +ags="$@ generate -t modules/swagger-codegen/src/main/resources/scala -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l scala -o samples/client/petstore/scala" java $JAVA_OPTS -jar $executable $ags diff --git a/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache b/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache index aa5888cbe3f..7f2edfd9aea 100644 --- a/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/asyncscala/api.mustache @@ -10,7 +10,7 @@ import collection.mutable class {{classname}}(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { {{#operation}} - def {{nickname}}({{#allParams}}{{^required}}{{paramName}}: Option[{{dataType}}] = {{#defaultValue}}Some({{defaultValue}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{#hasMore}},{{/hasMore}} + 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}} = { // create path and map variables @@ -21,14 +21,28 @@ class {{classname}}(client: TransportClient, config: SwaggerConfig) extends ApiC val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - {{#allParams}}// verify required params are set - val paramCount = (Set[Any]({{/allParams}}{{#required}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/required}}{{#allParams}}) - null).size - if (paramCount != {{requiredParamCount}}) sys.error("missing required params"){{/allParams}} + {{#allParams}} + {{#required}} + {{^isPrimitiveType}} + if ({{paramName}} == null) throw new Exception("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") - {{#queryParams}}{{^required}}if({{paramName}} != null) {{paramName}}.foreach { v => queryParams += "{{baseName}}" -> v.toString }{{/required}}{{#required}} - if({{paramName}} != null) queryParams += "{{baseName}}" -> {{paramName}}.toString{{/required}}{{/queryParams}} + {{/isPrimitiveType}} + {{/required}} + {{/allParams}} + {{#queryParams}} + {{^required}} + if ({{paramName}} != null) {{paramName}}.foreach { v => queryParams += "{{baseName}}" -> v.toString } - {{#headerParams}}headerParams += "{{baseName}}" -> {{paramName}}.toString{{/headerParams}} + {{/required}} + {{#required}} + if ({{paramName}} != null) queryParams += "{{baseName}}" -> {{paramName}}.toString + + {{/required}} + {{/queryParams}} + + {{#headerParams}} + headerParams += "{{baseName}}" -> {{paramName}}.toString + {{/headerParams}} val resFuture = client.submit("{{httpMethod}}", path, queryParams.toMap, headerParams.toMap, {{#bodyParam}}writer.write({{paramName}}){{/bodyParam}}{{^bodyParam}}"{{emptyBodyParam}}"{{/bodyParam}}) resFuture flatMap { resp => diff --git a/modules/swagger-codegen/src/main/resources/scala/api.mustache b/modules/swagger-codegen/src/main/resources/scala/api.mustache index bbf5048c946..6345cd876c8 100644 --- a/modules/swagger-codegen/src/main/resources/scala/api.mustache +++ b/modules/swagger-codegen/src/main/resources/scala/api.mustache @@ -46,10 +46,12 @@ class {{classname}}(val defBasePath: String = "{{basePath}}", {{#allParams}} {{#required}} + {{^isPrimitiveType}} if ({{paramName}} == null) throw new Exception("Missing required parameter '{{paramName}}' when calling {{classname}}->{{operationId}}") + + {{/isPrimitiveType}} {{/required}} {{/allParams}} - {{#queryParams}}if(String.valueOf({{paramName}}) != "null") queryParams += "{{baseName}}" -> {{paramName}}.toString {{/queryParams}} @@ -69,7 +71,8 @@ class {{classname}}(val defBasePath: String = "{{basePath}}", postBody = mp } else { - {{#formParams}}{{#notFile}}formParams += "{{baseName}}" -> {{paramName}}.toString(){{/notFile}} + {{#formParams}} + {{#notFile}}formParams += "{{baseName}}" -> {{paramName}}.toString(){{/notFile}} {{/formParams}} } @@ -85,6 +88,7 @@ class {{classname}}(val defBasePath: String = "{{basePath}}", case ex: ApiException => throw ex } } + {{/operation}} } {{/operations}} diff --git a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala index 3b2c3909453..b918b0c55f8 100644 --- a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/PetApi.scala @@ -1,8 +1,7 @@ package io.swagger.client.api import io.swagger.client.model.Pet -import io.swagger.client.model.Inline_response_200 -import io.swagger.client.model.Binary +import io.swagger.client.model.ApiResponse import java.io.File import com.wordnik.swagger.client._ import scala.concurrent.Future @@ -10,8 +9,7 @@ import collection.mutable class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - def addPet(body: Option[Pet] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { + def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { // create path and map variables val path = (addFmt("/pet")) @@ -19,36 +17,9 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->addPet") - - - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - def addPetUsingByteArray(body: Option[Binary] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Binary]): Future[Unit] = { - // create path and map variables - val path = (addFmt("/pet?testing_byte_array=true")) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => @@ -67,13 +38,6 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params") - - headerParams += "api_key" -> apiKey.toString @@ -83,8 +47,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c } } - def findPetsByStatus(status: Option[List[String]] = Some(available) - )(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { + def findPetsByStatus(status: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { // create path and map variables val path = (addFmt("/pet/findByStatus")) @@ -92,13 +55,11 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (status == null) throw new Exception("Missing required parameter 'status' when calling PetApi->findPetsByStatus") + + if (status != null) queryParams += "status" -> status.toString - if(status != null) status.foreach { v => queryParams += "status" -> v.toString } - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -106,8 +67,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c } } - def findPetsByTags(tags: Option[List[String]] = None - )(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { + def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = { // create path and map variables val path = (addFmt("/pet/findByTags")) @@ -115,13 +75,11 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (tags == null) throw new Exception("Missing required parameter 'tags' when calling PetApi->findPetsByTags") + + if (tags != null) queryParams += "tags" -> tags.toString - if(tags != null) tags.foreach { v => queryParams += "tags" -> v.toString } - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -138,13 +96,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -152,54 +104,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c } } - def getPetByIdInObject(petId: Long)(implicit reader: ClientResponseReader[Inline_response_200]): Future[Inline_response_200] = { - // create path and map variables - val path = (addFmt("/pet/{petId}?response=inline_arbitrary_object") - replaceAll ("\\{" + "petId" + "\\}",petId.toString)) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - def petPetIdtestingByteArraytrueGet(petId: Long)(implicit reader: ClientResponseReader[Binary]): Future[Binary] = { - // create path and map variables - val path = (addFmt("/pet/{petId}?testing_byte_array=true") - replaceAll ("\\{" + "petId" + "\\}",petId.toString)) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - def updatePet(body: Option[Pet] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { + def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { // create path and map variables val path = (addFmt("/pet")) @@ -207,13 +112,9 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->updatePet") - - val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => @@ -221,7 +122,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c } } - def updatePetWithForm(petId: String, + def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None )(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { @@ -233,17 +134,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -254,7 +145,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None - )(implicit reader: ClientResponseReader[Unit]): Future[Unit] = { + )(implicit reader: ClientResponseReader[ApiResponse]): Future[ApiResponse] = { // create path and map variables val path = (addFmt("/pet/{petId}/uploadImage") replaceAll ("\\{" + "petId" + "\\}",petId.toString)) @@ -263,17 +154,7 @@ class PetApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(c val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => diff --git a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/StoreApi.scala index e823ebd4e32..e17c641fcb2 100644 --- a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/StoreApi.scala +++ b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -1,7 +1,6 @@ package io.swagger.client.api import io.swagger.client.model.Order -import io.swagger.client.model.Any import com.wordnik.swagger.client._ import scala.concurrent.Future import collection.mutable @@ -17,13 +16,7 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -31,29 +24,6 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient } } - def findOrdersByStatus(status: Option[String] = Some(placed) - )(implicit reader: ClientResponseReader[List[Order]]): Future[List[Order]] = { - // create path and map variables - val path = (addFmt("/store/findByStatus")) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - if(status != null) status.foreach { v => queryParams += "status" -> v.toString } - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - def getInventory()(implicit reader: ClientResponseReader[Map[String, Integer]]): Future[Map[String, Integer]] = { // create path and map variables val path = (addFmt("/store/inventory")) @@ -62,11 +32,7 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -74,27 +40,7 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient } } - def getInventoryInObject()(implicit reader: ClientResponseReader[Any]): Future[Any] = { - // create path and map variables - val path = (addFmt("/store/inventory?response=arbitrary_object")) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - - - - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - def getOrderById(orderId: String)(implicit reader: ClientResponseReader[Order]): Future[Order] = { + 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)) @@ -103,13 +49,7 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -117,8 +57,7 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient } } - def placeOrder(body: Option[Order] = None - )(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = { + def placeOrder(body: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = { // create path and map variables val path = (addFmt("/store/order")) @@ -126,13 +65,9 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling StoreApi->placeOrder") - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => diff --git a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/UserApi.scala index 33ad25499c6..bf3294cb331 100644 --- a/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/client/petstore/async-scala/src/main/scala/io/swagger/client/api/UserApi.scala @@ -7,8 +7,7 @@ import collection.mutable class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - def createUser(body: Option[User] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { + def createUser(body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { // create path and map variables val path = (addFmt("/user")) @@ -16,13 +15,9 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUser") - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => @@ -30,8 +25,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( } } - def createUsersWithArrayInput(body: Option[List[User]] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { + def createUsersWithArrayInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { // create path and map variables val path = (addFmt("/user/createWithArray")) @@ -39,13 +33,9 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithArrayInput") - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => @@ -53,8 +43,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( } } - def createUsersWithListInput(body: Option[List[User]] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { + def createUsersWithListInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { // create path and map variables val path = (addFmt("/user/createWithList")) @@ -62,13 +51,9 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithListInput") - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => @@ -85,13 +70,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -108,13 +87,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params") - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -122,9 +95,8 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( } } - def loginUser(username: Option[String] = None, - password: Option[String] = None - )(implicit reader: ClientResponseReader[String]): Future[String] = { + def loginUser(username: String, + password: String)(implicit reader: ClientResponseReader[String]): Future[String] = { // create path and map variables val path = (addFmt("/user/login")) @@ -132,15 +104,11 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params") + if (username != null) queryParams += "username" -> username.toString + + if (password != null) queryParams += "password" -> password.toString - if(username != null) username.foreach { v => queryParams += "username" -> v.toString }if(password != null) password.foreach { v => queryParams += "password" -> v.toString } - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -156,11 +124,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - - - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") resFuture flatMap { resp => @@ -169,8 +133,7 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( } def updateUser(username: String, - body: Option[User] = None - )(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { + 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)) @@ -179,15 +142,9 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient( val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - // verify required params are set - val paramCount = (Set[Any](// verify required params are set - val paramCount = (Set[Any]() - null).size - if (paramCount != ) sys.error("missing required params")) - null).size - if (paramCount != ) sys.error("missing required params") + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->updateUser") - - val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => diff --git a/samples/client/petstore/async-scala/src/test/scala/Test.scala b/samples/client/petstore/async-scala/src/test/scala/Test.scala index d880fcb7f9c..749772a2718 100644 --- a/samples/client/petstore/async-scala/src/test/scala/Test.scala +++ b/samples/client/petstore/async-scala/src/test/scala/Test.scala @@ -1,8 +1,18 @@ +import io.swagger.client._ +import io.swagger.client.api._ +import io.swagger.client.model._ + import java.net.URI import scala.concurrent._ import scala.concurrent.duration._ import scala.util.{Failure, Success} +import org.scalatest._ +import org.junit.runner.RunWith +import org.scalatest.junit.JUnitRunner +import org.scalatest.FunSuite +import com.wordnik.swagger._ +com.wordnik.swagger.client @RunWith(classOf[JUnitRunner]) class SimpleTest extends FlatSpec with Matchers { @@ -24,4 +34,4 @@ class SimpleTest extends FlatSpec with Matchers { case Failure(t) => println("failed " + t.getMessage) } } -} \ No newline at end of file +} 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 ce0d9c2433d..f7e82cd1b61 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 @@ -1,7 +1,7 @@ package io.swagger.client.api import io.swagger.client.model.Pet -import io.swagger.client.model.InlineResponse200 +import io.swagger.client.model.ApiResponse import java.io.File import io.swagger.client.ApiInvoker import io.swagger.client.ApiException @@ -26,7 +26,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", /** * Add a new pet to the store * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store * @return void */ def addPet (body: Pet) = { @@ -40,6 +40,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->addPet") @@ -51,7 +52,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -63,46 +64,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } - /** - * Fake endpoint to test byte array in body parameter for adding a new pet to the store - * - * @param body Pet object in the form of byte array (optional) - * @return void - */ - def addPetUsingByteArray (body: String) = { - // create path and map variables - val path = "/pet?testing_byte_array=true".replaceAll("\\{format\\}","json") - val contentTypes = List("application/json", "application/xml", "application/json") - val contentType = contentTypes(0) - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - var postBody: AnyRef = body - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - } - - try { - apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } /** * Deletes a pet * @@ -123,8 +85,6 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->deletePet") - headerParams += "api_key" -> apiKey @@ -136,7 +96,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -148,13 +108,14 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Finds Pets by status * Multiple status values can be provided with comma separated strings - * @param status Status values that need to be considered for query (optional, default to available) + * @param status Status values that need to be considered for filter * @return List[Pet] */ - def findPetsByStatus (status: List[String] /* = available */) : Option[List[Pet]] = { + def findPetsByStatus (status: List[String]) : Option[List[Pet]] = { // create path and map variables val path = "/pet/findByStatus".replaceAll("\\{format\\}","json") val contentTypes = List("application/json") @@ -165,6 +126,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (status == null) throw new Exception("Missing required parameter 'status' when calling PetApi->findPetsByStatus") if(String.valueOf(status) != "null") queryParams += "status" -> status.toString @@ -177,7 +139,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -190,10 +152,11 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Finds Pets by tags - * Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing. - * @param tags Tags to filter by (optional) + * Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. + * @param tags Tags to filter by * @return List[Pet] */ def findPetsByTags (tags: List[String]) : Option[List[Pet]] = { @@ -207,6 +170,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (tags == null) throw new Exception("Missing required parameter 'tags' when calling PetApi->findPetsByTags") if(String.valueOf(tags) != "null") queryParams += "tags" -> tags.toString @@ -219,7 +183,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -232,10 +196,11 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Find pet by ID - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched + * Returns a single pet + * @param petId ID of pet to return * @return Pet */ def getPetById (petId: Long) : Option[Pet] = { @@ -251,8 +216,6 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->getPetById") - var postBody: AnyRef = null @@ -263,7 +226,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -276,98 +239,11 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } - /** - * Fake endpoint to test inline arbitrary object return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched - * @return InlineResponse200 - */ - def getPetByIdInObject (petId: Long) : Option[InlineResponse200] = { - // create path and map variables - val path = "/pet/{petId}?response=inline_arbitrary_object".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) - - val contentTypes = List("application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->getPetByIdInObject") - - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - } - - try { - apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - Some(ApiInvoker.deserialize(s, "", classOf[InlineResponse200]).asInstanceOf[InlineResponse200]) - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } - /** - * Fake endpoint to test byte array return by 'Find pet by ID' - * Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions - * @param petId ID of pet that needs to be fetched - * @return String - */ - def petPetIdtestingByteArraytrueGet (petId: Long) : Option[String] = { - // create path and map variables - val path = "/pet/{petId}?testing_byte_array=true".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) - - - val contentTypes = List("application/json") - val contentType = contentTypes(0) - - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->petPetIdtestingByteArraytrueGet") - - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - } - - try { - apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - Some(ApiInvoker.deserialize(s, "", classOf[String]).asInstanceOf[String]) - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } /** * Update an existing pet * - * @param body Pet object that needs to be added to the store (optional) + * @param body Pet object that needs to be added to the store * @return void */ def updatePet (body: Pet) = { @@ -381,6 +257,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->updatePet") @@ -392,7 +269,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -404,6 +281,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Updates a pet in the store with form data * @@ -412,7 +290,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", * @param status Updated status of the pet (optional) * @return void */ - def updatePetWithForm (petId: String, name: String, status: String) = { + def updatePetWithForm (petId: Long, name: String, status: String) = { // create path and map variables val path = "/pet/{petId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -425,8 +303,6 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->updatePetWithForm") - var postBody: AnyRef = null @@ -442,7 +318,7 @@ class PetApi(val defBasePath: String = "http://petstore.swagger.io/v2", } else { formParams += "name" -> name.toString() -formParams += "status" -> status.toString() + formParams += "status" -> status.toString() } try { @@ -455,15 +331,16 @@ formParams += "status" -> status.toString() case ex: ApiException => throw ex } } + /** * 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) - * @return void + * @return ApiResponse */ - def uploadFile (petId: Long, additionalMetadata: String, file: File) = { + def uploadFile (petId: Long, additionalMetadata: String, file: File) : Option[ApiResponse] = { // create path and map variables val path = "/pet/{petId}/uploadImage".replaceAll("\\{format\\}","json").replaceAll("\\{" + "petId" + "\\}",apiInvoker.escape(petId)) @@ -476,8 +353,6 @@ formParams += "status" -> status.toString() val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (petId == null) throw new Exception("Missing required parameter 'petId' when calling PetApi->uploadFile") - var postBody: AnyRef = null @@ -494,17 +369,19 @@ formParams += "status" -> status.toString() } else { formParams += "additionalMetadata" -> additionalMetadata.toString() - + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { case s: String => - case _ => None + Some(ApiInvoker.deserialize(s, "", classOf[ApiResponse]).asInstanceOf[ApiResponse]) + case _ => None } } catch { case ex: ApiException if ex.code == 404 => None case ex: ApiException => throw ex } } + } 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 f1d0ac8a84c..c507ad34403 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 @@ -40,8 +40,6 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (orderId == null) throw new Exception("Missing required parameter 'orderId' when calling StoreApi->deleteOrder") - var postBody: AnyRef = null @@ -52,7 +50,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -64,48 +62,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } - /** - * Finds orders by status - * A single status value can be provided as a string - * @param status Status value that needs to be considered for query (optional, default to placed) - * @return List[Order] - */ - def findOrdersByStatus (status: String /* = placed */) : Option[List[Order]] = { - // create path and map variables - val path = "/store/findByStatus".replaceAll("\\{format\\}","json") - val contentTypes = List("application/json") - val contentType = contentTypes(0) - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - if(String.valueOf(status) != "null") queryParams += "status" -> status.toString - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - } - - try { - apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - Some(ApiInvoker.deserialize(s, "array", classOf[Order]).asInstanceOf[List[Order]]) - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } /** * Returns pet inventories by status * Returns a map of status codes to quantities @@ -122,7 +79,6 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - var postBody: AnyRef = null @@ -133,7 +89,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -146,53 +102,14 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } - /** - * Fake endpoint to test arbitrary object return by 'Get inventory' - * Returns an arbitrary object which is actually a map of status codes to quantities - * @return Any - */ - def getInventoryInObject () : Option[Any] = { - // create path and map variables - val path = "/store/inventory?response=arbitrary_object".replaceAll("\\{format\\}","json") - val contentTypes = List("application/json") - val contentType = contentTypes(0) - // query params - val queryParams = new HashMap[String, String] - val headerParams = new HashMap[String, String] - val formParams = new HashMap[String, String] - - - - - var postBody: AnyRef = null - - if(contentType.startsWith("multipart/form-data")) { - val mp = new FormDataMultiPart() - - postBody = mp - } - else { - } - - try { - apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { - case s: String => - Some(ApiInvoker.deserialize(s, "", classOf[Any]).asInstanceOf[Any]) - case _ => None - } - } catch { - case ex: ApiException if ex.code == 404 => None - case ex: ApiException => throw ex - } - } /** * 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 */ - def getOrderById (orderId: String) : Option[Order] = { + def getOrderById (orderId: Long) : Option[Order] = { // create path and map variables val path = "/store/order/{orderId}".replaceAll("\\{format\\}","json").replaceAll("\\{" + "orderId" + "\\}",apiInvoker.escape(orderId)) @@ -205,8 +122,6 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (orderId == null) throw new Exception("Missing required parameter 'orderId' when calling StoreApi->getOrderById") - var postBody: AnyRef = null @@ -217,7 +132,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -230,10 +145,11 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Place an order for a pet * - * @param body order placed for purchasing the pet (optional) + * @param body order placed for purchasing the pet * @return Order */ def placeOrder (body: Order) : Option[Order] = { @@ -247,6 +163,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling StoreApi->placeOrder") @@ -258,7 +175,7 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -271,4 +188,5 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + } 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 e8d65f74040..010ec2da652 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 @@ -24,7 +24,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", /** * Create user * This can only be done by the logged in user. - * @param body Created user object (optional) + * @param body Created user object * @return void */ def createUser (body: User) = { @@ -38,6 +38,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUser") @@ -49,7 +50,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -61,10 +62,11 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object * @return void */ def createUsersWithArrayInput (body: List[User]) = { @@ -78,6 +80,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithArrayInput") @@ -89,7 +92,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -101,10 +104,11 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Creates list of users with given input array * - * @param body List of user object (optional) + * @param body List of user object * @return void */ def createUsersWithListInput (body: List[User]) = { @@ -118,6 +122,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithListInput") @@ -129,7 +134,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -141,6 +146,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Delete user * This can only be done by the logged in user. @@ -160,8 +166,6 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->deleteUser") - var postBody: AnyRef = null @@ -172,7 +176,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "DELETE", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -184,6 +188,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Get user by user name * @@ -203,8 +208,6 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->getUserByName") - var postBody: AnyRef = null @@ -215,7 +218,7 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -228,11 +231,12 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", case ex: ApiException => throw ex } } + /** * Logs user into the system * - * @param username The user name for login (optional) - * @param password The password for login in clear text (optional) + * @param username The user name for login + * @param password The password for login in clear text * @return String */ def loginUser (username: String, password: String) : Option[String] = { @@ -246,7 +250,6 @@ class UserApi(val defBasePath: String = "http://petstore.swagger.io/v2", val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if(String.valueOf(username) != "null") queryParams += "username" -> username.toString if(String.valueOf(password) != "null") queryParams += "password" -> password.toString @@ -259,7 +262,7 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -272,6 +275,7 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS case ex: ApiException => throw ex } } + /** * Logs out current logged in user session * @@ -288,7 +292,6 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - var postBody: AnyRef = null @@ -299,7 +302,7 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "GET", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -311,11 +314,12 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS case ex: ApiException => throw ex } } + /** * 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 (optional) + * @param body Updated user object * @return void */ def updateUser (username: String, body: User) = { @@ -331,7 +335,7 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS val headerParams = new HashMap[String, String] val formParams = new HashMap[String, String] - if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->updateUser") + if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->updateUser") @@ -343,7 +347,7 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS postBody = mp } else { - } + } try { apiInvoker.invokeApi(basePath, path, "PUT", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match { @@ -355,4 +359,5 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS case ex: ApiException => throw ex } } + } diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala deleted file mode 100644 index 874afe3d55a..00000000000 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/InlineResponse200.scala +++ /dev/null @@ -1,13 +0,0 @@ -package io.swagger.client.model - - - - -case class InlineResponse200 ( - tags: List[Tag], -id: Long, -category: Any, -/* pet status in the store */ - status: String, -name: String, -photoUrls: List[String]) diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Model200Response.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Model200Response.scala deleted file mode 100644 index 1be66a217a2..00000000000 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Model200Response.scala +++ /dev/null @@ -1,7 +0,0 @@ -package io.swagger.client.model - - - - -case class Model200Response ( - name: Integer) diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala deleted file mode 100644 index 93425065d39..00000000000 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/ModelReturn.scala +++ /dev/null @@ -1,7 +0,0 @@ -package io.swagger.client.model - - - - -case class ModelReturn ( - _return: Integer) diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala deleted file mode 100644 index 01b20e827b6..00000000000 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/Name.scala +++ /dev/null @@ -1,8 +0,0 @@ -package io.swagger.client.model - - - - -case class Name ( - name: Integer, -snakeCase: Integer) diff --git a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala b/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala deleted file mode 100644 index f934822dc80..00000000000 --- a/samples/client/petstore/scala/src/main/scala/io/swagger/client/model/SpecialModelName.scala +++ /dev/null @@ -1,7 +0,0 @@ -package io.swagger.client.model - - - - -case class SpecialModelName ( - specialPropertyName: Long)