From c387d58d2607d583a171f0815998b1324b9f11fa Mon Sep 17 00:00:00 2001 From: William Cheng Date: Fri, 16 Oct 2020 22:50:34 +0800 Subject: [PATCH] remove outdated scala files (#7723) --- .../io/swagger/client/api/HobbiesApi.scala | 205 ---------------- .../io/swagger/client/api/PeopleApi.scala | 225 ------------------ .../scala/io/swagger/client/model/Hobby.scala | 29 --- .../io/swagger/client/model/Person.scala | 22 -- 4 files changed, 481 deletions(-) delete mode 100644 modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/HobbiesApi.scala delete mode 100644 modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/PeopleApi.scala delete mode 100644 modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Hobby.scala delete mode 100644 modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Person.scala diff --git a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/HobbiesApi.scala b/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/HobbiesApi.scala deleted file mode 100644 index 3f8ca7c4880..00000000000 --- a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/HobbiesApi.scala +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Scala Client API Integration Test - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 1 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package io.swagger.client.api - -import java.text.SimpleDateFormat - -import io.swagger.client.model.ArrayByte -import java.util.Date -import io.swagger.client.model.Hobby -import io.swagger.client.{ApiInvoker, ApiException} - -import com.sun.jersey.multipart.FormDataMultiPart -import com.sun.jersey.multipart.file.FileDataBodyPart - -import javax.ws.rs.core.MediaType - -import java.io.File -import java.util.Date -import java.util.TimeZone - -import scala.collection.mutable.HashMap - -import com.wordnik.swagger.client._ -import scala.concurrent.Future -import collection.mutable - -import java.net.URI - -import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._ -import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._ - -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent._ -import scala.concurrent.duration._ -import scala.util.{Failure, Success, Try} - -import org.json4s._ - -class HobbiesApi( - val defBasePath: String = "https://localhost:8080", - 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 HobbiesApiAsyncHelper(client, config) - - /** - * Get hobbies - * Query hobbies with some additional optional meaningless parameters - * - * @param s a string (optional, default to some string) - * @param `class` a string, testing keyword escaping (optional, default to some string) - * @param i an integer (optional, default to 1) - * @param l a long (optional, default to 2) - * @param bool a bool (optional, default to true) - * @param f a float (optional, default to 0.1) - * @param d a double (optional, default to 10.005) - * @param datetime a date time (optional, default to 2018-01-01T08:30:00Z-04:00) - * @param date a date (optional, default to 2018-01-01) - * @param b a base64 encoded string (optional, default to c3dhZ2dlciBjb2RlZ2Vu) - * @param bin an octet string (optional, default to DEADBEEF) - * @return Hobby - */ - def getHobbies(s: Option[String] = Option("some string"), `class`: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes)): Option[Hobby] = { - val await = Try(Await.result(getHobbiesAsync(s, `class`, i, l, bool, f, d, datetime, date, b, bin), Duration.Inf)) - await match { - case Success(i) => Some(await.get) - case Failure(t) => None - } - } - - /** - * Get hobbies asynchronously - * Query hobbies with some additional optional meaningless parameters - * - * @param s a string (optional, default to some string) - * @param `class` a string, testing keyword escaping (optional, default to some string) - * @param i an integer (optional, default to 1) - * @param l a long (optional, default to 2) - * @param bool a bool (optional, default to true) - * @param f a float (optional, default to 0.1) - * @param d a double (optional, default to 10.005) - * @param datetime a date time (optional, default to 2018-01-01T08:30:00Z-04:00) - * @param date a date (optional, default to 2018-01-01) - * @param b a base64 encoded string (optional, default to c3dhZ2dlciBjb2RlZ2Vu) - * @param bin an octet string (optional, default to DEADBEEF) - * @return Future(Hobby) - */ - def getHobbiesAsync(s: Option[String] = Option("some string"), `class`: Option[String] = Option("some string"), i: Option[Integer] = Option(1), l: Option[Long] = Option(2), bool: Option[Boolean] = Option(true), f: Option[Float] = Option(0.1), d: Option[Double] = Option(10.005), datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes)): Future[Hobby] = { - helper.getHobbies(s, `class`, i, l, bool, f, d, datetime, date, b, bin) - } - -} - -class HobbiesApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - - def getHobbies(s: Option[String] = Option("some string"), - `class`: Option[String] = Option("some string"), - i: Option[Integer] = Option(1), - l: Option[Long] = Option(2), - bool: Option[Boolean] = Option(true), - f: Option[Float] = Option(0.1), - d: Option[Double] = Option(10.005), - datetime: Option[Date] = Option(dateTimeFormatter.parse("2018-01-01T08:30:00Z-04:00")), - date: Option[Date] = Option(dateFormatter.parse("2018-01-01")), - b: Option[Array[Byte]] = Option("c3dhZ2dlciBjb2RlZ2Vu".getBytes), - bin: Option[Array[Byte]] = Option("DEADBEEF".getBytes) - )(implicit reader: ClientResponseReader[Hobby]): Future[Hobby] = { - // create path and map variables - val path = (addFmt("/hobbies")) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - s match { - case Some(param) => queryParams += "s" -> param.toString - case _ => queryParams - } - `class` match { - case Some(param) => queryParams += "class" -> param.toString - case _ => queryParams - } - i match { - case Some(param) => queryParams += "i" -> param.toString - case _ => queryParams - } - l match { - case Some(param) => queryParams += "l" -> param.toString - case _ => queryParams - } - bool match { - case Some(param) => queryParams += "bool" -> param.toString - case _ => queryParams - } - f match { - case Some(param) => queryParams += "f" -> param.toString - case _ => queryParams - } - d match { - case Some(param) => queryParams += "d" -> param.toString - case _ => queryParams - } - datetime match { - case Some(param) => queryParams += "datetime" -> param.toString - case _ => queryParams - } - date match { - case Some(param) => queryParams += "date" -> param.toString - case _ => queryParams - } - b match { - case Some(param) => queryParams += "b" -> param.toString - case _ => queryParams - } - bin match { - case Some(param) => queryParams += "bin" -> param.toString - case _ => queryParams - } - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - -} diff --git a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/PeopleApi.scala b/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/PeopleApi.scala deleted file mode 100644 index ca5a245b255..00000000000 --- a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/api/PeopleApi.scala +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Scala Client API Integration Test - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 1 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package io.swagger.client.api - -import java.text.SimpleDateFormat - -import io.swagger.client.model.Person -import io.swagger.client.{ApiInvoker, ApiException} - -import com.sun.jersey.multipart.FormDataMultiPart -import com.sun.jersey.multipart.file.FileDataBodyPart - -import javax.ws.rs.core.MediaType - -import java.io.File -import java.util.Date -import java.util.TimeZone - -import scala.collection.mutable.HashMap - -import com.wordnik.swagger.client._ -import scala.concurrent.Future -import collection.mutable - -import java.net.URI - -import com.wordnik.swagger.client.ClientResponseReaders.Json4sFormatsReader._ -import com.wordnik.swagger.client.RequestWriters.Json4sFormatsWriter._ - -import scala.concurrent.ExecutionContext.Implicits.global -import scala.concurrent._ -import scala.concurrent.duration._ -import scala.util.{Failure, Success, Try} - -import org.json4s._ - -class PeopleApi( - val defBasePath: String = "https://localhost:8080", - 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 PeopleApiAsyncHelper(client, config) - - /** - * People listing - * - * - * @param age Limit results to people of a certain age. (optional) - * @return List[Person] - */ - def getPeople(age: Option[Long] = None): Option[List[Person]] = { - val await = Try(Await.result(getPeopleAsync(age), Duration.Inf)) - await match { - case Success(i) => Some(await.get) - case Failure(t) => None - } - } - - /** - * People listing asynchronously - * - * - * @param age Limit results to people of a certain age. (optional) - * @return Future(List[Person]) - */ - def getPeopleAsync(age: Option[Long] = None): Future[List[Person]] = { - helper.getPeople(age) - } - - /** - * get people by id - * Retrieves a single person record by personId - * - * @param personId The person's ID. - * @return Person - */ - def getPersonById(personId: Long): Option[Person] = { - val await = Try(Await.result(getPersonByIdAsync(personId), Duration.Inf)) - await match { - case Success(i) => Some(await.get) - case Failure(t) => None - } - } - - /** - * get people by id asynchronously - * Retrieves a single person record by personId - * - * @param personId The person's ID. - * @return Future(Person) - */ - def getPersonByIdAsync(personId: Long): Future[Person] = { - helper.getPersonById(personId) - } - - /** - * People batch save - * - * - * @param body Batch input of people to save - * @param size Explicitly sets the batch size (optional, default to 25) - * @return List[Person] - */ - def savePeople(body: List[Person], size: Option[Integer] = Option(25)): Option[List[Person]] = { - val await = Try(Await.result(savePeopleAsync(body, size), Duration.Inf)) - await match { - case Success(i) => Some(await.get) - case Failure(t) => None - } - } - - /** - * People batch save asynchronously - * - * - * @param body Batch input of people to save - * @param size Explicitly sets the batch size (optional, default to 25) - * @return Future(List[Person]) - */ - def savePeopleAsync(body: List[Person], size: Option[Integer] = Option(25)): Future[List[Person]] = { - helper.savePeople(body, size) - } - -} - -class PeopleApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - - def getPeople(age: Option[Long] = None - )(implicit reader: ClientResponseReader[List[Person]]): Future[List[Person]] = { - // create path and map variables - val path = (addFmt("/people")) - - // query params - val queryParams = new mutable.HashMap[String, String] - val headerParams = new mutable.HashMap[String, String] - - age match { - case Some(param) => queryParams += "age" -> param.toString - case _ => queryParams - } - - val resFuture = client.submit("GET", path, queryParams.toMap, headerParams.toMap, "") - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - def getPersonById(personId: Long)(implicit reader: ClientResponseReader[Person]): Future[Person] = { - // create path and map variables - val path = (addFmt("/people/{personId}") - replaceAll("\\{" + "personId" + "\\}", personId.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 savePeople(body: List[Person], - size: Option[Integer] = Option(25) - )(implicit reader: ClientResponseReader[List[Person]], writer: RequestWriter[List[Person]]): Future[List[Person]] = { - // create path and map variables - val path = (addFmt("/people")) - - // 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 PeopleApi->savePeople") - size match { - case Some(param) => queryParams += "size" -> param.toString - case _ => queryParams - } - - val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) - resFuture flatMap { resp => - process(reader.read(resp)) - } - } - - -} diff --git a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Hobby.scala b/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Hobby.scala deleted file mode 100644 index 02f64681fa4..00000000000 --- a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Hobby.scala +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Scala Client API Integration Test - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 1 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package io.swagger.client.model - -import java.util.Date - -case class Hobby ( - id: Option[Long] = None, - name: Option[String] = None, - count: Option[Integer] = None, - rate: Option[Float] = None, - ratio: Option[Double] = None, - enabled: Option[Boolean] = None, - created: Option[Date] = None, - timestamp: Option[Date] = None, - bytes: Option[Array[Byte]] = None, - binary: Option[String] = None -) - diff --git a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Person.scala b/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Person.scala deleted file mode 100644 index cd78718762b..00000000000 --- a/modules/openapi-generator/src/test/resources/integrationtests/scala/client/required-attributes-expected/src/main/scala/io/swagger/client/model/Person.scala +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Scala Client API Integration Test - * No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) - * - * OpenAPI spec version: 1 - * - * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git - * Do not edit the class manually. - */ - -package io.swagger.client.model - - -case class Person ( - id: Long, - firstName: String, - lastName: String, - age: Option[Integer] = None -) -