fix requireParameterCount in scala

This commit is contained in:
wing328
2016-04-16 00:09:15 +08:00
parent c317f99466
commit 79decc53a1
16 changed files with 138 additions and 579 deletions

View File

@@ -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 =>

View File

@@ -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 =>

View File

@@ -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 =>

View File

@@ -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)
}
}
}
}