Various improvements to scala-sttp4 generator (#15931)

* various improvements to scala-sttp4 generator

* test scala with jdk11

* test sttp4 in circleci

* add pom.xml

* update

* update tc
This commit is contained in:
William Cheng 2023-06-27 23:27:38 +08:00 committed by GitHub
parent 7a73f75f70
commit fac04cfa9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 243 additions and 233 deletions

View File

@ -1005,6 +1005,7 @@ Here is a list of template creators:
* Scala (scalaz & http4s): @tbrown1979 * Scala (scalaz & http4s): @tbrown1979
* Scala (Akka): @cchafer * Scala (Akka): @cchafer
* Scala (sttp): @chameleon82 * Scala (sttp): @chameleon82
* Scala (sttp4): @flsh86
* Swift: @tkqubo * Swift: @tkqubo
* Swift 3: @hexelon * Swift 3: @hexelon
* Swift 4: @ehyche * 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) | | R | @Ramanth (2019/07) @saigiridhar21 (2019/07) |
| Ruby | @cliffano (2017/07) @zlx (2017/09) @autopp (2019/02) | | 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) | | 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) | | 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) | | 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) | | Xojo | @Topheee (2023/04) |

View File

@ -1,5 +1,5 @@
generatorName: scala-sttp4 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 inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore.yaml
templateDir: modules/openapi-generator/src/main/resources/scala-sttp4 templateDir: modules/openapi-generator/src/main/resources/scala-sttp4
additionalProperties: additionalProperties:

View File

@ -238,7 +238,7 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod
/** /**
* Update/clean up model imports * Update/clean up model imports
* * <p>
* append '._" if the import is a Enum class, otherwise * append '._" if the import is a Enum class, otherwise
* remove model imports to avoid warnings for importing class in the same package in Scala * 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("._")); item.put("import", importPath.concat("._"));
newImports.add(item); newImports.add(item);
} }
} } else {
else {
item.put("import", importPath); item.put("import", importPath);
newImports.add(item); newImports.add(item);
} }
@ -353,8 +352,7 @@ public class ScalaSttp4ClientCodegen extends AbstractScalaCodegen implements Cod
Map<String, String> item = new HashMap<>(); Map<String, String> item = new HashMap<>();
if (isEnumClass(importPath, enumRefs)) { if (isEnumClass(importPath, enumRefs)) {
item.put("import", importPath.concat("._")); item.put("import", importPath.concat("._"));
} } else {
else {
item.put("import", importPath); item.put("import", importPath);
} }
newImports.add(item); newImports.add(item);

View File

@ -119,12 +119,14 @@ org.openapitools.codegen.languages.ScalaGatlingCodegen
org.openapitools.codegen.languages.ScalaLagomServerCodegen org.openapitools.codegen.languages.ScalaLagomServerCodegen
org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen
org.openapitools.codegen.languages.ScalaSttpClientCodegen org.openapitools.codegen.languages.ScalaSttpClientCodegen
org.openapitools.codegen.languages.ScalaSttp4ClientCodegen
org.openapitools.codegen.languages.ScalazClientCodegen org.openapitools.codegen.languages.ScalazClientCodegen
org.openapitools.codegen.languages.SpringCodegen org.openapitools.codegen.languages.SpringCodegen
org.openapitools.codegen.languages.StaticDocCodegen org.openapitools.codegen.languages.StaticDocCodegen
org.openapitools.codegen.languages.StaticHtmlGenerator org.openapitools.codegen.languages.StaticHtmlGenerator
org.openapitools.codegen.languages.StaticHtml2Generator org.openapitools.codegen.languages.StaticHtml2Generator
org.openapitools.codegen.languages.Swift5ClientCodegen org.openapitools.codegen.languages.Swift5ClientCodegen
org.openapitools.codegen.languages.SwiftCombineClientCodegen
org.openapitools.codegen.languages.TypeScriptClientCodegen org.openapitools.codegen.languages.TypeScriptClientCodegen
org.openapitools.codegen.languages.TypeScriptAngularClientCodegen org.openapitools.codegen.languages.TypeScriptAngularClientCodegen
org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen org.openapitools.codegen.languages.TypeScriptAureliaClientCodegen
@ -138,5 +140,3 @@ org.openapitools.codegen.languages.TypeScriptReduxQueryClientCodegen
org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen org.openapitools.codegen.languages.TypeScriptRxjsClientCodegen
org.openapitools.codegen.languages.WsdlSchemaCodegen org.openapitools.codegen.languages.WsdlSchemaCodegen
org.openapitools.codegen.languages.XojoClientCodegen org.openapitools.codegen.languages.XojoClientCodegen
org.openapitools.codegen.languages.ScalaSttp4ClientCodegen
org.openapitools.codegen.languages.SwiftCombineClientCodegen

View File

@ -10,8 +10,7 @@ import sttp.model.Method
{{#operations}} {{#operations}}
object {{classname}} { object {{classname}} {
def apply(baseUrl: String = "{{{basePath}}}") = new {{classname}}(baseUrl)
def apply(baseUrl: String = "{{{basePath}}}") = new {{classname}}(baseUrl)
} }
class {{classname}}(baseUrl: String) { class {{classname}}(baseUrl: String) {

View File

@ -2,59 +2,59 @@
package {{package}} package {{package}}
{{#imports}} {{#imports}}
import {{import}} import {{import}}
{{/imports}} {{/imports}}
{{#models}} {{#models}}
{{#model}} {{#model}}
{{#description}} {{#description}}
{{#javadocRenderer}} {{#javadocRenderer}}
{{#title}} {{#title}}
{{{.}}} {{{.}}}
{{/title}} {{/title}}
{{{description}}} {{{description}}}
{{/javadocRenderer}} {{/javadocRenderer}}
{{/description}} {{/description}}
{{^isEnum}} {{^isEnum}}
case class {{classname}}( case class {{classname}}(
{{#vars}} {{#vars}}
{{#description}} {{#description}}
/* {{{.}}} */ /* {{{.}}} */
{{/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}} {{{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}} {{/vars}}
) )
{{/isEnum}} {{/isEnum}}
{{#isEnum}} {{#isEnum}}
object {{classname}} extends Enumeration { object {{classname}} extends Enumeration {
type {{classname}} = {{classname}}.Value type {{classname}} = {{classname}}.Value
{{#allowableValues}} {{#allowableValues}}
{{#values}} {{#values}}
val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}")
{{/values}} {{/values}}
{{/allowableValues}} {{/allowableValues}}
} }
{{/isEnum}} {{/isEnum}}
{{#hasEnums}} {{#hasEnums}}
object {{classname}}Enums { object {{classname}}Enums {
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}
type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value type {{datatypeWithEnum}} = {{datatypeWithEnum}}.Value
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/vars}}
{{#vars}} {{#vars}}
{{#isEnum}} {{#isEnum}}
object {{datatypeWithEnum}} extends Enumeration { object {{datatypeWithEnum}} extends Enumeration {
{{#_enum}} {{#_enum}}
val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}") val {{#fnEnumEntry}}{{.}}{{/fnEnumEntry}} = Value("{{.}}")
{{/_enum}} {{/_enum}}
} }
{{/isEnum}} {{/isEnum}}
{{/vars}} {{/vars}}
} }
{{/hasEnums}} {{/hasEnums}}
{{/model}} {{/model}}
{{/models}} {{/models}}

View File

@ -1282,6 +1282,7 @@
<!-- test java-related projects --> <!-- test java-related projects -->
<module>samples/client/petstore/scala-akka</module> <module>samples/client/petstore/scala-akka</module>
<module>samples/client/petstore/scala-sttp</module> <module>samples/client/petstore/scala-sttp</module>
<module>samples/client/petstore/scala-sttp4</module>
<module>samples/client/petstore/clojure</module> <module>samples/client/petstore/clojure</module>
<module>samples/client/petstore/java/jersey2-java8</module> <module>samples/client/petstore/java/jersey2-java8</module>
<module>samples/openapi3/client/petstore/java/jersey2-java8</module> <module>samples/openapi3/client/petstore/java/jersey2-java8</module>

View File

@ -0,0 +1,34 @@
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>org.openapitools</groupId>
<artifactId>scala-sttp4-petstore-client</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<name>scala-sttp4-petstore-client</name>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.5.0</version>
<executions>
<execution>
<id>sbt-test</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>sbt</executable>
<arguments>
<argument>-ivy</argument>
<argument>${user.home}/.ivy2</argument>
<argument>test</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

View File

@ -19,8 +19,7 @@ import sttp.client4._
import sttp.model.Method import sttp.model.Method
object PetApi { 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) { class PetApi(baseUrl: String) {
@ -34,8 +33,7 @@ class PetApi(baseUrl: String) {
* *
* @param pet Pet object that needs to be added to the store * @param pet Pet object that needs to be added to the store
*/ */
def addPet(pet: Pet def addPet(pet: Pet): Request[Either[ResponseException[String, Exception], Pet]] =
): Request[Either[ResponseException[String, Exception], Pet]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/pet") .method(Method.POST, uri"$baseUrl/pet")
.contentType("application/json") .contentType("application/json")
@ -51,8 +49,7 @@ class PetApi(baseUrl: String) {
* @param petId Pet id to delete * @param petId Pet id to delete
* @param apiKey * @param apiKey
*/ */
def deletePet(petId: Long, apiKey: Option[String] = None def deletePet(petId: Long, apiKey: Option[String] = None): Request[Either[ResponseException[String, Exception], Unit]] =
): Request[Either[ResponseException[String, Exception], Unit]] =
basicRequest basicRequest
.method(Method.DELETE, uri"$baseUrl/pet/${petId}") .method(Method.DELETE, uri"$baseUrl/pet/${petId}")
.contentType("application/json") .contentType("application/json")
@ -68,8 +65,7 @@ class PetApi(baseUrl: String) {
* *
* @param status Status values that need to be considered for filter * @param status Status values that need to be considered for filter
*/ */
def findPetsByStatus(status: Seq[String] def findPetsByStatus(status: Seq[String]): Request[Either[ResponseException[String, Exception], Seq[Pet]]] =
): Request[Either[ResponseException[String, Exception], Seq[Pet]]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/pet/findByStatus?status=${ status }") .method(Method.GET, uri"$baseUrl/pet/findByStatus?status=${ status }")
.contentType("application/json") .contentType("application/json")
@ -84,8 +80,7 @@ class PetApi(baseUrl: String) {
* *
* @param tags Tags to filter by * @param tags Tags to filter by
*/ */
def findPetsByTags(tags: Seq[String] def findPetsByTags(tags: Seq[String]): Request[Either[ResponseException[String, Exception], Seq[Pet]]] =
): Request[Either[ResponseException[String, Exception], Seq[Pet]]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/pet/findByTags?tags=${ tags }") .method(Method.GET, uri"$baseUrl/pet/findByTags?tags=${ tags }")
.contentType("application/json") .contentType("application/json")
@ -104,8 +99,7 @@ class PetApi(baseUrl: String) {
* *
* @param petId ID of pet to return * @param petId ID of pet to return
*/ */
def getPetById(apiKey: String)(petId: Long def getPetById(apiKey: String)(petId: Long): Request[Either[ResponseException[String, Exception], Pet]] =
): Request[Either[ResponseException[String, Exception], Pet]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/pet/${petId}") .method(Method.GET, uri"$baseUrl/pet/${petId}")
.contentType("application/json") .contentType("application/json")
@ -123,8 +117,7 @@ class PetApi(baseUrl: String) {
* *
* @param pet Pet object that needs to be added to the store * @param pet Pet object that needs to be added to the store
*/ */
def updatePet(pet: Pet def updatePet(pet: Pet): Request[Either[ResponseException[String, Exception], Pet]] =
): Request[Either[ResponseException[String, Exception], Pet]] =
basicRequest basicRequest
.method(Method.PUT, uri"$baseUrl/pet") .method(Method.PUT, uri"$baseUrl/pet")
.contentType("application/json") .contentType("application/json")
@ -141,8 +134,7 @@ class PetApi(baseUrl: String) {
* @param name Updated name of the pet * @param name Updated name of the pet
* @param status Updated status of the pet * @param status Updated status of the pet
*/ */
def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None def updatePetWithForm(petId: Long, name: Option[String] = None, status: Option[String] = None): Request[Either[ResponseException[String, Exception], Unit]] =
): Request[Either[ResponseException[String, Exception], Unit]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/pet/${petId}") .method(Method.POST, uri"$baseUrl/pet/${petId}")
.contentType("application/x-www-form-urlencoded") .contentType("application/x-www-form-urlencoded")
@ -162,8 +154,7 @@ class PetApi(baseUrl: String) {
* @param additionalMetadata Additional data to pass to server * @param additionalMetadata Additional data to pass to server
* @param file file to upload * @param file file to upload
*/ */
def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None def uploadFile(petId: Long, additionalMetadata: Option[String] = None, file: Option[File] = None): Request[Either[ResponseException[String, Exception], ApiResponse]] =
): Request[Either[ResponseException[String, Exception], ApiResponse]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/pet/${petId}/uploadImage") .method(Method.POST, uri"$baseUrl/pet/${petId}/uploadImage")
.contentType("multipart/form-data") .contentType("multipart/form-data")

View File

@ -17,8 +17,7 @@ import sttp.client4._
import sttp.model.Method import sttp.model.Method
object StoreApi { 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) { class StoreApi(baseUrl: String) {
@ -32,8 +31,7 @@ class StoreApi(baseUrl: String) {
* *
* @param orderId ID of the order that needs to be deleted * @param orderId ID of the order that needs to be deleted
*/ */
def deleteOrder(orderId: String def deleteOrder(orderId: String): Request[Either[ResponseException[String, Exception], Unit]] =
): Request[Either[ResponseException[String, Exception], Unit]] =
basicRequest basicRequest
.method(Method.DELETE, uri"$baseUrl/store/order/${orderId}") .method(Method.DELETE, uri"$baseUrl/store/order/${orderId}")
.contentType("application/json") .contentType("application/json")
@ -48,8 +46,7 @@ class StoreApi(baseUrl: String) {
* Available security schemes: * Available security schemes:
* api_key (apiKey) * api_key (apiKey)
*/ */
def getInventory(apiKey: String)( def getInventory(apiKey: String)(): Request[Either[ResponseException[String, Exception], Map[String, Int]]] =
): Request[Either[ResponseException[String, Exception], Map[String, Int]]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/store/inventory") .method(Method.GET, uri"$baseUrl/store/inventory")
.contentType("application/json") .contentType("application/json")
@ -66,8 +63,7 @@ class StoreApi(baseUrl: String) {
* *
* @param orderId ID of pet that needs to be fetched * @param orderId ID of pet that needs to be fetched
*/ */
def getOrderById(orderId: Long def getOrderById(orderId: Long): Request[Either[ResponseException[String, Exception], Order]] =
): Request[Either[ResponseException[String, Exception], Order]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/store/order/${orderId}") .method(Method.GET, uri"$baseUrl/store/order/${orderId}")
.contentType("application/json") .contentType("application/json")
@ -82,8 +78,7 @@ class StoreApi(baseUrl: String) {
* *
* @param order order placed for purchasing the pet * @param order order placed for purchasing the pet
*/ */
def placeOrder(order: Order def placeOrder(order: Order): Request[Either[ResponseException[String, Exception], Order]] =
): Request[Either[ResponseException[String, Exception], Order]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/store/order") .method(Method.POST, uri"$baseUrl/store/order")
.contentType("application/json") .contentType("application/json")

View File

@ -18,8 +18,7 @@ import sttp.client4._
import sttp.model.Method import sttp.model.Method
object UserApi { 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) { class UserApi(baseUrl: String) {
@ -35,8 +34,7 @@ class UserApi(baseUrl: String) {
* *
* @param user Created user object * @param user Created user object
*/ */
def createUser(apiKey: String)(user: User def createUser(apiKey: String)(user: User): Request[Either[Either[String, String], Unit]] =
): Request[Either[Either[String, String], Unit]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/user") .method(Method.POST, uri"$baseUrl/user")
.contentType("application/json") .contentType("application/json")
@ -55,8 +53,7 @@ class UserApi(baseUrl: String) {
* *
* @param user List of user object * @param user List of user object
*/ */
def createUsersWithArrayInput(apiKey: String)(user: Seq[User] def createUsersWithArrayInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] =
): Request[Either[Either[String, String], Unit]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/user/createWithArray") .method(Method.POST, uri"$baseUrl/user/createWithArray")
.contentType("application/json") .contentType("application/json")
@ -75,8 +72,7 @@ class UserApi(baseUrl: String) {
* *
* @param user List of user object * @param user List of user object
*/ */
def createUsersWithListInput(apiKey: String)(user: Seq[User] def createUsersWithListInput(apiKey: String)(user: Seq[User]): Request[Either[Either[String, String], Unit]] =
): Request[Either[Either[String, String], Unit]] =
basicRequest basicRequest
.method(Method.POST, uri"$baseUrl/user/createWithList") .method(Method.POST, uri"$baseUrl/user/createWithList")
.contentType("application/json") .contentType("application/json")
@ -96,8 +92,7 @@ class UserApi(baseUrl: String) {
* *
* @param username The name that needs to be deleted * @param username The name that needs to be deleted
*/ */
def deleteUser(apiKey: String)(username: String def deleteUser(apiKey: String)(username: String): Request[Either[ResponseException[String, Exception], Unit]] =
): Request[Either[ResponseException[String, Exception], Unit]] =
basicRequest basicRequest
.method(Method.DELETE, uri"$baseUrl/user/${username}") .method(Method.DELETE, uri"$baseUrl/user/${username}")
.contentType("application/json") .contentType("application/json")
@ -114,8 +109,7 @@ class UserApi(baseUrl: String) {
* *
* @param username The name that needs to be fetched. Use user1 for testing. * @param username The name that needs to be fetched. Use user1 for testing.
*/ */
def getUserByName(username: String def getUserByName(username: String): Request[Either[ResponseException[String, Exception], User]] =
): Request[Either[ResponseException[String, Exception], User]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/user/${username}") .method(Method.GET, uri"$baseUrl/user/${username}")
.contentType("application/json") .contentType("application/json")
@ -135,8 +129,7 @@ class UserApi(baseUrl: String) {
* @param username The user name for login * @param username The user name for login
* @param password The password for login in clear text * @param password The password for login in clear text
*/ */
def loginUser(username: String, password: String def loginUser(username: String, password: String): Request[Either[ResponseException[String, Exception], String]] =
): Request[Either[ResponseException[String, Exception], String]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/user/login?username=${ username }&password=${ password }") .method(Method.GET, uri"$baseUrl/user/login?username=${ username }&password=${ password }")
.contentType("application/json") .contentType("application/json")
@ -151,8 +144,7 @@ class UserApi(baseUrl: String) {
* Available security schemes: * Available security schemes:
* api_key (apiKey) * api_key (apiKey)
*/ */
def logoutUser(apiKey: String)( def logoutUser(apiKey: String)(): Request[Either[Either[String, String], Unit]] =
): Request[Either[Either[String, String], Unit]] =
basicRequest basicRequest
.method(Method.GET, uri"$baseUrl/user/logout") .method(Method.GET, uri"$baseUrl/user/logout")
.contentType("application/json") .contentType("application/json")
@ -172,8 +164,7 @@ class UserApi(baseUrl: String) {
* @param username name that need to be deleted * @param username name that need to be deleted
* @param user Updated user object * @param user Updated user object
*/ */
def updateUser(apiKey: String)(username: String, user: User def updateUser(apiKey: String)(username: String, user: User): Request[Either[ResponseException[String, Exception], Unit]] =
): Request[Either[ResponseException[String, Exception], Unit]] =
basicRequest basicRequest
.method(Method.PUT, uri"$baseUrl/user/${username}") .method(Method.PUT, uri"$baseUrl/user/${username}")
.contentType("application/json") .contentType("application/json")

View File

@ -13,12 +13,12 @@ package org.openapitools.client.model
/** /**
* An uploaded response * An uploaded response
* Describes the result of uploading an image resource * Describes the result of uploading an image resource
*/ */
case class ApiResponse( case class ApiResponse(
code: Option[Int] = None, code: Option[Int] = None,
`type`: Option[String] = None, `type`: Option[String] = None,
message: Option[String] = None message: Option[String] = None
) )

View File

@ -13,11 +13,11 @@ package org.openapitools.client.model
/** /**
* Pet category * Pet category
* A category for a pet * A category for a pet
*/ */
case class Category( case class Category(
id: Option[Long] = None, id: Option[Long] = None,
name: Option[String] = None name: Option[String] = None
) )

View File

@ -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")
}
}

View File

@ -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")
}
}

View File

@ -13,11 +13,11 @@ package org.openapitools.client.model
/** /**
* Pet Tag * Pet Tag
* A tag for a pet * A tag for a pet
*/ */
case class Tag( case class Tag(
id: Option[Long] = None, id: Option[Long] = None,
name: Option[String] = None name: Option[String] = None
) )

View File

@ -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
)

View File

@ -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")
}
}

View File

@ -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")
}
}

View File

@ -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
)