diff --git a/modules/openapi-generator/src/main/resources/scala-httpclient/api.mustache b/modules/openapi-generator/src/main/resources/scala-httpclient/api.mustache index aefca6a952..4e6bd4fc2f 100644 --- a/modules/openapi-generator/src/main/resources/scala-httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/scala-httpclient/api.mustache @@ -72,7 +72,7 @@ class {{classname}}( {{#allParams}} * @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} * @return {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} */ - def {{operationId}}({{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{#defaultValue}} = {{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}{{/defaultValue}}{{/required}}{{^required}}Option[{{dataType}}]{{#defaultValue}} = Option({{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}){{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}: Option[{{returnType}}]{{/returnType}} = { + def {{operationId}}({{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}Option[{{dataType}}] = None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}: Option[{{returnType}}]{{/returnType}} = { val await = Try(Await.result({{operationId}}Async({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}), Duration.Inf)) await match { case Success(i) => Some(await.get) @@ -87,7 +87,7 @@ class {{classname}}( {{#allParams}} * @param {{paramName}} {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} {{/allParams}} * @return Future({{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}}) */ - def {{operationId}}Async({{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{#defaultValue}} = {{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}{{/defaultValue}}{{/required}}{{^required}}Option[{{dataType}}]{{#defaultValue}} = Option({{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}){{/defaultValue}}{{^defaultValue}} = None{{/defaultValue}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}} = { + def {{operationId}}Async({{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}Option[{{dataType}}] = None{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}} = { helper.{{operationId}}({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) } @@ -97,8 +97,8 @@ class {{classname}}( class {{classname}}AsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { {{#operation}} - def {{operationId}}({{#allParams}}{{^required}}{{paramName}}: Option[{{dataType}}] = {{#defaultValue}}Option({{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}){{/defaultValue}}{{^defaultValue}}None{{/defaultValue}}{{#hasMore}},{{/hasMore}} - {{/required}}{{#required}}{{paramName}}: {{dataType}}{{#defaultValue}} = {{#isString}}"{{{defaultValue}}}"{{/isString}}{{^isString}}{{#isByteArray}}"{{/isByteArray}}{{#isDate}}dateFormatter.parse("{{/isDate}}{{#isDateTime}}dateTimeFormatter.parse("{{/isDateTime}}{{{defaultValue}}}{{#isDate}}"){{/isDate}}{{#isDateTime}}"){{/isDateTime}}{{#isByteArray}}".getBytes{{/isByteArray}}{{/isString}}{{/defaultValue}}{{#hasMore}}, + def {{operationId}}({{#allParams}}{{^required}}{{paramName}}: Option[{{dataType}}] = None{{#hasMore}},{{/hasMore}} + {{/required}}{{#required}}{{paramName}}: {{dataType}}{{#hasMore}}, {{/hasMore}}{{/required}}{{/allParams}})(implicit reader: ClientResponseReader[{{#returnType}}{{returnType}}{{/returnType}}{{^returnType}}Unit{{/returnType}}]{{#bodyParams}}, writer: RequestWriter[{{^required}}Option[{{dataType}}]{{/required}}{{#required}}{{dataType}}{{/required}}]{{/bodyParams}}){{#returnType}}: Future[{{returnType}}]{{/returnType}}{{^returnType}}: Future[Unit]{{/returnType}} = { // create path and map variables val path = (addFmt("{{path}}"){{#pathParams}} diff --git a/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION b/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION index 096bf47efe..afa6365606 100644 --- a/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION +++ b/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +4.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/PetApi.scala b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/PetApi.scala index 7031416f34..191e9f9fa4 100644 --- a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/PetApi.scala +++ b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/PetApi.scala @@ -79,11 +79,11 @@ class PetApi( * Add a new pet to the store * * - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store * @return void */ - def addPet(pet: Pet) = { - val await = Try(Await.result(addPetAsync(pet), Duration.Inf)) + 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 @@ -94,11 +94,11 @@ class PetApi( * Add a new pet to the store asynchronously * * - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store * @return Future(void) */ - def addPetAsync(pet: Pet) = { - helper.addPet(pet) + def addPetAsync(body: Pet) = { + helper.addPet(body) } /** @@ -211,11 +211,11 @@ class PetApi( * Update an existing pet * * - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store * @return void */ - def updatePet(pet: Pet) = { - val await = Try(Await.result(updatePetAsync(pet), Duration.Inf)) + 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 @@ -226,11 +226,11 @@ class PetApi( * Update an existing pet asynchronously * * - * @param pet Pet object that needs to be added to the store + * @param body Pet object that needs to be added to the store * @return Future(void) */ - def updatePetAsync(pet: Pet) = { - helper.updatePet(pet) + def updatePetAsync(body: Pet) = { + helper.updatePet(body) } /** @@ -297,7 +297,7 @@ class PetApi( class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - def addPet(pet: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { + def addPet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { // create path and map variables val path = (addFmt("/pet")) @@ -305,9 +305,9 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (pet == null) throw new Exception("Missing required parameter 'pet' when calling PetApi->addPet") + 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(pet)) + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } @@ -385,7 +385,7 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends } } - def updatePet(pet: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { + def updatePet(body: Pet)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[Pet]): Future[Unit] = { // create path and map variables val path = (addFmt("/pet")) @@ -393,9 +393,9 @@ class PetApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (pet == null) throw new Exception("Missing required parameter 'pet' when calling PetApi->updatePet") + 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(pet)) + val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } diff --git a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/StoreApi.scala b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/StoreApi.scala index 6028a5f181..ed574a0eac 100644 --- a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/StoreApi.scala +++ b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/StoreApi.scala @@ -153,11 +153,11 @@ class StoreApi( * Place an order for a pet * * - * @param order order placed for purchasing the pet + * @param body order placed for purchasing the pet * @return Order */ - def placeOrder(order: Order): Option[Order] = { - val await = Try(Await.result(placeOrderAsync(order), Duration.Inf)) + 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 @@ -168,11 +168,11 @@ class StoreApi( * Place an order for a pet asynchronously * * - * @param order order placed for purchasing the pet + * @param body order placed for purchasing the pet * @return Future(Order) */ - def placeOrderAsync(order: Order): Future[Order] = { - helper.placeOrder(order) + def placeOrderAsync(body: Order): Future[Order] = { + helper.placeOrder(body) } } @@ -228,7 +228,7 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend } } - def placeOrder(order: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = { + def placeOrder(body: Order)(implicit reader: ClientResponseReader[Order], writer: RequestWriter[Order]): Future[Order] = { // create path and map variables val path = (addFmt("/store/order")) @@ -236,9 +236,9 @@ class StoreApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extend val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (order == null) throw new Exception("Missing required parameter 'order' when calling StoreApi->placeOrder") + 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(order)) + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } diff --git a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/UserApi.scala b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/UserApi.scala index b48b107644..141e7a18dd 100644 --- a/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/UserApi.scala +++ b/samples/client/petstore/scala-httpclient/src/main/scala/org/openapitools/client/api/UserApi.scala @@ -77,11 +77,11 @@ class UserApi( * Create user * This can only be done by the logged in user. * - * @param user Created user object + * @param body Created user object * @return void */ - def createUser(user: User) = { - val await = Try(Await.result(createUserAsync(user), Duration.Inf)) + 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 @@ -92,22 +92,22 @@ class UserApi( * Create user asynchronously * This can only be done by the logged in user. * - * @param user Created user object + * @param body Created user object * @return Future(void) */ - def createUserAsync(user: User) = { - helper.createUser(user) + def createUserAsync(body: User) = { + helper.createUser(body) } /** * Creates list of users with given input array * * - * @param user List of user object + * @param body List of user object * @return void */ - def createUsersWithArrayInput(user: List[User]) = { - val await = Try(Await.result(createUsersWithArrayInputAsync(user), Duration.Inf)) + 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 @@ -118,22 +118,22 @@ class UserApi( * Creates list of users with given input array asynchronously * * - * @param user List of user object + * @param body List of user object * @return Future(void) */ - def createUsersWithArrayInputAsync(user: List[User]) = { - helper.createUsersWithArrayInput(user) + def createUsersWithArrayInputAsync(body: List[User]) = { + helper.createUsersWithArrayInput(body) } /** * Creates list of users with given input array * * - * @param user List of user object + * @param body List of user object * @return void */ - def createUsersWithListInput(user: List[User]) = { - val await = Try(Await.result(createUsersWithListInputAsync(user), Duration.Inf)) + 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 @@ -144,11 +144,11 @@ class UserApi( * Creates list of users with given input array asynchronously * * - * @param user List of user object + * @param body List of user object * @return Future(void) */ - def createUsersWithListInputAsync(user: List[User]) = { - helper.createUsersWithListInput(user) + def createUsersWithListInputAsync(body: List[User]) = { + helper.createUsersWithListInput(body) } /** @@ -260,11 +260,11 @@ class UserApi( * This can only be done by the logged in user. * * @param username name that need to be deleted - * @param user Updated user object + * @param body Updated user object * @return void */ - def updateUser(username: String, user: User) = { - val await = Try(Await.result(updateUserAsync(username, user), Duration.Inf)) + 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 @@ -276,18 +276,18 @@ class UserApi( * This can only be done by the logged in user. * * @param username name that need to be deleted - * @param user Updated user object + * @param body Updated user object * @return Future(void) */ - def updateUserAsync(username: String, user: User) = { - helper.updateUser(username, user) + def updateUserAsync(username: String, body: User) = { + helper.updateUser(username, body) } } class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends ApiClient(client, config) { - def createUser(user: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { + def createUser(body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { // create path and map variables val path = (addFmt("/user")) @@ -295,15 +295,15 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUser") + 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(user)) + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } } - def createUsersWithArrayInput(user: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { + def createUsersWithArrayInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { // create path and map variables val path = (addFmt("/user/createWithArray")) @@ -311,15 +311,15 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUsersWithArrayInput") + 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(user)) + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } } - def createUsersWithListInput(user: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { + def createUsersWithListInput(body: List[User])(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[List[User]]): Future[Unit] = { // create path and map variables val path = (addFmt("/user/createWithList")) @@ -327,9 +327,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends val queryParams = new mutable.HashMap[String, String] val headerParams = new mutable.HashMap[String, String] - if (user == null) throw new Exception("Missing required parameter 'user' when calling UserApi->createUsersWithListInput") + 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(user)) + val resFuture = client.submit("POST", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) } @@ -409,7 +409,7 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends } def updateUser(username: String, - user: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { + body: User)(implicit reader: ClientResponseReader[Unit], writer: RequestWriter[User]): Future[Unit] = { // create path and map variables val path = (addFmt("/user/{username}") replaceAll("\\{" + "username" + "\\}", username.toString)) @@ -420,9 +420,9 @@ class UserApiAsyncHelper(client: TransportClient, config: SwaggerConfig) extends if (username == null) throw new Exception("Missing required parameter 'username' when calling UserApi->updateUser") - if (user == null) throw new Exception("Missing required parameter 'user' 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(user)) + val resFuture = client.submit("PUT", path, queryParams.toMap, headerParams.toMap, writer.write(body)) resFuture flatMap { resp => process(reader.read(resp)) }