forked from loafle/openapi-generator-original
fix requireParameterCount in scala
This commit is contained in:
parent
c317f99466
commit
79decc53a1
@ -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
|
||||
|
@ -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
|
||||
|
@ -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 =>
|
||||
|
@ -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}}
|
||||
|
@ -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,34 +17,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("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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->addPet")
|
||||
|
||||
|
||||
|
||||
@ -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,11 +55,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 (status == null) throw new Exception("Missing required parameter 'status' when calling PetApi->findPetsByStatus")
|
||||
|
||||
if(status != null) status.foreach { v => queryParams += "status" -> v.toString }
|
||||
if (status != null) queryParams += "status" -> status.toString
|
||||
|
||||
|
||||
|
||||
@ -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,11 +75,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 (tags == null) throw new Exception("Missing required parameter 'tags' when calling PetApi->findPetsByTags")
|
||||
|
||||
if(tags != null) tags.foreach { v => queryParams += "tags" -> v.toString }
|
||||
if (tags != null) queryParams += "tags" -> tags.toString
|
||||
|
||||
|
||||
|
||||
@ -138,12 +96,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]() - null).size
|
||||
if (paramCount != ) sys.error("missing required params")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
@ -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,11 +112,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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling PetApi->updatePet")
|
||||
|
||||
|
||||
|
||||
@ -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,16 +134,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](// 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, "")
|
||||
@ -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,16 +154,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](// 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, "")
|
||||
|
@ -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,12 +16,6 @@ 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, "")
|
||||
@ -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"))
|
||||
@ -64,37 +34,13 @@ class StoreApi(client: TransportClient, config: SwaggerConfig) extends ApiClient
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
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,12 +49,6 @@ 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, "")
|
||||
@ -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,11 +65,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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling StoreApi->placeOrder")
|
||||
|
||||
|
||||
|
||||
|
@ -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,11 +15,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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUser")
|
||||
|
||||
|
||||
|
||||
@ -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,11 +33,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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithArrayInput")
|
||||
|
||||
|
||||
|
||||
@ -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,11 +51,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")
|
||||
|
||||
|
||||
if (body == null) throw new Exception("Missing required parameter 'body' when calling UserApi->createUsersWithListInput")
|
||||
|
||||
|
||||
|
||||
@ -85,12 +70,6 @@ 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, "")
|
||||
@ -108,12 +87,6 @@ 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, "")
|
||||
@ -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,13 +104,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 (username != null) queryParams += "username" -> username.toString
|
||||
|
||||
if(username != null) username.foreach { v => queryParams += "username" -> v.toString }if(password != null) password.foreach { v => queryParams += "password" -> v.toString }
|
||||
if (password != null) queryParams += "password" -> password.toString
|
||||
|
||||
|
||||
|
||||
@ -158,10 +126,6 @@ class UserApi(client: TransportClient, config: SwaggerConfig) extends ApiClient(
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(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,13 +142,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](// 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")
|
||||
|
||||
|
||||
|
||||
|
@ -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 {
|
||||
|
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -500,6 +375,7 @@ formParams += "status" -> status.toString()
|
||||
try {
|
||||
apiInvoker.invokeApi(basePath, path, "POST", queryParams.toMap, formParams.toMap, postBody, headerParams.toMap, contentType) match {
|
||||
case s: String =>
|
||||
Some(ApiInvoker.deserialize(s, "", classOf[ApiResponse]).asInstanceOf[ApiResponse])
|
||||
case _ => None
|
||||
}
|
||||
} catch {
|
||||
@ -507,4 +383,5 @@ formParams += "status" -> status.toString()
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
@ -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
|
||||
@ -124,7 +81,6 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
||||
|
||||
|
||||
|
||||
|
||||
var postBody: AnyRef = null
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
@ -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
|
||||
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -271,4 +188,5 @@ class StoreApi(val defBasePath: String = "http://petstore.swagger.io/v2",
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
*
|
||||
@ -290,7 +294,6 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS
|
||||
|
||||
|
||||
|
||||
|
||||
var postBody: AnyRef = null
|
||||
|
||||
if(contentType.startsWith("multipart/form-data")) {
|
||||
@ -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")
|
||||
|
||||
|
||||
|
||||
@ -355,4 +359,5 @@ if(String.valueOf(password) != "null") queryParams += "password" -> password.toS
|
||||
case ex: ApiException => throw ex
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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])
|
@ -1,7 +0,0 @@
|
||||
package io.swagger.client.model
|
||||
|
||||
|
||||
|
||||
|
||||
case class Model200Response (
|
||||
name: Integer)
|
@ -1,7 +0,0 @@
|
||||
package io.swagger.client.model
|
||||
|
||||
|
||||
|
||||
|
||||
case class ModelReturn (
|
||||
_return: Integer)
|
@ -1,8 +0,0 @@
|
||||
package io.swagger.client.model
|
||||
|
||||
|
||||
|
||||
|
||||
case class Name (
|
||||
name: Integer,
|
||||
snakeCase: Integer)
|
@ -1,7 +0,0 @@
|
||||
package io.swagger.client.model
|
||||
|
||||
|
||||
|
||||
|
||||
case class SpecialModelName (
|
||||
specialPropertyName: Long)
|
Loading…
x
Reference in New Issue
Block a user