forked from loafle/openapi-generator-original
Merge remote-tracking branch 'origin' into 7.0.x
This commit is contained in:
@@ -11,7 +11,7 @@ This API client was generated by the [OpenAPI Generator](https://openapi-generat
|
||||
|
||||
## Requires
|
||||
|
||||
* Kotlin 1.6.10
|
||||
* Kotlin 1.7.21
|
||||
* Gradle 7.5
|
||||
|
||||
## Build
|
||||
@@ -80,13 +80,6 @@ Class | Method | HTTP request | Description
|
||||
<a name="documentation-for-authorization"></a>
|
||||
## Documentation for Authorization
|
||||
|
||||
<a name="api_key"></a>
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
<a name="petstore_auth"></a>
|
||||
### petstore_auth
|
||||
|
||||
@@ -97,3 +90,10 @@ Class | Method | HTTP request | Description
|
||||
- write:pets: modify pets in your account
|
||||
- read:pets: read your pets
|
||||
|
||||
<a name="api_key"></a>
|
||||
### api_key
|
||||
|
||||
- **Type**: API key
|
||||
- **API key parameter name**: api_key
|
||||
- **Location**: HTTP header
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ wrapper {
|
||||
}
|
||||
|
||||
buildscript {
|
||||
ext.kotlin_version = '1.6.10'
|
||||
ext.kotlin_version = '1.7.21'
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
@@ -18,6 +18,7 @@ buildscript {
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'maven-publish'
|
||||
|
||||
repositories {
|
||||
maven { url "https://repo1.maven.org/maven2" }
|
||||
|
||||
@@ -108,7 +108,7 @@ Configure api_key:
|
||||
|
||||
Find purchase order by ID
|
||||
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
|
||||
### Example
|
||||
```kotlin
|
||||
|
||||
@@ -110,6 +110,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -181,6 +182,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -263,6 +265,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/findByStatus",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -341,6 +344,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/findByTags",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -411,6 +415,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -479,6 +484,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -554,6 +560,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/{petId}".replace("{"+"petId"+"}", encodeURIComponent(petId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -632,6 +639,7 @@ class PetApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient = A
|
||||
path = "/pet/{petId}/uploadImage".replace("{"+"petId"+"}", encodeURIComponent(petId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/store/order/{orderId}".replace("{"+"orderId"+"}", encodeURIComponent(orderId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -175,13 +176,14 @@ class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/store/inventory",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = true,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return Order
|
||||
* @throws IllegalStateException If the request is not correctly configured
|
||||
@@ -212,7 +214,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generate exceptions
|
||||
* @param orderId ID of pet that needs to be fetched
|
||||
* @return ApiResponse<Order?>
|
||||
* @throws IllegalStateException If the request is not correctly configured
|
||||
@@ -245,6 +247,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/store/order/{orderId}".replace("{"+"orderId"+"}", encodeURIComponent(orderId.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -315,6 +318,7 @@ class StoreApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/store/order",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
|
||||
@@ -108,6 +108,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -175,6 +176,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/createWithArray",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -242,6 +244,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/createWithList",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -309,6 +312,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -379,6 +383,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -456,6 +461,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/login",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -520,6 +526,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/logout",
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
@@ -590,6 +597,7 @@ class UserApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
path = "/user/{username}".replace("{"+"username"+"}", encodeURIComponent(username.toString())),
|
||||
query = localVariableQuery,
|
||||
headers = localVariableHeaders,
|
||||
requiresAuthentication = false,
|
||||
body = localVariableBody
|
||||
)
|
||||
}
|
||||
|
||||
@@ -144,6 +144,11 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
||||
}
|
||||
|
||||
protected fun <T> updateAuthParams(requestConfig: RequestConfig<T>) {
|
||||
if (requestConfig.headers[Authorization].isNullOrEmpty()) {
|
||||
accessToken?.let { accessToken ->
|
||||
requestConfig.headers[Authorization] = "Bearer $accessToken "
|
||||
}
|
||||
}
|
||||
if (requestConfig.headers["api_key"].isNullOrEmpty()) {
|
||||
if (apiKey["api_key"] != null) {
|
||||
if (apiKeyPrefix["api_key"] != null) {
|
||||
@@ -153,11 +158,6 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
|
||||
}
|
||||
}
|
||||
}
|
||||
if (requestConfig.headers[Authorization].isNullOrEmpty()) {
|
||||
accessToken?.let { accessToken ->
|
||||
requestConfig.headers[Authorization] = "Bearer $accessToken "
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected inline fun <reified I, reified T: Any?> request(requestConfig: RequestConfig<I>): ApiResponse<T?> {
|
||||
|
||||
@@ -13,5 +13,6 @@ data class RequestConfig<T>(
|
||||
val path: String,
|
||||
val headers: MutableMap<String, String> = mutableMapOf(),
|
||||
val query: MutableMap<String, List<String>> = mutableMapOf(),
|
||||
val requiresAuthentication: Boolean,
|
||||
val body: T? = null
|
||||
)
|
||||
Reference in New Issue
Block a user