diff --git a/README.md b/README.md index 241f986411c..a11e42d50bf 100644 --- a/README.md +++ b/README.md @@ -1005,6 +1005,7 @@ Here is a list of template creators: * Scala (scalaz & http4s): @tbrown1979 * Scala (Akka): @cchafer * Scala (sttp): @chameleon82 + * Scala (sttp4): @flsh86 * Swift: @tkqubo * Swift 3: @hexelon * Swift 4: @ehyche @@ -1164,7 +1165,7 @@ If you want to join the committee, please kindly apply by sending an email to te | R | @Ramanth (2019/07) @saigiridhar21 (2019/07) | | Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) | | Rust | @frol (2017/07) @farcaller (2017/08) @richardwhiuk (2019/07) @paladinzh (2020/05) @jacob-pro (2022/10) | -| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) | +| Scala | @clasnake (2017/07), @jimschubert (2017/09) [:heart:](https://www.patreon.com/jimschubert), @shijinkui (2018/01), @ramzimaalej (2018/03), @chameleon82 (2020/03), @Bouillie (2020/04) @fish86 (2023/06) | | Swift | @jgavris (2017/07) @ehyche (2017/08) @Edubits (2017/09) @jaz-ah (2017/09) @4brunu (2019/11) @dydus0x14 (2023/06) | | TypeScript | @TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) @davidgamero (2022/03) @mkusaka (2022/04) | | Xojo | @Topheee (2023/04) | diff --git a/bin/configs/scala-sttp4-petstore-new.yaml b/bin/configs/scala-sttp4.yaml similarity index 82% rename from bin/configs/scala-sttp4-petstore-new.yaml rename to bin/configs/scala-sttp4.yaml index 6f8f95ec491..a5348147006 100644 --- a/bin/configs/scala-sttp4-petstore-new.yaml +++ b/bin/configs/scala-sttp4.yaml @@ -1,5 +1,5 @@ generatorName: scala-sttp4 -outputDir: samples/client/petstore/scala/sttp4 +outputDir: samples/client/petstore/scala-sttp4 inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml templateDir: modules/openapi-generator/src/main/resources/scala-sttp4 additionalProperties: diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4ClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4ClientCodegen.java index 3dd5def7810..7146fff3b6c 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4ClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaSttp4ClientCodegen.java @@ -238,7 +238,7 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod /** * Update/clean up model imports - * + *

* append '._" if the import is a Enum class, otherwise * remove model imports to avoid warnings for importing class in the same package in Scala * @@ -272,8 +272,7 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod item.put("import", importPath.concat("._")); newImports.add(item); } - } - else { + } else { item.put("import", importPath); newImports.add(item); } @@ -353,8 +352,7 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod Map item = new HashMap<>(); if (isEnumClass(importPath, enumRefs)) { item.put("import", importPath.concat("._")); - } - else { + } else { item.put("import", importPath); } newImports.add(item); diff --git a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig index 9c6357e26ad..2f9d1f0907d 100644 --- a/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig +++ b/modules/openapi-generator/src/main/resources/META-INF/services/org.openapitools.codegen.CodegenConfig @@ -119,12 +119,14 @@ org.openapitools.codegen.languages.ScalaGatlingCodegen org.openapitools.codegen.languages.ScalaLagomServerCodegen org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen org.openapitools.codegen.languages.ScalaSttpClientCodegen +org.openapitools.codegen.languages.ScalaSttp4ClientCodegen org.openapitools.codegen.languages.ScalazClientCodegen org.openapitools.codegen.languages.SpringCodegen org.openapitools.codegen.languages.StaticDocCodegen org.openapitools.codegen.languages.StaticHtmlGenerator org.openapitools.codegen.languages.StaticHtml2Generator org.openapitools.codegen.languages.Swift5ClientCodegen +org.openapitools.codegen.languages.SwiftCombineClientCodegen org.openapitools.codegen.languages.TypeScriptClientCodegen org.openapitools.codegen.languages.TypeScriptAngularClientCodegen org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen @@ -138,5 +140,3 @@ org.openapitools.codegen.languages.TypeScriptReduxQueryClientCodegen org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen org.openapitools.codegen.languages.WsdlSchemaCodegen org.openapitools.codegen.languages.XojoClientCodegen -org.openapitools.codegen.languages.ScalaSttp4ClientCodegen -org.openapitools.codegen.languages.SwiftCombineClientCodegen diff --git a/modules/openapi-generator/src/main/resources/scala-sttp4/api.mustache b/modules/openapi-generator/src/main/resources/scala-sttp4/api.mustache index 97a24613659..732eedb2989 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp4/api.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp4/api.mustache @@ -10,8 +10,7 @@ import sttp.model.Method {{#operations}} object {{classname}} { - -def apply(baseUrl: String = "{{{basePath}}}") = new {{classname}}(baseUrl) + def apply(baseUrl: String = "{{{basePath}}}") = new {{classname}}(baseUrl) } class {{classname}}(baseUrl: String) { diff --git a/modules/openapi-generator/src/main/resources/scala-sttp4/methodParameters.mustache b/modules/openapi-generator/src/main/resources/scala-sttp4/methodParameters.mustache index 17f4d011888..8d056a18a4c 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp4/methodParameters.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp4/methodParameters.mustache @@ -1 +1 @@ -{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}apiKey: String{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}} +{{#authMethods.0}}{{#authMethods}}{{#isApiKey}}apiKey: String{{/isApiKey}}{{#isBasic}}{{#isBasicBasic}}username: String, password: String{{/isBasicBasic}}{{#isBasicBearer}}bearerToken: String{{/isBasicBearer}}{{/isBasic}}{{^-last}}, {{/-last}}{{/authMethods}})({{/authMethods.0}}{{#allParams}}{{paramName}}: {{#required}}{{dataType}}{{/required}}{{^required}}{{#isContainer}}{{dataType}}{{/isContainer}}{{^isContainer}}Option[{{dataType}}]{{/isContainer}}{{/required}}{{^defaultValue}}{{^required}}{{^isContainer}} = None{{/isContainer}}{{/required}}{{/defaultValue}}{{^-last}}, {{/-last}}{{/allParams}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/scala-sttp4/model.mustache b/modules/openapi-generator/src/main/resources/scala-sttp4/model.mustache index a2cd060105c..ecece27a59a 100644 --- a/modules/openapi-generator/src/main/resources/scala-sttp4/model.mustache +++ b/modules/openapi-generator/src/main/resources/scala-sttp4/model.mustache @@ -2,59 +2,59 @@ package {{package}} {{#imports}} - import {{import}} +import {{import}} {{/imports}} {{#models}} - {{#model}} - {{#description}} - {{#javadocRenderer}} - {{#title}} - {{{.}}} - {{/title}} - {{{description}}} - {{/javadocRenderer}} - {{/description}} - {{^isEnum}} - case class {{classname}}( - {{#vars}} - {{#description}} - /* {{{.}}} */ - {{/description}} - {{{name}}}: {{^required}}Option[{{/required}}{{^isEnum}}{{dataType}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}Enums.{{datatypeWithEnum}}{{/isArray}}{{#isArray}}Seq[{{classname}}Enums.{{datatypeWithEnum}}]{{/isArray}}{{/isEnum}}{{^required}}] = None{{/required}}{{^-last}},{{/-last}} - {{/vars}} - ) - {{/isEnum}} +{{#model}} +{{#description}} +{{#javadocRenderer}} +{{#title}} +{{{.}}} +{{/title}} +{{{description}}} +{{/javadocRenderer}} +{{/description}} +{{^isEnum}} +case class {{classname}}( + {{#vars}} + {{#description}} + /* {{{.}}} */ + {{/description}} + {{{name}}}: {{^required}}Option[{{/required}}{{^isEnum}}{{dataType}}{{/isEnum}}{{#isEnum}}{{^isArray}}{{classname}}Enums.{{datatypeWithEnum}}{{/isArray}}{{#isArray}}Seq[{{classname}}Enums.{{datatypeWithEnum}}]{{/isArray}}{{/isEnum}}{{^required}}] = None{{/required}}{{^-last}},{{/-last}} + {{/vars}} +) +{{/isEnum}} - {{#isEnum}} - object {{classname}} extends Enumeration { - type {{classname}} = {{classname}}.Value - {{#allowableValues}} - {{#values}} - val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") - {{/values}} - {{/allowableValues}} - } - {{/isEnum}} - {{#hasEnums}} - object {{classname}}Enums { +{{#isEnum}} +object {{classname}} extends Enumeration { + type {{classname}} = {{classname}}.Value +{{#allowableValues}} + {{#values}} + val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") + {{/values}} +{{/allowableValues}} +} +{{/isEnum}} +{{#hasEnums}} +object {{classname}}Enums { - {{#vars}} - {{#isEnum}} - type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value - {{/isEnum}} - {{/vars}} - {{#vars}} - {{#isEnum}} - object {{datatypeWithEnum}} extends Enumeration { - {{#_enum}} - val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") - {{/_enum}} - } + {{#vars}} + {{#isEnum}} + type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value + {{/isEnum}} + {{/vars}} + {{#vars}} + {{#isEnum}} + object {{datatypeWithEnum}} extends Enumeration { +{{#_enum}} + val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") +{{/_enum}} + } - {{/isEnum}} - {{/vars}} - } - {{/hasEnums}} - {{/model}} + {{/isEnum}} + {{/vars}} +} +{{/hasEnums}} +{{/model}} {{/models}} diff --git a/pom.xml b/pom.xml index e83e705f9f9..c55076158c5 100644 --- a/pom.xml +++ b/pom.xml @@ -1282,6 +1282,7 @@ samples/client/petstore/scala-akka samples/client/petstore/scala-sttp + samples/client/petstore/scala-sttp4 samples/client/petstore/clojure samples/client/petstore/java/jersey2-java8 samples/openapi3/client/petstore/java/jersey2-java8 diff --git a/samples/client/petstore/scala/sttp4/.openapi-generator-ignore b/samples/client/petstore/scala-sttp4/.openapi-generator-ignore similarity index 100% rename from samples/client/petstore/scala/sttp4/.openapi-generator-ignore rename to samples/client/petstore/scala-sttp4/.openapi-generator-ignore diff --git a/samples/client/petstore/scala/sttp4/.openapi-generator/FILES b/samples/client/petstore/scala-sttp4/.openapi-generator/FILES similarity index 100% rename from samples/client/petstore/scala/sttp4/.openapi-generator/FILES rename to samples/client/petstore/scala-sttp4/.openapi-generator/FILES diff --git a/samples/client/petstore/scala/sttp4/.openapi-generator/VERSION b/samples/client/petstore/scala-sttp4/.openapi-generator/VERSION similarity index 100% rename from samples/client/petstore/scala/sttp4/.openapi-generator/VERSION rename to samples/client/petstore/scala-sttp4/.openapi-generator/VERSION diff --git a/samples/client/petstore/scala/sttp4/README.md b/samples/client/petstore/scala-sttp4/README.md similarity index 100% rename from samples/client/petstore/scala/sttp4/README.md rename to samples/client/petstore/scala-sttp4/README.md diff --git a/samples/client/petstore/scala/sttp4/build.sbt b/samples/client/petstore/scala-sttp4/build.sbt similarity index 100% rename from samples/client/petstore/scala/sttp4/build.sbt rename to samples/client/petstore/scala-sttp4/build.sbt diff --git a/samples/client/petstore/scala-sttp4/pom.xml b/samples/client/petstore/scala-sttp4/pom.xml new file mode 100644 index 00000000000..59513704ffc --- /dev/null +++ b/samples/client/petstore/scala-sttp4/pom.xml @@ -0,0 +1,34 @@ + + 4.0.0 + org.openapitools + scala-sttp4-petstore-client + pom + 1.0-SNAPSHOT + scala-sttp4-petstore-client + + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + sbt-test + integration-test + + exec + + + sbt + + -ivy + ${user.home}/.ivy2 + test + + + + + + + + diff --git a/samples/client/petstore/scala/sttp4/project/build.properties b/samples/client/petstore/scala-sttp4/project/build.properties similarity index 100% rename from samples/client/petstore/scala/sttp4/project/build.properties rename to samples/client/petstore/scala-sttp4/project/build.properties diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala similarity index 82% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala index 57a29cebb84..7c483930db1 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/PetApi.scala @@ -19,8 +19,7 @@ import sttp.client4._ import sttp.model.Method object PetApi { - -def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new PetApi(baseUrl) + def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new PetApi(baseUrl) } class PetApi(baseUrl: String) { @@ -34,8 +33,7 @@ class PetApi(baseUrl: String) { * * @param pet Pet object that needs to be added to the store */ - def addPet(pet: Pet -): Request[Either[ResponseException[String, Exception], Pet]] = + def addPet(pet: Pet): Request[Either[ResponseException[String, Exception], Pet]] = basicRequest .method(Method.POST, uri"$baseUrl/pet") .contentType("application/json") @@ -51,8 +49,7 @@ class PetApi(baseUrl: String) { * @param petId Pet id to delete * @param apiKey */ - def deletePet(petId: Long, apiKey: Option[String] = None -): Request[Either[ResponseException[String, Exception], Unit]] = + def deletePet(petId: Long, apiKey: Option[String] = None): Request[Either[ResponseException[String, Exception], Unit]] = basicRequest .method(Method.DELETE, uri"$baseUrl/pet/${petId}") .contentType("application/json") @@ -68,8 +65,7 @@ class PetApi(baseUrl: String) { * * @param status Status values that need to be considered for filter */ - def findPetsByStatus(status: Seq[String] -): Request[Either[ResponseException[String, Exception], Seq[Pet]]] = + def findPetsByStatus(status: Seq[String]): Request[Either[ResponseException[String, Exception], Seq[Pet]]] = basicRequest .method(Method.GET, uri"$baseUrl/pet/findByStatus?status=${ status }") .contentType("application/json") @@ -84,8 +80,7 @@ class PetApi(baseUrl: String) { * * @param tags Tags to filter by */ - def findPetsByTags(tags: Seq[String] -): Request[Either[ResponseException[String, Exception], Seq[Pet]]] = + def findPetsByTags(tags: Seq[String]): Request[Either[ResponseException[String, Exception], Seq[Pet]]] = basicRequest .method(Method.GET, uri"$baseUrl/pet/findByTags?tags=${ tags }") .contentType("application/json") @@ -104,8 +99,7 @@ class PetApi(baseUrl: String) { * * @param petId ID of pet to return */ - def getPetById(apiKey: String)(petId: Long -): Request[Either[ResponseException[String, Exception], Pet]] = + def getPetById(apiKey: String)(petId: Long): Request[Either[ResponseException[String, Exception], Pet]] = basicRequest .method(Method.GET, uri"$baseUrl/pet/${petId}") .contentType("application/json") @@ -123,8 +117,7 @@ class PetApi(baseUrl: String) { * * @param pet Pet object that needs to be added to the store */ - def updatePet(pet: Pet -): Request[Either[ResponseException[String, Exception], Pet]] = + def updatePet(pet: Pet): Request[Either[ResponseException[String, Exception], Pet]] = basicRequest .method(Method.PUT, uri"$baseUrl/pet") .contentType("application/json") @@ -141,8 +134,7 @@ class PetApi(baseUrl: String) { * @param name Updated name of the pet * @param status Updated status of the pet */ - def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None -): Request[Either[ResponseException[String, Exception], Unit]] = + def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): Request[Either[ResponseException[String, Exception], Unit]] = basicRequest .method(Method.POST, uri"$baseUrl/pet/${petId}") .contentType("application/x-www-form-urlencoded") @@ -162,8 +154,7 @@ class PetApi(baseUrl: String) { * @param additionalMetadata Additional data to pass to server * @param file file to upload */ - def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None -): Request[Either[ResponseException[String, Exception], ApiResponse]] = + def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): Request[Either[ResponseException[String, Exception], ApiResponse]] = basicRequest .method(Method.POST, uri"$baseUrl/pet/${petId}/uploadImage") .contentType("multipart/form-data") diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala similarity index 82% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala index 292dafdd512..d4d14232b39 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/StoreApi.scala @@ -17,8 +17,7 @@ import sttp.client4._ import sttp.model.Method object StoreApi { - -def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new StoreApi(baseUrl) + def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new StoreApi(baseUrl) } class StoreApi(baseUrl: String) { @@ -32,8 +31,7 @@ class StoreApi(baseUrl: String) { * * @param orderId ID of the order that needs to be deleted */ - def deleteOrder(orderId: String -): Request[Either[ResponseException[String, Exception], Unit]] = + def deleteOrder(orderId: String): Request[Either[ResponseException[String, Exception], Unit]] = basicRequest .method(Method.DELETE, uri"$baseUrl/store/order/${orderId}") .contentType("application/json") @@ -48,8 +46,7 @@ class StoreApi(baseUrl: String) { * Available security schemes: * api_key (apiKey) */ - def getInventory(apiKey: String)( -): Request[Either[ResponseException[String, Exception], Map[String, Int]]] = + def getInventory(apiKey: String)(): Request[Either[ResponseException[String, Exception], Map[String, Int]]] = basicRequest .method(Method.GET, uri"$baseUrl/store/inventory") .contentType("application/json") @@ -66,8 +63,7 @@ class StoreApi(baseUrl: String) { * * @param orderId ID of pet that needs to be fetched */ - def getOrderById(orderId: Long -): Request[Either[ResponseException[String, Exception], Order]] = + def getOrderById(orderId: Long): Request[Either[ResponseException[String, Exception], Order]] = basicRequest .method(Method.GET, uri"$baseUrl/store/order/${orderId}") .contentType("application/json") @@ -82,8 +78,7 @@ class StoreApi(baseUrl: String) { * * @param order order placed for purchasing the pet */ - def placeOrder(order: Order -): Request[Either[ResponseException[String, Exception], Order]] = + def placeOrder(order: Order): Request[Either[ResponseException[String, Exception], Order]] = basicRequest .method(Method.POST, uri"$baseUrl/store/order") .contentType("application/json") diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala similarity index 82% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala index ee8a1489e91..c86bc67d21c 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/api/UserApi.scala @@ -18,8 +18,7 @@ import sttp.client4._ import sttp.model.Method object UserApi { - -def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new UserApi(baseUrl) + def apply(baseUrl: String = "http://petstore.swagger.io/v2") = new UserApi(baseUrl) } class UserApi(baseUrl: String) { @@ -35,8 +34,7 @@ class UserApi(baseUrl: String) { * * @param user Created user object */ - def createUser(apiKey: String)(user: User -): Request[Either[Either[String, String], Unit]] = + def createUser(apiKey: String)(user: User): Request[Either[Either[String, String], Unit]] = basicRequest .method(Method.POST, uri"$baseUrl/user") .contentType("application/json") @@ -55,8 +53,7 @@ class UserApi(baseUrl: String) { * * @param user List of user object */ - def createUsersWithArrayInput(apiKey: String)(user: Seq[User] -): Request[Either[Either[String, String], Unit]] = + def createUsersWithArrayInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] = basicRequest .method(Method.POST, uri"$baseUrl/user/createWithArray") .contentType("application/json") @@ -75,8 +72,7 @@ class UserApi(baseUrl: String) { * * @param user List of user object */ - def createUsersWithListInput(apiKey: String)(user: Seq[User] -): Request[Either[Either[String, String], Unit]] = + def createUsersWithListInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] = basicRequest .method(Method.POST, uri"$baseUrl/user/createWithList") .contentType("application/json") @@ -96,8 +92,7 @@ class UserApi(baseUrl: String) { * * @param username The name that needs to be deleted */ - def deleteUser(apiKey: String)(username: String -): Request[Either[ResponseException[String, Exception], Unit]] = + def deleteUser(apiKey: String)(username: String): Request[Either[ResponseException[String, Exception], Unit]] = basicRequest .method(Method.DELETE, uri"$baseUrl/user/${username}") .contentType("application/json") @@ -114,8 +109,7 @@ class UserApi(baseUrl: String) { * * @param username The name that needs to be fetched. Use user1 for testing. */ - def getUserByName(username: String -): Request[Either[ResponseException[String, Exception], User]] = + def getUserByName(username: String): Request[Either[ResponseException[String, Exception], User]] = basicRequest .method(Method.GET, uri"$baseUrl/user/${username}") .contentType("application/json") @@ -135,8 +129,7 @@ class UserApi(baseUrl: String) { * @param username The user name for login * @param password The password for login in clear text */ - def loginUser(username: String, password: String -): Request[Either[ResponseException[String, Exception], String]] = + def loginUser(username: String, password: String): Request[Either[ResponseException[String, Exception], String]] = basicRequest .method(Method.GET, uri"$baseUrl/user/login?username=${ username }&password=${ password }") .contentType("application/json") @@ -151,8 +144,7 @@ class UserApi(baseUrl: String) { * Available security schemes: * api_key (apiKey) */ - def logoutUser(apiKey: String)( -): Request[Either[Either[String, String], Unit]] = + def logoutUser(apiKey: String)(): Request[Either[Either[String, String], Unit]] = basicRequest .method(Method.GET, uri"$baseUrl/user/logout") .contentType("application/json") @@ -172,8 +164,7 @@ class UserApi(baseUrl: String) { * @param username name that need to be deleted * @param user Updated user object */ - def updateUser(apiKey: String)(username: String, user: User -): Request[Either[ResponseException[String, Exception], Unit]] = + def updateUser(apiKey: String)(username: String, user: User): Request[Either[ResponseException[String, Exception], Unit]] = basicRequest .method(Method.PUT, uri"$baseUrl/user/${username}") .contentType("application/json") diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/AdditionalTypeSerializers.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/AdditionalTypeSerializers.scala similarity index 100% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/AdditionalTypeSerializers.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/AdditionalTypeSerializers.scala diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/DateSerializers.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/DateSerializers.scala similarity index 100% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/DateSerializers.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/DateSerializers.scala diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/JsonSupport.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/JsonSupport.scala similarity index 100% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/core/JsonSupport.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/core/JsonSupport.scala diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala similarity index 58% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala index bbd9803e2bf..b0abb512265 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/ApiResponse.scala @@ -13,12 +13,12 @@ package org.openapitools.client.model /** - * An uploaded response - * Describes the result of uploading an image resource + * An uploaded response + * Describes the result of uploading an image resource */ - case class ApiResponse( - code: Option[Int] = None, - `type`: Option[String] = None, - message: Option[String] = None - ) +case class ApiResponse( + code: Option[Int] = None, + `type`: Option[String] = None, + message: Option[String] = None +) diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Category.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Category.scala similarity index 67% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Category.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Category.scala index 98c2886bed3..169acc49cef 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Category.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Category.scala @@ -13,11 +13,11 @@ package org.openapitools.client.model /** - * Pet category - * A category for a pet + * Pet category + * A category for a pet */ - case class Category( - id: Option[Long] = None, - name: Option[String] = None - ) +case class Category( + id: Option[Long] = None, + name: Option[String] = None +) diff --git a/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Order.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Order.scala new file mode 100644 index 00000000000..9e805e256b2 --- /dev/null +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Order.scala @@ -0,0 +1,39 @@ +/** + * 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. + * + * The version of the OpenAPI document: 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.time.OffsetDateTime + + /** + * Pet Order + * An order for a pets from the pet store + */ +case class Order( + id: Option[Long] = None, + petId: Option[Long] = None, + quantity: Option[Int] = None, + shipDate: Option[OffsetDateTime] = None, + /* Order Status */ + status: Option[OrderEnums.Status] = None, + complete: Option[Boolean] = None +) + +object OrderEnums { + + type Status = Status.Value + object Status extends Enumeration { + val Placed = Value("placed") + val Approved = Value("approved") + val Delivered = Value("delivered") + } + +} diff --git a/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Pet.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Pet.scala new file mode 100644 index 00000000000..3cbab605128 --- /dev/null +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Pet.scala @@ -0,0 +1,38 @@ +/** + * 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. + * + * The version of the OpenAPI document: 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 + + + /** + * a Pet + * A pet for sale in the pet store + */ +case class Pet( + id: Option[Long] = None, + category: Option[Category] = None, + name: String, + photoUrls: Seq[String], + tags: Option[Seq[Tag]] = None, + /* pet status in the store */ + status: Option[PetEnums.Status] = None +) + +object PetEnums { + + type Status = Status.Value + object Status extends Enumeration { + val Available = Value("available") + val Pending = Value("pending") + val Sold = Value("sold") + } + +} diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Tag.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Tag.scala similarity index 68% rename from samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Tag.scala rename to samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Tag.scala index 9eefb0eb9de..c2020246658 100644 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Tag.scala +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/Tag.scala @@ -13,11 +13,11 @@ package org.openapitools.client.model /** - * Pet Tag - * A tag for a pet + * Pet Tag + * A tag for a pet */ - case class Tag( - id: Option[Long] = None, - name: Option[String] = None - ) +case class Tag( + id: Option[Long] = None, + name: Option[String] = None +) diff --git a/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/User.scala b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/User.scala new file mode 100644 index 00000000000..6977180bcce --- /dev/null +++ b/samples/client/petstore/scala-sttp4/src/main/scala/org/openapitools/client/model/User.scala @@ -0,0 +1,30 @@ +/** + * 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. + * + * The version of the OpenAPI document: 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 + + + /** + * a User + * A User who is purchasing from the pet store + */ +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[Int] = None +) + diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Order.scala b/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Order.scala deleted file mode 100644 index 203a56f5595..00000000000 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Order.scala +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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. - * - * The version of the OpenAPI document: 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.time.OffsetDateTime - - /** - * Pet Order - * An order for a pets from the pet store - */ - case class Order( - id: Option[Long] = None, - petId: Option[Long] = None, - quantity: Option[Int] = None, - shipDate: Option[OffsetDateTime] = None, - /* Order Status */ - status: Option[OrderEnums.Status] = None, - complete: Option[Boolean] = None - ) - - object OrderEnums { - - type Status = Status.Value - object Status extends Enumeration { - val Placed = Value("placed") - val Approved = Value("approved") - val Delivered = Value("delivered") - } - - } diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Pet.scala b/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Pet.scala deleted file mode 100644 index a7260f23bf2..00000000000 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/Pet.scala +++ /dev/null @@ -1,38 +0,0 @@ -/** - * 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. - * - * The version of the OpenAPI document: 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 - - - /** - * a Pet - * A pet for sale in the pet store - */ - case class Pet( - id: Option[Long] = None, - category: Option[Category] = None, - name: String, - photoUrls: Seq[String], - tags: Option[Seq[Tag]] = None, - /* pet status in the store */ - status: Option[PetEnums.Status] = None - ) - - object PetEnums { - - type Status = Status.Value - object Status extends Enumeration { - val Available = Value("available") - val Pending = Value("pending") - val Sold = Value("sold") - } - - } diff --git a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/User.scala b/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/User.scala deleted file mode 100644 index da93c063d54..00000000000 --- a/samples/client/petstore/scala/sttp4/src/main/scala/org/openapitools/client/model/User.scala +++ /dev/null @@ -1,30 +0,0 @@ -/** - * 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. - * - * The version of the OpenAPI document: 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 - - - /** - * a User - * A User who is purchasing from the pet store - */ - 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[Int] = None - ) -