Nikita Karnaukh eefcd62d5b
[Kotlin][Client] Added supporting Retrofit2(RxJava/RxJava2/Coroutines) (#5750)
* Added support Retrofit2(RxJava/RxJava2/Coroutines) to Kotlin client code generator

* Added generated samples for Retrofit2(RxJava/RxJava2/Coroutines) on Kotlin

* Fixed generating retrofit2 without Rx/Coroutines

* Fixed MultipartBody template, remove redundant space after MultipartBody.Part annotation

* Fix documentation diff.

* Fix generating build.gradle file for samples.
Add dependencies for rxJava/rxJava2 and rx retrofit's adapter.

* Update generated sample with rx dependencies

* Update generated sample with coroutines

* Update generated sample with RxJava 2 dependencies

* Update and refactoring scripts for sample generation

* Update generated sample code

* revert changes by mistake

* revert changes by mistake #2

* Fix return type for first RxJava

* Add RxJavaCallAdapterFactory to ApiClient scheme for RxJava 1/2

* Fix script loggin

* Update generated code for RxJava 1/2

* Fix kotlin.md documentation by script export_docs_generators.sh

* Update Kotlin samples project in pom.xml

* Revert "Update Kotlin samples project in pom.xml"

This reverts commit 9de4d0ba

* Fixed "" wrapping number types for annotation value
Fixed generating polymorphic interfaces for Gson, interface fields can't be marked with @SerializedName annotation, it's enough to mark it in child model.
Fixed instantiationTypes(array, list, map) for Kotlin generator

* Update Kotlin samples project after last fixes

* Update Kotlin samples project for kotlin-jvm-*

* Update Kotlin readme.md documentations

* Update Kotlin client sample changes

* Fixed encoding braces for generics model

* Update Kotlin client sample changes

* Update Kotlin client sample after merge with master

* Fixed adding empty braces for inherit from Map/Array

* Update sample model after last fix with empty braces

* Revert adding @SerializedName to Kotlin interface fields through @get:SerializedName as for Jackson

* Update Kotlin client samples with adding @get:SerializedName
2020-05-18 16:26:27 +08:00

12 KiB

PetApi

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

Method HTTP request Description
addPet POST /pet Add a new pet to the store
deletePet DELETE /pet/{petId} Deletes a pet
findPetsByStatus GET /pet/findByStatus Finds Pets by status
findPetsByTags GET /pet/findByTags Finds Pets by tags
getPetById GET /pet/{petId} Find pet by ID
updatePet PUT /pet Update an existing pet
updatePetWithForm POST /pet/{petId} Updates a pet in the store with form data
uploadFile POST /pet/{petId}/uploadImage uploads an image
uploadFileWithRequiredFile POST /fake/{petId}/uploadImageWithRequiredFile uploads an image (required)

addPet

addPet(pet)

Add a new pet to the store

Example

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

val apiInstance = PetApi()
val pet : Pet =  // Pet | Pet object that needs to be added to the store
try {
    apiInstance.addPet(pet)
} catch (e: ClientException) {
    println("4xx response calling PetApi#addPet")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#addPet")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
pet Pet Pet object that needs to be added to the store

Return type

null (empty response body)

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

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

deletePet

deletePet(petId, apiKey)

Deletes a pet

Example

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

val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | Pet id to delete
val apiKey : kotlin.String = apiKey_example // kotlin.String | 
try {
    apiInstance.deletePet(petId, apiKey)
} catch (e: ClientException) {
    println("4xx response calling PetApi#deletePet")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#deletePet")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
petId kotlin.Long Pet id to delete
apiKey kotlin.String [optional]

Return type

null (empty response body)

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

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

findPetsByStatus

kotlin.Array<Pet> findPetsByStatus(status)

Finds Pets by status

Multiple status values can be provided with comma separated strings

Example

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

val apiInstance = PetApi()
val status : kotlin.Array<kotlin.String> =  // kotlin.Array<kotlin.String> | Status values that need to be considered for filter
try {
    val result : kotlin.Array<Pet> = apiInstance.findPetsByStatus(status)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling PetApi#findPetsByStatus")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#findPetsByStatus")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
status kotlin.Array<kotlin.String> Status values that need to be considered for filter [enum: available, pending, sold]

Return type

kotlin.Array<Pet>

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

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

findPetsByTags

kotlin.Array<Pet> findPetsByTags(tags)

Finds Pets by tags

Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.

Example

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

val apiInstance = PetApi()
val tags : kotlin.Array<kotlin.String> =  // kotlin.Array<kotlin.String> | Tags to filter by
try {
    val result : kotlin.Array<Pet> = apiInstance.findPetsByTags(tags)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling PetApi#findPetsByTags")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#findPetsByTags")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
tags kotlin.Array<kotlin.String> Tags to filter by

Return type

kotlin.Array<Pet>

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

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

getPetById

Pet getPetById(petId)

Find pet by ID

Returns a single pet

Example

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

val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to return
try {
    val result : Pet = apiInstance.getPetById(petId)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling PetApi#getPetById")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#getPetById")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
petId kotlin.Long ID of pet to return

Return type

Pet

Authorization

Configure api_key: ApiClient.apiKey["api_key"] = "" ApiClient.apiKeyPrefix["api_key"] = ""

HTTP request headers

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

updatePet

updatePet(pet)

Update an existing pet

Example

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

val apiInstance = PetApi()
val pet : Pet =  // Pet | Pet object that needs to be added to the store
try {
    apiInstance.updatePet(pet)
} catch (e: ClientException) {
    println("4xx response calling PetApi#updatePet")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#updatePet")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
pet Pet Pet object that needs to be added to the store

Return type

null (empty response body)

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

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

updatePetWithForm

updatePetWithForm(petId, name, status)

Updates a pet in the store with form data

Example

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

val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet that needs to be updated
val name : kotlin.String = name_example // kotlin.String | Updated name of the pet
val status : kotlin.String = status_example // kotlin.String | Updated status of the pet
try {
    apiInstance.updatePetWithForm(petId, name, status)
} catch (e: ClientException) {
    println("4xx response calling PetApi#updatePetWithForm")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#updatePetWithForm")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
petId kotlin.Long ID of pet that needs to be updated
name kotlin.String Updated name of the pet [optional]
status kotlin.String Updated status of the pet [optional]

Return type

null (empty response body)

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: Not defined

uploadFile

ApiResponse uploadFile(petId, additionalMetadata, file)

uploads an image

Example

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

val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
val file : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
try {
    val result : ApiResponse = apiInstance.uploadFile(petId, additionalMetadata, file)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling PetApi#uploadFile")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#uploadFile")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
petId kotlin.Long ID of pet to update
additionalMetadata kotlin.String Additional data to pass to server [optional]
file java.io.File file to upload [optional]

Return type

ApiResponse

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json

uploadFileWithRequiredFile

ApiResponse uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)

uploads an image (required)

Example

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

val apiInstance = PetApi()
val petId : kotlin.Long = 789 // kotlin.Long | ID of pet to update
val requiredFile : java.io.File = BINARY_DATA_HERE // java.io.File | file to upload
val additionalMetadata : kotlin.String = additionalMetadata_example // kotlin.String | Additional data to pass to server
try {
    val result : ApiResponse = apiInstance.uploadFileWithRequiredFile(petId, requiredFile, additionalMetadata)
    println(result)
} catch (e: ClientException) {
    println("4xx response calling PetApi#uploadFileWithRequiredFile")
    e.printStackTrace()
} catch (e: ServerException) {
    println("5xx response calling PetApi#uploadFileWithRequiredFile")
    e.printStackTrace()
}

Parameters

Name Type Description Notes
petId kotlin.Long ID of pet to update
requiredFile java.io.File file to upload
additionalMetadata kotlin.String Additional data to pass to server [optional]

Return type

ApiResponse

Authorization

Configure petstore_auth: ApiClient.accessToken = ""

HTTP request headers

  • Content-Type: multipart/form-data
  • Accept: application/json