Merge remote-tracking branch 'origin/6.3.x' into 7.0.x

This commit is contained in:
William Cheng
2022-10-16 21:27:53 +08:00
11745 changed files with 669618 additions and 201259 deletions

View File

@@ -1,5 +1,14 @@
# org.openapitools.client - Kotlin client library for Demo
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
## Overview
This API client was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://github.com/OAI/OpenAPI-Specification) from a remote server, you can easily generate an API client.
- API version: 1.0.0
- Package version:
- Build package: org.openapitools.codegen.languages.KotlinClientCodegen
## Requires
* Kotlin 1.4.30

View File

@@ -2,12 +2,12 @@ group 'org.openapitools'
version '1.0.0'
wrapper {
gradleVersion = '6.8.3'
gradleVersion = '7.5'
distributionUrl = "https://services.gradle.org/distributions/gradle-$gradleVersion-all.zip"
}
buildscript {
ext.kotlin_version = '1.5.10'
ext.kotlin_version = '1.6.10'
repositories {
maven { url "https://repo1.maven.org/maven2" }
@@ -30,8 +30,8 @@ test {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation "com.squareup.moshi:moshi-kotlin:1.12.0"
implementation "com.squareup.moshi:moshi-adapters:1.12.0"
implementation "com.squareup.okhttp3:okhttp:4.9.1"
implementation "com.squareup.moshi:moshi-kotlin:1.13.0"
implementation "com.squareup.moshi:moshi-adapters:1.13.0"
implementation "com.squareup.okhttp3:okhttp:4.10.0"
testImplementation "io.kotlintest:kotlintest-runner-junit5:3.4.2"
}

View File

@@ -9,7 +9,7 @@ Method | HTTP request | Description
<a name="test"></a>
# **test**
> test(pi0, pi1, pn0, pn1, qi0, qi1, qi2, qi3, qn0, qn1, qn2, qn3, hi0, hi1, hi2, hi3, hn0, hn1, hn2, hn3, fi0, fi1, fi2, fi3, fn0, fn1, fn2, fn3)
> test(pi0, pi1, pn0, pn1, qi0, qi1, qi2, qi3, qn0, qn1, qn2, qn3, hi0, hi1, hi2, hi3, hn0, hn1, hn2, hn3, fi0, fi1, fi2, fi3, fn0, fn1, fn2, fn3, fn4)
Tests default values
@@ -50,8 +50,9 @@ val fn0 : java.math.BigDecimal = 8.14 // java.math.BigDecimal |
val fn1 : java.math.BigDecimal = 8.14 // java.math.BigDecimal |
val fn2 : java.math.BigDecimal = 8.14 // java.math.BigDecimal |
val fn3 : java.math.BigDecimal = 8.14 // java.math.BigDecimal |
val fn4 : kotlin.collections.List<kotlin.String> = // kotlin.collections.List<kotlin.String> |
try {
apiInstance.test(pi0, pi1, pn0, pn1, qi0, qi1, qi2, qi3, qn0, qn1, qn2, qn3, hi0, hi1, hi2, hi3, hn0, hn1, hn2, hn3, fi0, fi1, fi2, fi3, fn0, fn1, fn2, fn3)
apiInstance.test(pi0, pi1, pn0, pn1, qi0, qi1, qi2, qi3, qn0, qn1, qn2, qn3, hi0, hi1, hi2, hi3, hn0, hn1, hn2, hn3, fi0, fi1, fi2, fi3, fn0, fn1, fn2, fn3, fn4)
} catch (e: ClientException) {
println("4xx response calling DefaultApi#test")
e.printStackTrace()
@@ -93,6 +94,7 @@ Name | Type | Description | Notes
**fn1** | **java.math.BigDecimal**| | [default to 71.0]
**fn2** | **java.math.BigDecimal**| | [optional]
**fn3** | **java.math.BigDecimal**| |
**fn4** | [**kotlin.collections.List&lt;kotlin.String&gt;**](kotlin.String.md)| |
### Return type

View File

@@ -1,14 +1,9 @@
/**
* Demo
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(
@@ -22,6 +17,7 @@ package org.openapitools.client.apis
import java.io.IOException
import okhttp3.OkHttpClient
import okhttp3.HttpUrl
import com.squareup.moshi.Json
@@ -79,6 +75,7 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
* @param fn1 (default to 71.0)
* @param fn2 (optional)
* @param fn3
* @param fn4
* @return void
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
@@ -87,8 +84,8 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
* @throws ServerException If the API returns a server error response
*/
@Throws(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
fun test(pi0: kotlin.Int = 10, pi1: kotlin.Int, pn0: java.math.BigDecimal = java.math.BigDecimal("10.0"), pn1: java.math.BigDecimal, qi0: kotlin.Int? = 10, qi1: kotlin.Int = 71, qi2: kotlin.Int? = null, qi3: kotlin.Int, qn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), qn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), qn2: java.math.BigDecimal? = null, qn3: java.math.BigDecimal, hi0: kotlin.Int? = 10, hi1: kotlin.Int = 71, hi2: kotlin.Int? = null, hi3: kotlin.Int, hn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), hn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), hn2: java.math.BigDecimal? = null, hn3: java.math.BigDecimal, fi0: kotlin.Int? = 10, fi1: kotlin.Int = 71, fi2: kotlin.Int? = null, fi3: kotlin.Int, fn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), fn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), fn2: java.math.BigDecimal? = null, fn3: java.math.BigDecimal) : Unit {
val localVarResponse = testWithHttpInfo(pi0 = pi0, pi1 = pi1, pn0 = pn0, pn1 = pn1, qi0 = qi0, qi1 = qi1, qi2 = qi2, qi3 = qi3, qn0 = qn0, qn1 = qn1, qn2 = qn2, qn3 = qn3, hi0 = hi0, hi1 = hi1, hi2 = hi2, hi3 = hi3, hn0 = hn0, hn1 = hn1, hn2 = hn2, hn3 = hn3, fi0 = fi0, fi1 = fi1, fi2 = fi2, fi3 = fi3, fn0 = fn0, fn1 = fn1, fn2 = fn2, fn3 = fn3)
fun test(pi0: kotlin.Int = 10, pi1: kotlin.Int, pn0: java.math.BigDecimal = java.math.BigDecimal("10.0"), pn1: java.math.BigDecimal, qi0: kotlin.Int? = 10, qi1: kotlin.Int = 71, qi2: kotlin.Int? = null, qi3: kotlin.Int, qn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), qn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), qn2: java.math.BigDecimal? = null, qn3: java.math.BigDecimal, hi0: kotlin.Int? = 10, hi1: kotlin.Int = 71, hi2: kotlin.Int? = null, hi3: kotlin.Int, hn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), hn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), hn2: java.math.BigDecimal? = null, hn3: java.math.BigDecimal, fi0: kotlin.Int? = 10, fi1: kotlin.Int = 71, fi2: kotlin.Int? = null, fi3: kotlin.Int, fn0: java.math.BigDecimal? = java.math.BigDecimal("10.0"), fn1: java.math.BigDecimal = java.math.BigDecimal("71.0"), fn2: java.math.BigDecimal? = null, fn3: java.math.BigDecimal, fn4: kotlin.collections.List<kotlin.String>) : Unit {
val localVarResponse = testWithHttpInfo(pi0 = pi0, pi1 = pi1, pn0 = pn0, pn1 = pn1, qi0 = qi0, qi1 = qi1, qi2 = qi2, qi3 = qi3, qn0 = qn0, qn1 = qn1, qn2 = qn2, qn3 = qn3, hi0 = hi0, hi1 = hi1, hi2 = hi2, hi3 = hi3, hn0 = hn0, hn1 = hn1, hn2 = hn2, hn3 = hn3, fi0 = fi0, fi1 = fi1, fi2 = fi2, fi3 = fi3, fn0 = fn0, fn1 = fn1, fn2 = fn2, fn3 = fn3, fn4 = fn4)
return when (localVarResponse.responseType) {
ResponseType.Success -> Unit
@@ -136,13 +133,14 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
* @param fn1 (default to 71.0)
* @param fn2 (optional)
* @param fn3
* @param fn4
* @return ApiResponse<Unit?>
* @throws IllegalStateException If the request is not correctly configured
* @throws IOException Rethrows the OkHttp execute method exception
*/
@Throws(IllegalStateException::class, IOException::class)
fun testWithHttpInfo(pi0: kotlin.Int, pi1: kotlin.Int, pn0: java.math.BigDecimal, pn1: java.math.BigDecimal, qi0: kotlin.Int?, qi1: kotlin.Int, qi2: kotlin.Int?, qi3: kotlin.Int, qn0: java.math.BigDecimal?, qn1: java.math.BigDecimal, qn2: java.math.BigDecimal?, qn3: java.math.BigDecimal, hi0: kotlin.Int?, hi1: kotlin.Int, hi2: kotlin.Int?, hi3: kotlin.Int, hn0: java.math.BigDecimal?, hn1: java.math.BigDecimal, hn2: java.math.BigDecimal?, hn3: java.math.BigDecimal, fi0: kotlin.Int?, fi1: kotlin.Int, fi2: kotlin.Int?, fi3: kotlin.Int, fn0: java.math.BigDecimal?, fn1: java.math.BigDecimal, fn2: java.math.BigDecimal?, fn3: java.math.BigDecimal) : ApiResponse<Unit?> {
val localVariableConfig = testRequestConfig(pi0 = pi0, pi1 = pi1, pn0 = pn0, pn1 = pn1, qi0 = qi0, qi1 = qi1, qi2 = qi2, qi3 = qi3, qn0 = qn0, qn1 = qn1, qn2 = qn2, qn3 = qn3, hi0 = hi0, hi1 = hi1, hi2 = hi2, hi3 = hi3, hn0 = hn0, hn1 = hn1, hn2 = hn2, hn3 = hn3, fi0 = fi0, fi1 = fi1, fi2 = fi2, fi3 = fi3, fn0 = fn0, fn1 = fn1, fn2 = fn2, fn3 = fn3)
fun testWithHttpInfo(pi0: kotlin.Int, pi1: kotlin.Int, pn0: java.math.BigDecimal, pn1: java.math.BigDecimal, qi0: kotlin.Int?, qi1: kotlin.Int, qi2: kotlin.Int?, qi3: kotlin.Int, qn0: java.math.BigDecimal?, qn1: java.math.BigDecimal, qn2: java.math.BigDecimal?, qn3: java.math.BigDecimal, hi0: kotlin.Int?, hi1: kotlin.Int, hi2: kotlin.Int?, hi3: kotlin.Int, hn0: java.math.BigDecimal?, hn1: java.math.BigDecimal, hn2: java.math.BigDecimal?, hn3: java.math.BigDecimal, fi0: kotlin.Int?, fi1: kotlin.Int, fi2: kotlin.Int?, fi3: kotlin.Int, fn0: java.math.BigDecimal?, fn1: java.math.BigDecimal, fn2: java.math.BigDecimal?, fn3: java.math.BigDecimal, fn4: kotlin.collections.List<kotlin.String>) : ApiResponse<Unit?> {
val localVariableConfig = testRequestConfig(pi0 = pi0, pi1 = pi1, pn0 = pn0, pn1 = pn1, qi0 = qi0, qi1 = qi1, qi2 = qi2, qi3 = qi3, qn0 = qn0, qn1 = qn1, qn2 = qn2, qn3 = qn3, hi0 = hi0, hi1 = hi1, hi2 = hi2, hi3 = hi3, hn0 = hn0, hn1 = hn1, hn2 = hn2, hn3 = hn3, fi0 = fi0, fi1 = fi1, fi2 = fi2, fi3 = fi3, fn0 = fn0, fn1 = fn1, fn2 = fn2, fn3 = fn3, fn4 = fn4)
return request<Map<String, PartConfig<*>>, Unit>(
localVariableConfig
@@ -180,9 +178,10 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
* @param fn1 (default to 71.0)
* @param fn2 (optional)
* @param fn3
* @param fn4
* @return RequestConfig
*/
fun testRequestConfig(pi0: kotlin.Int, pi1: kotlin.Int, pn0: java.math.BigDecimal, pn1: java.math.BigDecimal, qi0: kotlin.Int?, qi1: kotlin.Int, qi2: kotlin.Int?, qi3: kotlin.Int, qn0: java.math.BigDecimal?, qn1: java.math.BigDecimal, qn2: java.math.BigDecimal?, qn3: java.math.BigDecimal, hi0: kotlin.Int?, hi1: kotlin.Int, hi2: kotlin.Int?, hi3: kotlin.Int, hn0: java.math.BigDecimal?, hn1: java.math.BigDecimal, hn2: java.math.BigDecimal?, hn3: java.math.BigDecimal, fi0: kotlin.Int?, fi1: kotlin.Int, fi2: kotlin.Int?, fi3: kotlin.Int, fn0: java.math.BigDecimal?, fn1: java.math.BigDecimal, fn2: java.math.BigDecimal?, fn3: java.math.BigDecimal) : RequestConfig<Map<String, PartConfig<*>>> {
fun testRequestConfig(pi0: kotlin.Int, pi1: kotlin.Int, pn0: java.math.BigDecimal, pn1: java.math.BigDecimal, qi0: kotlin.Int?, qi1: kotlin.Int, qi2: kotlin.Int?, qi3: kotlin.Int, qn0: java.math.BigDecimal?, qn1: java.math.BigDecimal, qn2: java.math.BigDecimal?, qn3: java.math.BigDecimal, hi0: kotlin.Int?, hi1: kotlin.Int, hi2: kotlin.Int?, hi3: kotlin.Int, hn0: java.math.BigDecimal?, hn1: java.math.BigDecimal, hn2: java.math.BigDecimal?, hn3: java.math.BigDecimal, fi0: kotlin.Int?, fi1: kotlin.Int, fi2: kotlin.Int?, fi3: kotlin.Int, fn0: java.math.BigDecimal?, fn1: java.math.BigDecimal, fn2: java.math.BigDecimal?, fn3: java.math.BigDecimal, fn4: kotlin.collections.List<kotlin.String>) : RequestConfig<Map<String, PartConfig<*>>> {
val localVariableBody = mapOf(
"fi0" to PartConfig(body = fi0, headers = mutableMapOf()),
"fi1" to PartConfig(body = fi1, headers = mutableMapOf()),
@@ -191,7 +190,8 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
"fn0" to PartConfig(body = fn0, headers = mutableMapOf()),
"fn1" to PartConfig(body = fn1, headers = mutableMapOf()),
"fn2" to PartConfig(body = fn2, headers = mutableMapOf()),
"fn3" to PartConfig(body = fn3, headers = mutableMapOf()),)
"fn3" to PartConfig(body = fn3, headers = mutableMapOf()),
"fn4" to PartConfig(body = fn4, headers = mutableMapOf()),)
val localVariableQuery: MultiValueMap = mutableMapOf<kotlin.String, kotlin.collections.List<kotlin.String>>()
.apply {
if (qi0 != null) {
@@ -223,11 +223,14 @@ class DefaultApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient
return RequestConfig(
method = RequestMethod.POST,
path = "/test".replace("{"+"pi0"+"}", pi0.toString()).replace("{"+"pi1"+"}", pi1.toString()).replace("{"+"pn0"+"}", pn0.toString()).replace("{"+"pn1"+"}", pn1.toString()),
path = "/test".replace("{"+"pi0"+"}", encodeURIComponent(pi0.toString())).replace("{"+"pi1"+"}", encodeURIComponent(pi1.toString())).replace("{"+"pn0"+"}", encodeURIComponent(pn0.toString())).replace("{"+"pn1"+"}", encodeURIComponent(pn1.toString())),
query = localVariableQuery,
headers = localVariableHeaders,
body = localVariableBody
)
}
private fun encodeURIComponent(uriComponent: kotlin.String): kotlin.String =
HttpUrl.Builder().scheme("http").host("localhost").addPathSegment(uriComponent).build().encodedPathSegments[0]
}

View File

@@ -68,6 +68,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
protected inline fun <reified T> requestBody(content: T, mediaType: String?): RequestBody =
when {
content is File -> content.asRequestBody((mediaType ?: guessContentTypeFromFile(content)).toMediaTypeOrNull())
mediaType == FormDataMediaType ->
MultipartBody.Builder()
.setType(MultipartBody.FORM)
@@ -75,22 +76,24 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
// content's type *must* be Map<String, PartConfig<*>>
@Suppress("UNCHECKED_CAST")
(content as Map<String, PartConfig<*>>).forEach { (name, part) ->
val contentType = part.headers.remove("Content-Type")
val bodies = if (part.body is Iterable<*>) part.body else listOf(part.body)
bodies.forEach { body ->
val headers = part.headers.toMutableMap() +
("Content-Disposition" to "form-data; name=\"$name\"" + if (body is File) "; filename=\"${body.name}\"" else "")
addPart(headers.toHeaders(),
requestSingleBody(body, contentType))
if (part.body is File) {
val partHeaders = part.headers.toMutableMap() +
("Content-Disposition" to "form-data; name=\"$name\"; filename=\"${part.body.name}\"")
val fileMediaType = guessContentTypeFromFile(part.body).toMediaTypeOrNull()
addPart(
partHeaders.toHeaders(),
part.body.asRequestBody(fileMediaType)
)
} else {
val partHeaders = part.headers.toMutableMap() +
("Content-Disposition" to "form-data; name=\"$name\"")
addPart(
partHeaders.toHeaders(),
parameterToString(part.body).toRequestBody(null)
)
}
}
}.build()
else -> requestSingleBody(content, mediaType)
}
protected inline fun <reified T> requestSingleBody(content: T, mediaType: String?): RequestBody =
when {
content is File -> content.asRequestBody((mediaType ?: guessContentTypeFromFile(content)).toMediaTypeOrNull())
mediaType == FormUrlEncMediaType -> {
FormBody.Builder().apply {
// content's type *must* be Map<String, PartConfig<*>>
@@ -145,7 +148,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
val httpUrl = baseUrl.toHttpUrlOrNull() ?: throw IllegalStateException("baseUrl is invalid.")
val url = httpUrl.newBuilder()
.addPathSegments(requestConfig.path.trimStart('/'))
.addEncodedPathSegments(requestConfig.path.trimStart('/'))
.apply {
requestConfig.query.forEach { query ->
query.value.forEach { queryValue ->
@@ -155,7 +158,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
}.build()
// take content-type/accept from spec or set to default (application/json) if not defined
if (requestConfig.headers[ContentType].isNullOrEmpty()) {
if (requestConfig.body != null && requestConfig.headers[ContentType].isNullOrEmpty()) {
requestConfig.headers[ContentType] = JsonMediaType
}
if (requestConfig.headers[Accept].isNullOrEmpty()) {
@@ -163,16 +166,16 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
}
val headers = requestConfig.headers
if(headers[ContentType].isNullOrEmpty()) {
throw kotlin.IllegalStateException("Missing Content-Type header. This is required.")
}
if(headers[Accept].isNullOrEmpty()) {
if (headers[Accept].isNullOrEmpty()) {
throw kotlin.IllegalStateException("Missing Accept header. This is required.")
}
// TODO: support multiple contentType options here.
val contentType = (headers[ContentType] as String).substringBefore(";").lowercase(Locale.getDefault())
val contentType = if (headers[ContentType] != null) {
// TODO: support multiple contentType options here.
(headers[ContentType] as String).substringBefore(";").lowercase(Locale.getDefault())
} else {
null
}
val request = when (requestConfig.method) {
RequestMethod.DELETE -> Request.Builder().url(url).delete(requestBody(requestConfig.body, contentType))

View File

@@ -14,4 +14,4 @@ class BigDecimalAdapter {
fun fromJson(value: String): BigDecimal {
return BigDecimal(value)
}
}
}

View File

@@ -14,4 +14,4 @@ class BigIntegerAdapter {
fun fromJson(value: String): BigInteger {
return BigInteger(value)
}
}
}

View File

@@ -1,14 +1,9 @@
/**
* Demo
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1.0.0
*
*
* Please note:
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* Do not edit this file manually.
*
*/
@file:Suppress(