mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-08 09:46:08 +00:00
PR for ability to easily debug newly created codegen classes. (#2388)
* 2nd attempt to make the automatic checkin testing work * trying to submit the samples in hopes that the CI matches them and passes * found some samples I hadn't updated. Maybe this is it?
This commit is contained in:
committed by
Akihito Nakano
parent
07e8b5ae03
commit
e5a0d18374
@@ -0,0 +1,94 @@
|
||||
import org.openapitools.client._
|
||||
import org.openapitools.client.api._
|
||||
import org.openapitools.client.model._
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest._
|
||||
|
||||
import scala.collection.mutable.{ ListBuffer, HashMap }
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.beans.BeanProperty
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class PetApiTest extends FlatSpec with Matchers {
|
||||
behavior of "PetApi"
|
||||
val api = new PetApi
|
||||
|
||||
it should "add and fetch a pet" in {
|
||||
val pet = Pet(
|
||||
Some(1000),
|
||||
Some(Category(Some(1), Some("sold"))),
|
||||
"dragon",
|
||||
(for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList,
|
||||
Some((for (i <- (1 to 5)) yield org.openapitools.client.model.Tag(Some(i), Some("tag-" + i))).toList),
|
||||
Some("lost")
|
||||
)
|
||||
|
||||
api.addPet(pet)
|
||||
api.getPetById(1000) match {
|
||||
case Some(pet) => {
|
||||
pet.id should be(Some(1000))
|
||||
pet.tags.get.size should be(5)
|
||||
pet.status should be(Some("lost"))
|
||||
pet.category should not be (null)
|
||||
pet.category.get.name should be(Some("sold"))
|
||||
pet.name should be("dragon")
|
||||
pet.photoUrls.size should be(10)
|
||||
}
|
||||
case None => fail("didn't find pet created")
|
||||
}
|
||||
}
|
||||
|
||||
it should "update a pet" in {
|
||||
val pet = Pet(
|
||||
Some(1000),
|
||||
Some(Category(Some(1), Some("sold"))),
|
||||
"programmer",
|
||||
(for (i <- (1 to 10)) yield "http://foo.com/photo/" + i).toList,
|
||||
Some((for (i <- (1 to 5)) yield org.openapitools.client.model.Tag(Some(i), Some("tag-" + i))).toList),
|
||||
Some("confused")
|
||||
)
|
||||
|
||||
api.addPet(pet)
|
||||
|
||||
api.getPetById(1000) match {
|
||||
case Some(pet) => {
|
||||
pet.name should be("programmer")
|
||||
pet.status should be(Some("confused"))
|
||||
}
|
||||
case None => fail("didn't find pet created")
|
||||
}
|
||||
val updatedPet = pet.copy(status = Some("fulfilled"))
|
||||
api.updatePet(updatedPet)
|
||||
api.getPetById(1000) match {
|
||||
case Some(pet) => {
|
||||
pet.name should be("programmer")
|
||||
pet.status should be(Some("fulfilled"))
|
||||
}
|
||||
case None => fail("didn't find pet updated")
|
||||
}
|
||||
}
|
||||
|
||||
it should "find pets by status" in {
|
||||
api.findPetsByStatus(List("available")) match {
|
||||
case Some(pets) => {
|
||||
pets.foreach(pet => pet.status should be("available"))
|
||||
}
|
||||
case None => fail("didn't find pets by status")
|
||||
}
|
||||
}
|
||||
|
||||
it should "find pets by tag" in {
|
||||
api.findPetsByTags(List("tag1", "tag2")) match {
|
||||
case Some(pets) => {
|
||||
pets.foreach(pet => {
|
||||
val tags = (for (tag <- pet.tags.get) yield tag.name).toSet
|
||||
if ((tags & Set(Some("tag1"), Some("tag2"))).size == 0)
|
||||
fail("unexpected tags in " + tags)
|
||||
})
|
||||
}
|
||||
case None => fail("didn't find pets by tag")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import org.openapitools.client._
|
||||
import org.openapitools.client.api._
|
||||
import org.openapitools.client.model._
|
||||
import org.joda.time.DateTime
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest._
|
||||
|
||||
import scala.collection.mutable.{ ListBuffer, HashMap }
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.beans.BeanProperty
|
||||
import java.util.Date
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class StoreApiTest extends FlatSpec with Matchers {
|
||||
behavior of "StoreApi"
|
||||
val api = new StoreApi
|
||||
|
||||
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
||||
|
||||
it should "place and fetch an order" in {
|
||||
val now = new Date()
|
||||
val order = Order(
|
||||
petId = Some(10),
|
||||
id = Some(1000),
|
||||
quantity = Some(101),
|
||||
status = Some("pending"),
|
||||
shipDate = Some(now),
|
||||
complete = Some(true))
|
||||
|
||||
api.placeOrder(order)
|
||||
|
||||
api.getOrderById(1000) match {
|
||||
case Some(order) => {
|
||||
order.id.get should be(1000)
|
||||
order.petId.get should be(10)
|
||||
order.quantity.get should be(101)
|
||||
order.shipDate.get.getTime().equals(now.getTime()) should be(true)
|
||||
}
|
||||
case None => fail("didn't find order created")
|
||||
}
|
||||
}
|
||||
|
||||
it should "delete an order" in {
|
||||
val now = new Date()
|
||||
val order = Order(
|
||||
id = Some(1001),
|
||||
petId = Some(10),
|
||||
quantity = Some(101),
|
||||
status = Some("pending"),
|
||||
shipDate = Some(now),
|
||||
complete = Some(true))
|
||||
|
||||
api.placeOrder(order)
|
||||
|
||||
api.getOrderById(1001) match {
|
||||
case Some(order) => order.id should be(Some(1001))
|
||||
case None => fail("didn't find order created")
|
||||
}
|
||||
|
||||
api.deleteOrder("1001")
|
||||
/* comment out the following as the client cannot handle
|
||||
* 4xx response yet
|
||||
api.getOrderById(1001) match {
|
||||
case Some(order) => fail("order should have been deleted")
|
||||
case None =>
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
150
samples/client/petstore/scala-httpclient/bin/UserApiTest.scala
Normal file
150
samples/client/petstore/scala-httpclient/bin/UserApiTest.scala
Normal file
@@ -0,0 +1,150 @@
|
||||
import org.openapitools.client._
|
||||
import org.openapitools.client.api._
|
||||
import org.openapitools.client.model._
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.junit.JUnitRunner
|
||||
import org.scalatest._
|
||||
|
||||
import scala.collection.mutable.{ ListBuffer, HashMap }
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.beans.BeanProperty
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class UserApiTest extends FlatSpec with Matchers with BeforeAndAfterAll {
|
||||
behavior of "UserApi"
|
||||
val api = new UserApi
|
||||
api.apiInvoker.defaultHeaders += "api_key" -> "special-key"
|
||||
|
||||
// preparation before running a test
|
||||
override def beforeAll() {
|
||||
val user = User(
|
||||
Some(11222),
|
||||
Some("scala-test-username"),
|
||||
Some("scala-test-first"),
|
||||
Some("scala-test-last"),
|
||||
Some("scala_test@fail.com"),
|
||||
Some("SCALATEST"),
|
||||
Some("408-867-5309"),
|
||||
Some(1))
|
||||
|
||||
api.createUser(user)
|
||||
}
|
||||
|
||||
// cleanup after running a test
|
||||
override def afterAll() {
|
||||
api.deleteUser("scala-test-username")
|
||||
}
|
||||
|
||||
it should "fetch a user" in {
|
||||
api.getUserByName("scala-test-username") match {
|
||||
case Some(user) => {
|
||||
user.id should be(Some(11222))
|
||||
user.username should be(Some("scala-test-username"))
|
||||
user.password should be(Some("SCALATEST"))
|
||||
user.email should be(Some("scala_test@fail.com"))
|
||||
user.firstName should be(Some("scala-test-first"))
|
||||
user.lastName should be(Some("scala-test-last"))
|
||||
user.phone should be(Some("408-867-5309"))
|
||||
user.userStatus should be(Some(1))
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
|
||||
it should "authenticate a user" in {
|
||||
api.loginUser("scala-test-username", "SCALATEST") match {
|
||||
case Some(status) => status.startsWith("logged in user session") match {
|
||||
case true => // success!
|
||||
case _ => fail("didn't get expected message " + status)
|
||||
}
|
||||
case None => fail("not able to login")
|
||||
}
|
||||
}
|
||||
|
||||
it should "log out a user" in {
|
||||
api.logoutUser
|
||||
}
|
||||
|
||||
it should "create 2 users" in {
|
||||
val userArray = (for (i <- (1 to 2)) yield {
|
||||
User(
|
||||
Some(2000 + i),
|
||||
Some("johnny-" + i),
|
||||
Some("Johnny"),
|
||||
Some("Rocket-" + i),
|
||||
Some("johnny-" + i + "@fail.com"),
|
||||
Some("XXXXXXXXXXX"),
|
||||
Some("408-867-5309"),
|
||||
Some(1))
|
||||
}).toList
|
||||
api.createUsersWithArrayInput(userArray)
|
||||
|
||||
for (i <- (1 to 2)) {
|
||||
api.getUserByName("johnny-" + i) match {
|
||||
case Some(user) => {
|
||||
user.id should be(Some(2000 + i))
|
||||
user.email should be(Some("johnny-" + i + "@fail.com"))
|
||||
}
|
||||
case None => fail("didn't find user " + i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it should "create 3 users" in {
|
||||
val userList = (for (i <- (1 to 3)) yield {
|
||||
User(
|
||||
Some(3000 + i),
|
||||
Some("fred-" + i),
|
||||
Some("Johnny"),
|
||||
Some("Rocket-" + i),
|
||||
Some("fred-" + i + "@fail.com"),
|
||||
Some("XXXXXXXXXXX"),
|
||||
Some("408-867-5309"),
|
||||
Some(1))
|
||||
}).toList
|
||||
api.createUsersWithListInput(userList)
|
||||
|
||||
for (i <- (1 to 3)) {
|
||||
api.getUserByName("fred-" + i) match {
|
||||
case Some(user) => {
|
||||
user.id should be(Some(3000 + i))
|
||||
user.email should be(Some("fred-" + i + "@fail.com"))
|
||||
}
|
||||
case None => fail("didn't find user " + i)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it should "update a user" in {
|
||||
val user = User(
|
||||
Some(4000),
|
||||
Some("tony"),
|
||||
Some("Tony"),
|
||||
Some("Tiger"),
|
||||
Some("tony@fail.com"),
|
||||
Some("XXXXXXXXXXX"),
|
||||
Some("408-867-5309"),
|
||||
Some(1))
|
||||
|
||||
api.createUser(user)
|
||||
|
||||
api.getUserByName("tony") match {
|
||||
case Some(user) => {
|
||||
user.id should be(Some(4000))
|
||||
user.username should be(Some("tony"))
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
|
||||
val updatedUser = user.copy(email = Some("tony@succeed.com"))
|
||||
|
||||
api.updateUser("tony", updatedUser)
|
||||
api.getUserByName("tony") match {
|
||||
case Some(user) => {
|
||||
user.email should be(Some("tony@succeed.com"))
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client
|
||||
|
||||
import com.sun.jersey.api.client.Client
|
||||
import com.sun.jersey.api.client.ClientResponse
|
||||
import com.sun.jersey.api.client.config.ClientConfig
|
||||
import com.sun.jersey.api.client.config.DefaultClientConfig
|
||||
import com.sun.jersey.api.client.filter.LoggingFilter
|
||||
|
||||
import com.sun.jersey.core.util.MultivaluedMapImpl
|
||||
import com.sun.jersey.multipart.FormDataMultiPart
|
||||
import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
|
||||
import java.io.File
|
||||
import java.net.URLEncoder
|
||||
import java.util.UUID
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.collection.mutable
|
||||
|
||||
import com.fasterxml.jackson.module.scala.DefaultScalaModule
|
||||
import com.fasterxml.jackson.datatype.joda.JodaModule
|
||||
import com.fasterxml.jackson.core.JsonGenerator.Feature
|
||||
import com.fasterxml.jackson.databind._
|
||||
import com.fasterxml.jackson.annotation._
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize
|
||||
|
||||
object ScalaJsonUtil {
|
||||
def getJsonMapper: ObjectMapper = {
|
||||
val mapper = new ObjectMapper()
|
||||
mapper.registerModule(new DefaultScalaModule())
|
||||
mapper.registerModule(new JodaModule())
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL)
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_DEFAULT)
|
||||
mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false)
|
||||
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
|
||||
mapper.setSerializationInclusion(JsonInclude.Include.NON_EMPTY)
|
||||
mapper
|
||||
}
|
||||
}
|
||||
|
||||
class ApiInvoker(val mapper: ObjectMapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders: mutable.HashMap[String, String] = mutable.HashMap(),
|
||||
hostMap: mutable.HashMap[String, Client] = mutable.HashMap(),
|
||||
asyncHttpClient: Boolean = false,
|
||||
authScheme: String = "",
|
||||
authPreemptive: Boolean = false
|
||||
) {
|
||||
|
||||
var defaultHeaders: mutable.HashMap[String, String] = httpHeaders
|
||||
|
||||
def escape(value: String): String = {
|
||||
URLEncoder.encode(value, "utf-8").replaceAll("\\+", "%20")
|
||||
}
|
||||
def escape(values: List[String]): String = {
|
||||
values.map(escape).mkString(",")
|
||||
}
|
||||
|
||||
def escape(value: Long): String = value.toString
|
||||
def escape(value: Double): String = value.toString
|
||||
def escape(value: Float): String = value.toString
|
||||
def escape(value: UUID): String = value.toString
|
||||
|
||||
def deserialize(json: String, containerType: String, cls: Class[_]) = {
|
||||
if (cls == classOf[String]) {
|
||||
json match {
|
||||
case s: String =>
|
||||
if (s.startsWith("\"") && s.endsWith("\"") && s.length > 1) {
|
||||
s.substring(1, s.length - 1)
|
||||
} else {
|
||||
s
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
} else {
|
||||
containerType.toLowerCase match {
|
||||
case "array" =>
|
||||
val typeInfo = mapper.getTypeFactory.constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
case "list" =>
|
||||
val typeInfo = mapper.getTypeFactory.constructCollectionType(classOf[java.util.List[_]], cls)
|
||||
val response = mapper.readValue(json, typeInfo).asInstanceOf[java.util.List[_]]
|
||||
response.asScala.toList
|
||||
case _ =>
|
||||
json match {
|
||||
case e: String if "\"\"" == e => null
|
||||
case _ => mapper.readValue(json, cls)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def serialize(obj: AnyRef): String = {
|
||||
if (obj != null) {
|
||||
obj match {
|
||||
case e: List[_] => mapper.writeValueAsString(obj.asInstanceOf[List[_]].asJava)
|
||||
case _ => mapper.writeValueAsString(obj)
|
||||
}
|
||||
} else {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
def invokeApi(
|
||||
host: String,
|
||||
path: String,
|
||||
method: String,
|
||||
queryParams: Map[String, String],
|
||||
formParams: Map[String, String],
|
||||
body: AnyRef,
|
||||
headerParams: Map[String, String],
|
||||
contentType: String
|
||||
): String = {
|
||||
val client = getClient(host)
|
||||
|
||||
val querystring = queryParams.filter(k => k._2 != null).map(k => escape(k._1) + "=" + escape(k._2)).mkString("?", "&", "")
|
||||
val builder = client.resource(host + path + querystring).accept(contentType)
|
||||
headerParams.map(p => builder.header(p._1, p._2))
|
||||
defaultHeaders.foreach(p => {
|
||||
if (!headerParams.contains(p._1) && p._2 != null) {
|
||||
builder.header(p._1, p._2)
|
||||
}
|
||||
})
|
||||
var formData: MultivaluedMapImpl = null
|
||||
if (contentType == "application/x-www-form-urlencoded") {
|
||||
formData = new MultivaluedMapImpl()
|
||||
formParams.foreach(p => formData.add(p._1, p._2))
|
||||
}
|
||||
|
||||
val response: ClientResponse = method match {
|
||||
case "GET" => builder.get(classOf[ClientResponse])
|
||||
case "POST" =>
|
||||
if (formData != null && formData.size() > 0) {
|
||||
builder.post(classOf[ClientResponse], formData)
|
||||
} else if (body != null && body.isInstanceOf[File]) {
|
||||
val file = body.asInstanceOf[File]
|
||||
val form = new FormDataMultiPart()
|
||||
form.field("filename", file.getName)
|
||||
form.bodyPart(new FileDataBodyPart("file", file, MediaType.MULTIPART_FORM_DATA_TYPE))
|
||||
builder.post(classOf[ClientResponse], form)
|
||||
} else {
|
||||
if (body == null) {
|
||||
builder.post(classOf[ClientResponse], serialize(body))
|
||||
} else {
|
||||
builder.`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
}
|
||||
case "PUT" =>
|
||||
if (formData != null) {
|
||||
builder.post(classOf[ClientResponse], formData)
|
||||
} else if (body == null) {
|
||||
builder.put(classOf[ClientResponse], null)
|
||||
} else {
|
||||
builder.`type`(contentType).put(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
case "DELETE" => builder.delete(classOf[ClientResponse])
|
||||
case "PATCH" =>
|
||||
if(formData != null) {
|
||||
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], formData)
|
||||
} else if(body == null) {
|
||||
builder.header("X-HTTP-Method-Override", "PATCH").post(classOf[ClientResponse], null)
|
||||
} else {
|
||||
builder.header("X-HTTP-Method-Override", "PATCH").`type`(contentType).post(classOf[ClientResponse], serialize(body))
|
||||
}
|
||||
case _ => null
|
||||
}
|
||||
response.getStatusInfo.getStatusCode match {
|
||||
case 204 => ""
|
||||
case code: Int if Range(200, 299).contains(code) =>
|
||||
if (response.hasEntity) {
|
||||
response.getEntity(classOf[String])
|
||||
} else {
|
||||
""
|
||||
}
|
||||
case _ =>
|
||||
val entity = if (response.hasEntity) {
|
||||
response.getEntity(classOf[String])
|
||||
} else {
|
||||
"no data"
|
||||
}
|
||||
throw new ApiException(response.getStatusInfo.getStatusCode, entity)
|
||||
}
|
||||
}
|
||||
|
||||
def getClient(host: String): Client = {
|
||||
if (hostMap.contains(host)) {
|
||||
hostMap(host)
|
||||
} else {
|
||||
val client = newClient(host)
|
||||
// client.addFilter(new LoggingFilter())
|
||||
hostMap += host -> client
|
||||
client
|
||||
}
|
||||
}
|
||||
|
||||
def newClient(host: String): Client = if (asyncHttpClient) {
|
||||
import com.ning.http.client.Realm
|
||||
import org.sonatype.spice.jersey.client.ahc.AhcHttpClient
|
||||
import org.sonatype.spice.jersey.client.ahc.config.DefaultAhcConfig
|
||||
|
||||
val config: DefaultAhcConfig = new DefaultAhcConfig()
|
||||
if (!authScheme.isEmpty) {
|
||||
val authSchemeEnum = Realm.AuthScheme.valueOf(authScheme)
|
||||
config
|
||||
.getAsyncHttpClientConfigBuilder
|
||||
.setRealm(new Realm.RealmBuilder().setScheme(authSchemeEnum)
|
||||
.setUsePreemptiveAuth(authPreemptive).build)
|
||||
}
|
||||
AhcHttpClient.create(config)
|
||||
} else {
|
||||
Client.create()
|
||||
}
|
||||
}
|
||||
|
||||
object ApiInvoker extends ApiInvoker(
|
||||
mapper = ScalaJsonUtil.getJsonMapper,
|
||||
httpHeaders = mutable.HashMap(),
|
||||
hostMap = mutable.HashMap(),
|
||||
asyncHttpClient = false,
|
||||
authScheme = "",
|
||||
authPreemptive = false
|
||||
)
|
||||
|
||||
class ApiException(val code: Int, msg: String) extends RuntimeException(msg)
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.openapitools.client
|
||||
|
||||
import org.openapitools.client.api._
|
||||
|
||||
import com.wordnik.swagger.client._
|
||||
|
||||
import java.io.Closeable
|
||||
|
||||
class AsyncClient(config: SwaggerConfig) extends Closeable {
|
||||
lazy val locator: ServiceLocator = config.locator
|
||||
lazy val name: String = config.name
|
||||
|
||||
private[this] val client = transportClient
|
||||
|
||||
protected def transportClient: TransportClient = new RestClient(config)
|
||||
|
||||
def close() {
|
||||
client.close()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.api
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
import org.openapitools.client.model.ApiResponse
|
||||
import java.io.File
|
||||
import org.openapitools.client.model.Pet
|
||||
import org.openapitools.client.{ApiInvoker, ApiException}
|
||||
|
||||
import collection.mutable
|
||||
import com.sun.jersey.multipart.FormDataMultiPart
|
||||
import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
import com.wordnik.swagger.client._
|
||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||
|
||||
import java.net.URI
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
import org.json4s._
|
||||
|
||||
class PetApi(
|
||||
val defBasePath: String = "http://petstore.swagger.io/v2",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker
|
||||
) {
|
||||
private lazy val dateTimeFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
private val dateFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
implicit val formats = new org.json4s.DefaultFormats {
|
||||
override def dateFormatter = dateTimeFormatter
|
||||
}
|
||||
implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
|
||||
implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
|
||||
implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
|
||||
implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
|
||||
implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
|
||||
implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
|
||||
|
||||
var basePath: String = defBasePath
|
||||
var apiInvoker: ApiInvoker = defApiInvoker
|
||||
|
||||
def addHeader(key: String, value: String): mutable.HashMap[String, String] = {
|
||||
apiInvoker.defaultHeaders += key -> value
|
||||
}
|
||||
|
||||
val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
|
||||
val client = new RestClient(config)
|
||||
val helper = new PetApiAsyncHelper(client, config)
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
* @return void
|
||||
*/
|
||||
def addPet(body: Pet) = {
|
||||
val await = Try(Await.result(addPetAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store asynchronously
|
||||
*
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
* @return Future(void)
|
||||
*/
|
||||
def addPetAsync(body: Pet) = {
|
||||
helper.addPet(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
*
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey (optional)
|
||||
* @return void
|
||||
*/
|
||||
def deletePet(petId: Long, apiKey: Option[String] = None) = {
|
||||
val await = Try(Await.result(deletePetAsync(petId, apiKey), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet asynchronously
|
||||
*
|
||||
*
|
||||
* @param petId Pet id to delete
|
||||
* @param apiKey (optional)
|
||||
* @return Future(void)
|
||||
*/
|
||||
def deletePetAsync(petId: Long, apiKey: Option[String] = None) = {
|
||||
helper.deletePet(petId, apiKey)
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* @param status Status values that need to be considered for filter
|
||||
* @return List[Pet]
|
||||
*/
|
||||
def findPetsByStatus(status: List[String]): Option[List[Pet]] = {
|
||||
val await = Try(Await.result(findPetsByStatusAsync(status), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status asynchronously
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* @param status Status values that need to be considered for filter
|
||||
* @return Future(List[Pet])
|
||||
*/
|
||||
def findPetsByStatusAsync(status: List[String]): Future[List[Pet]] = {
|
||||
helper.findPetsByStatus(status)
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* @param tags Tags to filter by
|
||||
* @return List[Pet]
|
||||
*/
|
||||
def findPetsByTags(tags: List[String]): Option[List[Pet]] = {
|
||||
val await = Try(Await.result(findPetsByTagsAsync(tags), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags asynchronously
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* @param tags Tags to filter by
|
||||
* @return Future(List[Pet])
|
||||
*/
|
||||
def findPetsByTagsAsync(tags: List[String]): Future[List[Pet]] = {
|
||||
helper.findPetsByTags(tags)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a single pet
|
||||
*
|
||||
* @param petId ID of pet to return
|
||||
* @return Pet
|
||||
*/
|
||||
def getPetById(petId: Long): Option[Pet] = {
|
||||
val await = Try(Await.result(getPetByIdAsync(petId), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID asynchronously
|
||||
* Returns a single pet
|
||||
*
|
||||
* @param petId ID of pet to return
|
||||
* @return Future(Pet)
|
||||
*/
|
||||
def getPetByIdAsync(petId: Long): Future[Pet] = {
|
||||
helper.getPetById(petId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
* @return void
|
||||
*/
|
||||
def updatePet(body: Pet) = {
|
||||
val await = Try(Await.result(updatePetAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet asynchronously
|
||||
*
|
||||
*
|
||||
* @param body Pet object that needs to be added to the store
|
||||
* @return Future(void)
|
||||
*/
|
||||
def updatePetAsync(body: Pet) = {
|
||||
helper.updatePet(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated
|
||||
* @param name Updated name of the pet (optional)
|
||||
* @param status Updated status of the pet (optional)
|
||||
* @return void
|
||||
*/
|
||||
def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None) = {
|
||||
val await = Try(Await.result(updatePetWithFormAsync(petId, name, status), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data asynchronously
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet that needs to be updated
|
||||
* @param name Updated name of the pet (optional)
|
||||
* @param status Updated status of the pet (optional)
|
||||
* @return Future(void)
|
||||
*/
|
||||
def updatePetWithFormAsync(petId: Long, name: Option[String] = None, status: Option[String] = None) = {
|
||||
helper.updatePetWithForm(petId, name, status)
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 ApiResponse
|
||||
*/
|
||||
def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): Option[ApiResponse] = {
|
||||
val await = Try(Await.result(uploadFileAsync(petId, additionalMetadata, file), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads an image asynchronously
|
||||
*
|
||||
*
|
||||
* @param petId ID of pet to update
|
||||
* @param additionalMetadata Additional data to pass to server (optional)
|
||||
* @param file file to upload (optional)
|
||||
* @return Future(ApiResponse)
|
||||
*/
|
||||
def uploadFileAsync(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): Future[ApiResponse] = {
|
||||
helper.uploadFile(petId, additionalMetadata, file)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||
|
||||
def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 deletePet(petId: Long,
|
||||
apiKey: Option[String] = None
|
||||
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/{petId}")
|
||||
replaceAll("\\{" + "petId" + "\\}", petId.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
apiKey match {
|
||||
case Some(param) => headerParams += "api_key" -> param.toString
|
||||
case _ => headerParams
|
||||
}
|
||||
|
||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def findPetsByStatus(status: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/findByStatus"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (status == null) throw new Exception("Missing required parameter 'status' when calling PetApi->findPetsByStatus")
|
||||
queryParams += "status" -> status.toString
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def findPetsByTags(tags: List[String])(implicit reader: ClientResponseReader[List[Pet]]): Future[List[Pet]] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/findByTags"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (tags == null) throw new Exception("Missing required parameter 'tags' when calling PetApi->findPetsByTags")
|
||||
queryParams += "tags" -> tags.toString
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def getPetById(petId: Long)(implicit reader: ClientResponseReader[Pet]): Future[Pet] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/{petId}")
|
||||
replaceAll("\\{" + "petId" + "\\}", petId.toString))
|
||||
|
||||
// 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 updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def updatePetWithForm(petId: Long,
|
||||
name: Option[String] = None,
|
||||
status: Option[String] = None
|
||||
)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/{petId}")
|
||||
replaceAll("\\{" + "petId" + "\\}", petId.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
|
||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def uploadFile(petId: Long,
|
||||
additionalMetadata: Option[String] = None,
|
||||
file: Option[File] = None
|
||||
)(implicit reader: ClientResponseReader[ApiResponse]): Future[ApiResponse] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/pet/{petId}/uploadImage")
|
||||
replaceAll("\\{" + "petId" + "\\}", petId.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
|
||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,248 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.api
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
import org.openapitools.client.model.Order
|
||||
import org.openapitools.client.{ApiInvoker, ApiException}
|
||||
|
||||
import collection.mutable
|
||||
import com.sun.jersey.multipart.FormDataMultiPart
|
||||
import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
import com.wordnik.swagger.client._
|
||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||
|
||||
import java.net.URI
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
import org.json4s._
|
||||
|
||||
class StoreApi(
|
||||
val defBasePath: String = "http://petstore.swagger.io/v2",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker
|
||||
) {
|
||||
private lazy val dateTimeFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
private val dateFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
implicit val formats = new org.json4s.DefaultFormats {
|
||||
override def dateFormatter = dateTimeFormatter
|
||||
}
|
||||
implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
|
||||
implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
|
||||
implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
|
||||
implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
|
||||
implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
|
||||
implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
|
||||
|
||||
var basePath: String = defBasePath
|
||||
var apiInvoker: ApiInvoker = defApiInvoker
|
||||
|
||||
def addHeader(key: String, value: String): mutable.HashMap[String, String] = {
|
||||
apiInvoker.defaultHeaders += key -> value
|
||||
}
|
||||
|
||||
val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
|
||||
val client = new RestClient(config)
|
||||
val helper = new StoreApiAsyncHelper(client, config)
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
* @return void
|
||||
*/
|
||||
def deleteOrder(orderId: String) = {
|
||||
val await = Try(Await.result(deleteOrderAsync(orderId), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID asynchronously
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* @param orderId ID of the order that needs to be deleted
|
||||
* @return Future(void)
|
||||
*/
|
||||
def deleteOrderAsync(orderId: String) = {
|
||||
helper.deleteOrder(orderId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return Map[String, Integer]
|
||||
*/
|
||||
def getInventory(): Option[Map[String, Integer]] = {
|
||||
val await = Try(Await.result(getInventoryAsync(), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status asynchronously
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* @return Future(Map[String, Integer])
|
||||
*/
|
||||
def getInventoryAsync(): Future[Map[String, Integer]] = {
|
||||
helper.getInventory()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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: Long): Option[Order] = {
|
||||
val await = Try(Await.result(getOrderByIdAsync(orderId), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID asynchronously
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
*
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return Future(Order)
|
||||
*/
|
||||
def getOrderByIdAsync(orderId: Long): Future[Order] = {
|
||||
helper.getOrderById(orderId)
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
* @return Order
|
||||
*/
|
||||
def placeOrder(body: Order): Option[Order] = {
|
||||
val await = Try(Await.result(placeOrderAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet asynchronously
|
||||
*
|
||||
*
|
||||
* @param body order placed for purchasing the pet
|
||||
* @return Future(Order)
|
||||
*/
|
||||
def placeOrderAsync(body: Order): Future[Order] = {
|
||||
helper.placeOrder(body)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||
|
||||
def deleteOrder(orderId: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/store/order/{orderId}")
|
||||
replaceAll("\\{" + "orderId" + "\\}", orderId.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (orderId == null) throw new Exception("Missing required parameter 'orderId' when calling StoreApi->deleteOrder")
|
||||
|
||||
|
||||
val resFuture = client.submit("DELETE", 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"))
|
||||
|
||||
// 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: Long)(implicit reader: ClientResponseReader[Order]): Future[Order] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/store/order/{orderId}")
|
||||
replaceAll("\\{" + "orderId" + "\\}", orderId.toString))
|
||||
|
||||
// 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 placeOrder(body: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/store/order"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,432 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.api
|
||||
|
||||
import java.text.SimpleDateFormat
|
||||
|
||||
import org.openapitools.client.model.User
|
||||
import org.openapitools.client.{ApiInvoker, ApiException}
|
||||
|
||||
import collection.mutable
|
||||
import com.sun.jersey.multipart.FormDataMultiPart
|
||||
import com.sun.jersey.multipart.file.FileDataBodyPart
|
||||
import com.wordnik.swagger.client._
|
||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||
|
||||
import java.net.URI
|
||||
import java.io.File
|
||||
import java.util.Date
|
||||
import java.util.TimeZone
|
||||
import javax.ws.rs.core.MediaType
|
||||
|
||||
import scala.concurrent.ExecutionContext.Implicits.global
|
||||
import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable.HashMap
|
||||
import scala.util.{Failure, Success, Try}
|
||||
|
||||
import org.json4s._
|
||||
|
||||
class UserApi(
|
||||
val defBasePath: String = "http://petstore.swagger.io/v2",
|
||||
defApiInvoker: ApiInvoker = ApiInvoker
|
||||
) {
|
||||
private lazy val dateTimeFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
private val dateFormatter = {
|
||||
val formatter = new SimpleDateFormat("yyyy-MM-dd")
|
||||
formatter.setTimeZone(TimeZone.getTimeZone("UTC"))
|
||||
formatter
|
||||
}
|
||||
implicit val formats = new org.json4s.DefaultFormats {
|
||||
override def dateFormatter = dateTimeFormatter
|
||||
}
|
||||
implicit val stringReader: ClientResponseReader[String] = ClientResponseReaders.StringReader
|
||||
implicit val unitReader: ClientResponseReader[Unit] = ClientResponseReaders.UnitReader
|
||||
implicit val jvalueReader: ClientResponseReader[JValue] = ClientResponseReaders.JValueReader
|
||||
implicit val jsonReader: ClientResponseReader[Nothing] = JsonFormatsReader
|
||||
implicit val stringWriter: RequestWriter[String] = RequestWriters.StringWriter
|
||||
implicit val jsonWriter: RequestWriter[Nothing] = JsonFormatsWriter
|
||||
|
||||
var basePath: String = defBasePath
|
||||
var apiInvoker: ApiInvoker = defApiInvoker
|
||||
|
||||
def addHeader(key: String, value: String): mutable.HashMap[String, String] = {
|
||||
apiInvoker.defaultHeaders += key -> value
|
||||
}
|
||||
|
||||
val config: SwaggerConfig = SwaggerConfig.forUrl(new URI(defBasePath))
|
||||
val client = new RestClient(config)
|
||||
val helper = new UserApiAsyncHelper(client, config)
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param body Created user object
|
||||
* @return void
|
||||
*/
|
||||
def createUser(body: User) = {
|
||||
val await = Try(Await.result(createUserAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user asynchronously
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param body Created user object
|
||||
* @return Future(void)
|
||||
*/
|
||||
def createUserAsync(body: User) = {
|
||||
helper.createUser(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
def createUsersWithArrayInput(body: List[User]) = {
|
||||
val await = Try(Await.result(createUsersWithArrayInputAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array asynchronously
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return Future(void)
|
||||
*/
|
||||
def createUsersWithArrayInputAsync(body: List[User]) = {
|
||||
helper.createUsersWithArrayInput(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return void
|
||||
*/
|
||||
def createUsersWithListInput(body: List[User]) = {
|
||||
val await = Try(Await.result(createUsersWithListInputAsync(body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array asynchronously
|
||||
*
|
||||
*
|
||||
* @param body List of user object
|
||||
* @return Future(void)
|
||||
*/
|
||||
def createUsersWithListInputAsync(body: List[User]) = {
|
||||
helper.createUsersWithListInput(body)
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username The name that needs to be deleted
|
||||
* @return void
|
||||
*/
|
||||
def deleteUser(username: String) = {
|
||||
val await = Try(Await.result(deleteUserAsync(username), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user asynchronously
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username The name that needs to be deleted
|
||||
* @return Future(void)
|
||||
*/
|
||||
def deleteUserAsync(username: String) = {
|
||||
helper.deleteUser(username)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
* @return User
|
||||
*/
|
||||
def getUserByName(username: String): Option[User] = {
|
||||
val await = Try(Await.result(getUserByNameAsync(username), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name asynchronously
|
||||
*
|
||||
*
|
||||
* @param username The name that needs to be fetched. Use user1 for testing.
|
||||
* @return Future(User)
|
||||
*/
|
||||
def getUserByNameAsync(username: String): Future[User] = {
|
||||
helper.getUserByName(username)
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
*
|
||||
* @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] = {
|
||||
val await = Try(Await.result(loginUserAsync(username, password), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system asynchronously
|
||||
*
|
||||
*
|
||||
* @param username The user name for login
|
||||
* @param password The password for login in clear text
|
||||
* @return Future(String)
|
||||
*/
|
||||
def loginUserAsync(username: String, password: String): Future[String] = {
|
||||
helper.loginUser(username, password)
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
def logoutUser() = {
|
||||
val await = Try(Await.result(logoutUserAsync(), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session asynchronously
|
||||
*
|
||||
*
|
||||
* @return Future(void)
|
||||
*/
|
||||
def logoutUserAsync() = {
|
||||
helper.logoutUser()
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
* @return void
|
||||
*/
|
||||
def updateUser(username: String, body: User) = {
|
||||
val await = Try(Await.result(updateUserAsync(username, body), Duration.Inf))
|
||||
await match {
|
||||
case Success(i) => Some(await.get)
|
||||
case Failure(t) => None
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user asynchronously
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* @param username name that need to be deleted
|
||||
* @param body Updated user object
|
||||
* @return Future(void)
|
||||
*/
|
||||
def updateUserAsync(username: String, body: User) = {
|
||||
helper.updateUser(username, body)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||
|
||||
def createUser(body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/user"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
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 =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def deleteUser(username: String)(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/user/{username}")
|
||||
replaceAll("\\{" + "username" + "\\}", username.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->deleteUser")
|
||||
|
||||
|
||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def getUserByName(username: String)(implicit reader: ClientResponseReader[User]): Future[User] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/user/{username}")
|
||||
replaceAll("\\{" + "username" + "\\}", username.toString))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->getUserByName")
|
||||
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def loginUser(username: String,
|
||||
password: String)(implicit reader: ClientResponseReader[String]): Future[String] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/user/login"))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.HashMap[String, String]
|
||||
|
||||
if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->loginUser")
|
||||
|
||||
if (password == null) throw new Exception("Missing required parameter 'password' when calling UserApi->loginUser")
|
||||
|
||||
queryParams += "username" -> username.toString
|
||||
queryParams += "password" -> password.toString
|
||||
|
||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
def logoutUser()(implicit reader: ClientResponseReader[Unit]): Future[Unit] = {
|
||||
// create path and map variables
|
||||
val path = (addFmt("/user/logout"))
|
||||
|
||||
// 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 updateUser(username: String,
|
||||
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))
|
||||
|
||||
// query params
|
||||
val queryParams = new mutable.HashMap[String, String]
|
||||
val headerParams = new mutable.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")
|
||||
|
||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||
resFuture flatMap { resp =>
|
||||
process(reader.read(resp))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
|
||||
case class ApiResponse (
|
||||
code: Option[Integer] = None,
|
||||
`type`: Option[String] = None,
|
||||
message: Option[String] = None
|
||||
)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
|
||||
case class Category (
|
||||
id: Option[Long] = None,
|
||||
name: Option[String] = None
|
||||
)
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
import java.util.Date
|
||||
|
||||
case class Order (
|
||||
id: Option[Long] = None,
|
||||
petId: Option[Long] = None,
|
||||
quantity: Option[Integer] = None,
|
||||
shipDate: Option[Date] = None,
|
||||
// Order Status
|
||||
status: Option[String] = None,
|
||||
complete: Option[Boolean] = None
|
||||
)
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
|
||||
case class Pet (
|
||||
id: Option[Long] = None,
|
||||
category: Option[Category] = None,
|
||||
name: String,
|
||||
photoUrls: List[String],
|
||||
tags: Option[List[Tag]] = None,
|
||||
// pet status in the store
|
||||
status: Option[String] = None
|
||||
)
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
|
||||
case class Tag (
|
||||
id: Option[Long] = None,
|
||||
name: Option[String] = None
|
||||
)
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* OpenAPI Petstore
|
||||
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
|
||||
*
|
||||
* OpenAPI spec version: 1.0.0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
package org.openapitools.client.model
|
||||
|
||||
|
||||
case class User (
|
||||
id: Option[Long] = None,
|
||||
username: Option[String] = None,
|
||||
firstName: Option[String] = None,
|
||||
lastName: Option[String] = None,
|
||||
email: Option[String] = None,
|
||||
password: Option[String] = None,
|
||||
phone: Option[String] = None,
|
||||
// User Status
|
||||
userStatus: Option[Integer] = None
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user