forked from loafle/openapi-generator-original
Add model name mapping feature to C# codegen (#16209)
* add model name mapping feature to C# codegen * rename file * update samples * update doc
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
README.md
|
||||
build.gradle
|
||||
docs/Environment.md
|
||||
docs/FakeApi.md
|
||||
docs/PropertyNameMapping.md
|
||||
gradle/wrapper/gradle-wrapper.jar
|
||||
@@ -25,4 +26,5 @@ src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/URIAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/infrastructure/UUIDAdapter.kt
|
||||
src/main/kotlin/org/openapitools/client/models/Environment.kt
|
||||
src/main/kotlin/org/openapitools/client/models/PropertyNameMapping.kt
|
||||
|
||||
@@ -50,6 +50,7 @@ Class | Method | HTTP request | Description
|
||||
<a id="documentation-for-models"></a>
|
||||
## Documentation for Models
|
||||
|
||||
- [org.openapitools.client.models.Environment](docs/Environment.md)
|
||||
- [org.openapitools.client.models.PropertyNameMapping](docs/PropertyNameMapping.md)
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
|
||||
# Environment
|
||||
|
||||
## Properties
|
||||
Name | Type | Description | Notes
|
||||
------------ | ------------- | ------------- | -------------
|
||||
**dummy** | **kotlin.String** | | [optional]
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ Method | HTTP request | Description
|
||||
|
||||
<a id="getParameterNameMapping"></a>
|
||||
# **getParameterNameMapping**
|
||||
> getParameterNameMapping(underscoreType, type, typeWithUnderscore, httpDebugOption)
|
||||
> Environment getParameterNameMapping(underscoreType, type, typeWithUnderscore, httpDebugOption)
|
||||
|
||||
parameter name mapping test
|
||||
|
||||
@@ -25,7 +25,8 @@ val type : kotlin.String = type_example // kotlin.String | type
|
||||
val typeWithUnderscore : kotlin.String = typeWithUnderscore_example // kotlin.String | type_
|
||||
val httpDebugOption : kotlin.String = httpDebugOption_example // kotlin.String | http debug option (to test parameter naming option)
|
||||
try {
|
||||
apiInstance.getParameterNameMapping(underscoreType, type, typeWithUnderscore, httpDebugOption)
|
||||
val result : Environment = apiInstance.getParameterNameMapping(underscoreType, type, typeWithUnderscore, httpDebugOption)
|
||||
println(result)
|
||||
} catch (e: ClientException) {
|
||||
println("4xx response calling FakeApi#getParameterNameMapping")
|
||||
e.printStackTrace()
|
||||
@@ -46,7 +47,7 @@ Name | Type | Description | Notes
|
||||
|
||||
### Return type
|
||||
|
||||
null (empty response body)
|
||||
[**Environment**](Environment.md)
|
||||
|
||||
### Authorization
|
||||
|
||||
@@ -55,5 +56,5 @@ No authorization required
|
||||
### HTTP request headers
|
||||
|
||||
- **Content-Type**: Not defined
|
||||
- **Accept**: Not defined
|
||||
- **Accept**: application/json
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import java.io.IOException
|
||||
import okhttp3.OkHttpClient
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
import org.openapitools.client.models.Environment
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
|
||||
@@ -51,19 +52,20 @@ class FakeApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
* @param type type
|
||||
* @param typeWithUnderscore type_
|
||||
* @param httpDebugOption http debug option (to test parameter naming option)
|
||||
* @return void
|
||||
* @return Environment
|
||||
* @throws IllegalStateException If the request is not correctly configured
|
||||
* @throws IOException Rethrows the OkHttp execute method exception
|
||||
* @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(IllegalStateException::class, IOException::class, UnsupportedOperationException::class, ClientException::class, ServerException::class)
|
||||
fun getParameterNameMapping(underscoreType: kotlin.Long, type: kotlin.String, typeWithUnderscore: kotlin.String, httpDebugOption: kotlin.String) : Unit {
|
||||
fun getParameterNameMapping(underscoreType: kotlin.Long, type: kotlin.String, typeWithUnderscore: kotlin.String, httpDebugOption: kotlin.String) : Environment {
|
||||
val localVarResponse = getParameterNameMappingWithHttpInfo(underscoreType = underscoreType, type = type, typeWithUnderscore = typeWithUnderscore, httpDebugOption = httpDebugOption)
|
||||
|
||||
return when (localVarResponse.responseType) {
|
||||
ResponseType.Success -> Unit
|
||||
ResponseType.Success -> (localVarResponse as Success<*>).data as Environment
|
||||
ResponseType.Informational -> throw UnsupportedOperationException("Client does not support Informational responses.")
|
||||
ResponseType.Redirection -> throw UnsupportedOperationException("Client does not support Redirection responses.")
|
||||
ResponseType.ClientError -> {
|
||||
@@ -84,15 +86,16 @@ class FakeApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
* @param type type
|
||||
* @param typeWithUnderscore type_
|
||||
* @param httpDebugOption http debug option (to test parameter naming option)
|
||||
* @return ApiResponse<Unit?>
|
||||
* @return ApiResponse<Environment?>
|
||||
* @throws IllegalStateException If the request is not correctly configured
|
||||
* @throws IOException Rethrows the OkHttp execute method exception
|
||||
*/
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@Throws(IllegalStateException::class, IOException::class)
|
||||
fun getParameterNameMappingWithHttpInfo(underscoreType: kotlin.Long, type: kotlin.String, typeWithUnderscore: kotlin.String, httpDebugOption: kotlin.String) : ApiResponse<Unit?> {
|
||||
fun getParameterNameMappingWithHttpInfo(underscoreType: kotlin.Long, type: kotlin.String, typeWithUnderscore: kotlin.String, httpDebugOption: kotlin.String) : ApiResponse<Environment?> {
|
||||
val localVariableConfig = getParameterNameMappingRequestConfig(underscoreType = underscoreType, type = type, typeWithUnderscore = typeWithUnderscore, httpDebugOption = httpDebugOption)
|
||||
|
||||
return request<Unit, Unit>(
|
||||
return request<Unit, Environment>(
|
||||
localVariableConfig
|
||||
)
|
||||
}
|
||||
@@ -116,7 +119,8 @@ class FakeApi(basePath: kotlin.String = defaultBasePath, client: OkHttpClient =
|
||||
val localVariableHeaders: MutableMap<String, String> = mutableMapOf()
|
||||
underscoreType.apply { localVariableHeaders["_type"] = this.toString() }
|
||||
typeWithUnderscore.apply { localVariableHeaders["type_"] = this.toString() }
|
||||
|
||||
localVariableHeaders["Accept"] = "application/json"
|
||||
|
||||
return RequestConfig(
|
||||
method = RequestMethod.GET,
|
||||
path = "/fake/parameter-name-mapping",
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
*
|
||||
* Please note:
|
||||
* This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* Do not edit this file manually.
|
||||
*
|
||||
*/
|
||||
|
||||
@file:Suppress(
|
||||
"ArrayInDataClass",
|
||||
"EnumEntryName",
|
||||
"RemoveRedundantQualifierName",
|
||||
"UnusedImport"
|
||||
)
|
||||
|
||||
package org.openapitools.client.models
|
||||
|
||||
|
||||
import com.squareup.moshi.Json
|
||||
import com.squareup.moshi.JsonClass
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param dummy
|
||||
*/
|
||||
|
||||
|
||||
data class Environment (
|
||||
|
||||
@Json(name = "dummy")
|
||||
val dummy: kotlin.String? = null
|
||||
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user