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:
William Cheng
2023-08-02 10:06:11 +08:00
committed by GitHub
parent 3278eea9a4
commit 4602f18ca8
30 changed files with 509 additions and 59 deletions

View File

@@ -177,6 +177,11 @@ open class OpenApiGeneratorGenerateExtension(project: Project) {
*/
val parameterNameMappings = project.objects.mapProperty<String, String>()
/**
* Specifies mappings between a model name and the new name
*/
val modelNameMappings = project.objects.mapProperty<String, String>()
/**
* Specifies mappings (rules) in OpenAPI normalizer
*/

View File

@@ -286,6 +286,13 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
@Input
val parameterNameMappings = project.objects.mapProperty<String, String>()
/**
* Specifies mappings between the model name and the new name
*/
@Optional
@Input
val modelNameMappings = project.objects.mapProperty<String, String>()
/**
* Specifies mappings (rules) in OpenAPI normalizer
*/
@@ -833,6 +840,12 @@ open class GenerateTask @Inject constructor(private val objectFactory: ObjectFac
}
}
if (modelNameMappings.isPresent) {
modelNameMappings.get().forEach { entry ->
configurator.addModelNameMapping(entry.key, entry.value)
}
}
if (openapiNormalizer.isPresent) {
openapiNormalizer.get().forEach { entry ->
configurator.addOpenAPINormalizer(entry.key, entry.value)