forked from loafle/openapi-generator-original
[Kotlin][Client] Fix url path for Retrofit, Fix optionals for @Query @Body, Set List as default collection for Kotlin data class (#6456)
* Replace typeMapping kotlin.Array with kotlin.collections.List, because its doesn't work with Kotlin Data Classes(required manually implementing hashCode&equals) Replace typeMapping kotlin.Array<kotlin.Byte> with efficient primitive implementation kotlin.ByteArray Replace instantiationTypes array to kotlin.collections.ArrayList, for extending Array we should provide element count to its constructor. * Fixed path(removed slash on begin path) for Jvm Kotlin Retrofit * Fixed handling optional bodyParams for Jvm Kotlin Retrofit * Fix kotlin tests * Fixed code format for detekt inspections #2 * revert formatting * Added ability to generate optional @Query params. * Update Kotlin docs. * Update Kotlin openapi3 client samples * Update Kotlin client samples * Update Kotlin openapi3 client samples after merge with master * Revert hardcoding List instead Array * Set List as default collectionType * Update Kotlin samples * Fixed Kotlin multiplatform api template. fix mapper for Array type. Fixed Kotlin multiplatform api template Code style. * Update Kotlin multiplatform sample * Fix Kotlin multiplatform template code style * Update Kotlin multiplatform sample * Fix Kotlin multiplatform converting Array to List in Api. * Update Kotlin multiplatform sample #3 * Fix Kotlin tests * Fix Kotlin jackson Application.kt * Fix Kotlin tests #2 * Fix merge conflict with master * Generate samples after merge with master * Generate samples after merge with master #2 * Generate samples after merge with master #3 * Generate samples after merge with master #4 * update kotlin samples * update all samples Co-authored-by: William Cheng <wing328hk@gmail.com>
This commit is contained in:
@@ -119,7 +119,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
* Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
* @param tags Tags to filter by
|
||||
* @return kotlin.Array<Pet>
|
||||
* @return kotlin.collections.List<Pet>
|
||||
* @throws UnsupportedOperationException If the API returns an informational or redirection response
|
||||
* @throws ClientException If the API returns a client error response
|
||||
* @throws ServerException If the API returns a server error response
|
||||
@@ -127,7 +127,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
|
||||
@Deprecated(message = "This operation is deprecated.")
|
||||
fun findPetsByTags(tags: kotlin.Array<kotlin.String>) : kotlin.Array<Pet> {
|
||||
fun findPetsByTags(tags: kotlin.collections.List<kotlin.String>) : kotlin.collections.List<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
@@ -140,13 +140,13 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders
|
||||
)
|
||||
val localVarResponse = request<kotlin.Array<Pet>>(
|
||||
val localVarResponse = request<kotlin.collections.List<Pet>>(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array<Pet>
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List<Pet>
|
||||
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||
ResponseType.ClientError -> {
|
||||
@@ -164,14 +164,14 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
* Get all pets
|
||||
*
|
||||
* @param lastUpdated When this endpoint was hit last to help indentify if the client already has the latest copy. (optional)
|
||||
* @return kotlin.Array<Pet>
|
||||
* @return kotlin.collections.List<Pet>
|
||||
* @throws UnsupportedOperationException If the API returns an informational or redirection response
|
||||
* @throws ClientException If the API returns a client error response
|
||||
* @throws ServerException If the API returns a server error response
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
|
||||
fun getAllPets(lastUpdated: java.time.OffsetDateTime?) : kotlin.Array<Pet> {
|
||||
fun getAllPets(lastUpdated: java.time.OffsetDateTime?) : kotlin.collections.List<Pet> {
|
||||
val localVariableBody: kotlin.Any? = null
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, List<kotlin.String>>()
|
||||
.apply {
|
||||
@@ -186,13 +186,13 @@ class PetApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders
|
||||
)
|
||||
val localVarResponse = request<kotlin.Array<Pet>>(
|
||||
val localVarResponse = request<kotlin.collections.List<Pet>>(
|
||||
localVariableConfig,
|
||||
localVariableBody
|
||||
)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.Array<Pet>
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as kotlin.collections.List<Pet>
|
||||
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||
ResponseType.ClientError -> {
|
||||
|
||||
@@ -83,7 +83,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
* @throws ServerException If the API returns a server error response
|
||||
*/
|
||||
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
|
||||
fun createUsersWithArrayInput(body: kotlin.Array<User>) : Unit {
|
||||
fun createUsersWithArrayInput(body: kotlin.collections.List<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
@@ -123,7 +123,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath) : ApiClient(basePath) {
|
||||
* @throws ServerException If the API returns a server error response
|
||||
*/
|
||||
@Throws(UnsupportedOperationException::class, ClientException::class, ServerException::class)
|
||||
fun createUsersWithListInput(body: kotlin.Array<User>) : Unit {
|
||||
fun createUsersWithListInput(body: kotlin.collections.List<User>) : Unit {
|
||||
val localVariableBody: kotlin.Any? = body
|
||||
val localVariableQuery: MultiValueMap = mutableMapOf()
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* Describes the result of uploading an image resource
|
||||
* @param code
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* A category for a pet
|
||||
* @param id
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* An order for a pets from the pet store
|
||||
* @param id
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.openapitools.client.models.Category
|
||||
import org.openapitools.client.models.Tag
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* A pet for sale in the pet store
|
||||
* @param name
|
||||
@@ -29,13 +30,13 @@ data class Pet (
|
||||
@Json(name = "name")
|
||||
val name: kotlin.String,
|
||||
@Json(name = "photoUrls")
|
||||
val photoUrls: kotlin.Array<kotlin.String>,
|
||||
val photoUrls: kotlin.collections.List<kotlin.String>,
|
||||
@Json(name = "id")
|
||||
val id: kotlin.Long? = null,
|
||||
@Json(name = "category")
|
||||
val category: Category? = null,
|
||||
@Json(name = "tags")
|
||||
val tags: kotlin.Array<Tag>? = null,
|
||||
val tags: kotlin.collections.List<Tag>? = null,
|
||||
/* pet status in the store */
|
||||
@Json(name = "status")
|
||||
val status: Pet.Status? = null
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* A tag for a pet
|
||||
* @param id
|
||||
|
||||
@@ -13,6 +13,7 @@ package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
/**
|
||||
* A User who is purchasing from the pet store
|
||||
* @param id
|
||||
|
||||
Reference in New Issue
Block a user