forked from loafle/openapi-generator-original
* #1023 - [Scala] Use status family during response processing * #1023 - [Scala] Use status family during response processing - adding REDIRECTION & INFORMATIONAL support
This commit is contained in:
parent
822234dd76
commit
c81c09b941
@ -13,12 +13,13 @@ import com.sun.jersey.multipart.file.FileDataBodyPart
|
|||||||
import com.wordnik.swagger.client._
|
import com.wordnik.swagger.client._
|
||||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||||
|
import javax.ws.rs.core.Response.Status.Family
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.{MediaType, Response}
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
@ -144,7 +145,11 @@ class {{classname}}AsyncHelper(client: TransportClient, config: SwaggerConfig) e
|
|||||||
|
|
||||||
val resFuture = client.submit("{{httpMethod}}", path, queryParams.toMap, headerParams.toMap, {{#bodyParam}}writer.write({{paramName}}){{/bodyParam}}{{^bodyParam}}"{{emptyBodyParam}}"{{/bodyParam}})
|
val resFuture = client.submit("{{httpMethod}}", path, queryParams.toMap, headerParams.toMap, {{#bodyParam}}writer.write({{paramName}}){{/bodyParam}}{{^bodyParam}}"{{emptyBodyParam}}"{{/bodyParam}})
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,237 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* 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,128 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* 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.UNKNOWN_BASE_TYPE
|
||||||
|
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 javax.ws.rs.core.Response.Status.Family
|
||||||
|
|
||||||
|
import java.net.URI
|
||||||
|
import java.io.File
|
||||||
|
import java.util.Date
|
||||||
|
import java.util.TimeZone
|
||||||
|
import javax.ws.rs.core.{MediaType, Response}
|
||||||
|
|
||||||
|
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 FakeApi(
|
||||||
|
val defBasePath: String = "http://petstore.swagger.io *_/ ' \" =end -- \\r\\n \\n \\r/v2 *_/ ' \" =end -- \\r\\n \\n \\r",
|
||||||
|
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 FakeApiAsyncHelper(client, config)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* @param UNKNOWN_BASE_TYPE (optional)
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
def testCodeInject * ' " =end rn n r(UNKNOWN_BASE_TYPE: Option[UNKNOWN_BASE_TYPE] = None) = {
|
||||||
|
val await = Try(Await.result(testCodeInject * ' " =end rn n rAsync(UNKNOWN_BASE_TYPE), Duration.Inf))
|
||||||
|
await match {
|
||||||
|
case Success(i) => Some(await.get)
|
||||||
|
case Failure(t) => None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r asynchronously
|
||||||
|
* To test code injection *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* @param UNKNOWN_BASE_TYPE (optional)
|
||||||
|
* @return Future(void)
|
||||||
|
*/
|
||||||
|
def testCodeInject * ' " =end rn n rAsync(UNKNOWN_BASE_TYPE: Option[UNKNOWN_BASE_TYPE] = None) = {
|
||||||
|
helper.testCodeInject * ' " =end rn n r(UNKNOWN_BASE_TYPE)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class FakeApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) {
|
||||||
|
|
||||||
|
def testCodeInject * ' " =end rn n r(UNKNOWN_BASE_TYPE: Option[UNKNOWN_BASE_TYPE] = None
|
||||||
|
)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Option[UNKNOWN_BASE_TYPE]]): Future[Unit] = {
|
||||||
|
// create path and map variables
|
||||||
|
val path = (addFmt("/fake"))
|
||||||
|
|
||||||
|
// query params
|
||||||
|
val queryParams = new mutable.HashMap[String, String]
|
||||||
|
val headerParams = new mutable.HashMap[String, String]
|
||||||
|
|
||||||
|
|
||||||
|
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(UNKNOWN_BASE_TYPE))
|
||||||
|
resFuture flatMap { resp =>
|
||||||
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* OpenAPI Petstore *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ *_/ ' \" =end --
|
||||||
|
*
|
||||||
|
* OpenAPI spec version: 1.0.0 *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
* Contact: something@something.abc *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
*
|
||||||
|
* 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 ModelReturn (
|
||||||
|
// property description *_/ ' \" =end -- \\r\\n \\n \\r
|
||||||
|
`return`: Option[Integer] = None
|
||||||
|
)
|
||||||
|
|
@ -1 +1 @@
|
|||||||
4.0.0-SNAPSHOT
|
4.0.0-SNAPSHOT
|
||||||
|
@ -25,12 +25,13 @@ import com.sun.jersey.multipart.file.FileDataBodyPart
|
|||||||
import com.wordnik.swagger.client._
|
import com.wordnik.swagger.client._
|
||||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||||
|
import javax.ws.rs.core.Response.Status.Family
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.{MediaType, Response}
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
@ -309,7 +310,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +336,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +357,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +378,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +398,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -397,7 +418,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,7 +441,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -435,7 +464,11 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,13 @@ import com.sun.jersey.multipart.file.FileDataBodyPart
|
|||||||
import com.wordnik.swagger.client._
|
import com.wordnik.swagger.client._
|
||||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||||
|
import javax.ws.rs.core.Response.Status.Family
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.{MediaType, Response}
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
@ -193,7 +194,11 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -208,7 +213,11 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -224,7 +233,11 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -240,7 +253,11 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,12 +23,13 @@ import com.sun.jersey.multipart.file.FileDataBodyPart
|
|||||||
import com.wordnik.swagger.client._
|
import com.wordnik.swagger.client._
|
||||||
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._
|
||||||
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._
|
||||||
|
import javax.ws.rs.core.Response.Status.Family
|
||||||
|
|
||||||
import java.net.URI
|
import java.net.URI
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.Date
|
import java.util.Date
|
||||||
import java.util.TimeZone
|
import java.util.TimeZone
|
||||||
import javax.ws.rs.core.MediaType
|
import javax.ws.rs.core.{MediaType, Response}
|
||||||
|
|
||||||
import scala.concurrent.ExecutionContext.Implicits.global
|
import scala.concurrent.ExecutionContext.Implicits.global
|
||||||
import scala.concurrent._
|
import scala.concurrent._
|
||||||
@ -299,7 +300,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,7 +320,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,7 +340,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +362,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("DELETE", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -367,7 +384,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -389,7 +410,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +429,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "")
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +453,11 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends
|
|||||||
|
|
||||||
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body))
|
||||||
resFuture flatMap { resp =>
|
resFuture flatMap { resp =>
|
||||||
process(reader.read(resp))
|
val status = Response.Status.fromStatusCode(resp.statusCode)
|
||||||
|
status.getFamily match {
|
||||||
|
case Family.SUCCESSFUL | Family.REDIRECTION | Family.INFORMATIONAL => process(reader.read(resp))
|
||||||
|
case _ => throw new ApiException(resp.statusCode, resp.statusText)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user