Add schema mappings (#12600)

* add option schema mappings

* add schema mapping support, update tests

* minor fix

* update other generators, tests
This commit is contained in:
William Cheng
2022-07-03 17:46:39 +08:00
committed by GitHub
parent 72b4189f76
commit 2d3bfaf96d
29 changed files with 277 additions and 81 deletions

View File

@@ -298,6 +298,12 @@ public class CodeGenMojo extends AbstractMojo {
@Parameter(name = "importMappings", property = "openapi.generator.maven.plugin.importMappings")
private List<String> importMappings;
/**
* A map of scheme and the new one
*/
@Parameter(name = "schemaMappings", property = "openapi.generator.maven.plugin.schemaMappings")
private List<String> schemaMappings;
/**
* A map of inline scheme names and the new names
*/
@@ -671,6 +677,12 @@ public class CodeGenMojo extends AbstractMojo {
configurator);
}
// Retained for backwards-compatibility with configOptions -> schema-mappings
if (schemaMappings == null && configOptions.containsKey("schema-mappings")) {
applySchemaMappingsKvp(configOptions.get("schema-mappings").toString(),
configurator);
}
// Retained for backwards-compatibility with configOptions -> inline-schema-name-mappings
if (inlineSchemaNameMappings == null && configOptions.containsKey("inline-schema-name-mappings")) {
applyInlineSchemaNameMappingsKvp(configOptions.get("inline-schema-name-mappings").toString(),
@@ -721,6 +733,11 @@ public class CodeGenMojo extends AbstractMojo {
applyImportMappingsKvpList(importMappings, configurator);
}
// Apply Schema Mappings
if (schemaMappings != null && (configOptions == null || !configOptions.containsKey("schema-mappings"))) {
applySchemaMappingsKvpList(schemaMappings, configurator);
}
// Apply Inline Schema Name Mappings
if (inlineSchemaNameMappings != null && (configOptions == null || !configOptions.containsKey("inline-schema-name-mappings"))) {
applyInlineSchemaNameMappingsKvpList(inlineSchemaNameMappings, configurator);