Nikita Karnaukh d657e95021 [Kotlin][Client] Added Kotlinx Serialization for JVM/Retrofit2/OkHttp3&4 (#6916)
* Added supporting kotlin.serialization for jvm

* Added Serializable annotations for java types(date,time,url,uri etc.)

* Added SafeEnumSerializer

* Added StringBuilderAdapter for kotlin.serialization
Fix adapter naming
Fix Retrofit ApiClient.kt for kotlin.serialization

* Added StringBuilderAdapter for kotlin.serialization

* Switch sample to retrofit2-kotlin-serialization

* Add sample for retrofit2-kotlin.serialization

* update sample

* update sample

* update sample #3

* Fix enum quotes for kotlin.serialization

* update samples

* update pom.xml

* add pom.xml to child module

* fix kotlin-multiplatform freeCompilerArgs

* refactoring, add useSafeEnum option, remove safeEnum for kotlin.multiplatform

* update kotlin samples

* fix import kotlinx.serialization.Required

* Update kotlinx.serialization 1.0.0-rc-2, kotlin 1.4.10, retrofit-kotlinx-converter 0.7.0

* Update gradle wrapper 6.7-rc-3

* fix SafeEnum import

* fix Json initialization,
fix SafeEnumSerializer

* update samples

* update kotlinx.serialization to 1.0.0

* Update gradle to 6.7 in kotlin samples

* fixed adding @Contextual for collections with non-primitive type elements

* remove unused SafeEnum imports, refactored

* update kotlin readme

* update kotlin project template Readme.md

* update samples for kotlin

* simplify template for class properties

* remove @Contextual from kotlin-multiplatform

* update kotlin multiplatform dependencies

* refactoring templates

* revert all changes for multiplatform

* fix tests

* revert multiplatform #2

* update samples after merge, fix missed isListContainer->isArray

* fixed redundant space before @Contextual

* Fixed enum template, Class were missed in generated samples

* fix enum template toString value->serialName

* fixed isEnum case for collections

* update samples

* removed useSafeEnum option, kotlinx serialization has out of box approach with coerceInputValues option for same behavior

* generate samples

* update kotlinx.serialization 1.0.1

* update samples

* Added pom.mustache template for kotlin-client samples with fixed execution of gradle wrapper instead standalone installed gradle on CI

* update samples with new pom.xml

* reverted enum value property name

* fixed kotlin-multiplatform pom.xml

* update kotlin-threetenbp sample

* update kotlin-string sample

* update kotlin-string sample

* fix adding kotlinx.serialization classpath to build.gradle

* generate samples

* add supporting kotlinx_serialization kotlinx.serialization.Serializable with java.io.Serializable at the same time

* update retrofit2-kotlinx-serialization-converter:0.8.0

* update kotlinx_serialization sample with retrofit2-kotlinx-serialization-converter:0.8.0

* apply suggest from @blendthink

* added proguard-rules.pro file for kotlinx.serialization on Android projects

* fix pom.mustache

* update gradle wrapper to 6.8.3

* update kotlin samples

* fix kotlin readme template, update kotlin samples

* update kotlin samples

* update kotlin sample
delete petstore/kotlin unit tests

* revert deletion kotlin client tests
remove adding pom.xml to kotlin client samples

* add support kotlinx serialization for okhttp3/4

* update kotlin client samples
2021-03-19 18:12:23 +08:00

7.4 KiB

UserApi

All URIs are relative to http://petstore.swagger.io/v2

Method HTTP request Description
createUser POST user Create user
createUsersWithArrayInput POST user/createWithArray Creates list of users with given input array
createUsersWithListInput POST user/createWithList Creates list of users with given input array
deleteUser DELETE user/{username} Delete user
getUserByName GET user/{username} Get user by user name
loginUser GET user/login Logs user into the system
logoutUser GET user/logout Logs out current logged in user session
updateUser PUT user/{username} Updated user

Create user

This can only be done by the logged in user.

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : User =  // User | Created user object

webService.createUser(body)

Parameters

Name Type Description Notes
body User Created user object

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

Creates list of users with given input array

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : kotlin.collections.List<User> =  // kotlin.collections.List<User> | List of user object

webService.createUsersWithArrayInput(body)

Parameters

Name Type Description Notes
body kotlin.collections.List<User> List of user object

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

Creates list of users with given input array

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val body : kotlin.collections.List<User> =  // kotlin.collections.List<User> | List of user object

webService.createUsersWithListInput(body)

Parameters

Name Type Description Notes
body kotlin.collections.List<User> List of user object

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

Delete user

This can only be done by the logged in user.

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be deleted

webService.deleteUser(username)

Parameters

Name Type Description Notes
username kotlin.String The name that needs to be deleted

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

Get user by user name

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The name that needs to be fetched. Use user1 for testing.

val result : User = webService.getUserByName(username)

Parameters

Name Type Description Notes
username kotlin.String The name that needs to be fetched. Use user1 for testing.

Return type

User

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

Logs user into the system

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | The user name for login
val password : kotlin.String = password_example // kotlin.String | The password for login in clear text

val result : kotlin.String = webService.loginUser(username, password)

Parameters

Name Type Description Notes
username kotlin.String The user name for login
password kotlin.String The password for login in clear text

Return type

kotlin.String

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/xml, application/json

Logs out current logged in user session

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)

webService.logoutUser()

Parameters

This endpoint does not need any parameter.

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined

Updated user

This can only be done by the logged in user.

Example

// Import classes:
//import org.openapitools.client.*
//import org.openapitools.client.infrastructure.*
//import org.openapitools.client.models.*

val apiClient = ApiClient()
val webService = apiClient.createWebservice(UserApi::class.java)
val username : kotlin.String = username_example // kotlin.String | name that need to be deleted
val body : User =  // User | Updated user object

webService.updateUser(username, body)

Parameters

Name Type Description Notes
username kotlin.String name that need to be deleted
body User Updated user object

Return type

null (empty response body)

Authorization

No authorization required

HTTP request headers

  • Content-Type: Not defined
  • Accept: Not defined