|
7 | 7 | import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
8 | 8 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
|
9 | 9 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
| 10 | +import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyEnumNameMappingsKvpList; |
10 | 11 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
|
11 | 12 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
12 | 13 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
|
13 | 14 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
14 | 15 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
|
15 | 16 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
| 17 | +import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyNameMappingsKvpList; |
16 | 18 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyOpenAPINormalizerKvpList;
|
17 | 19 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
|
18 | 20 | import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
@@ -492,15 +494,36 @@ static String uniqueJoin(Collection<String> values) {
|
492 | 494 | private List<String> openapiNormalizer;
|
493 | 495 |
|
494 | 496 | /**
|
495 |
| - * A map of scheme and the new one |
| 497 | + * A map of scheme and the new one. |
496 | 498 | */
|
497 | 499 | @Parameter(name = "schemaMappings", property = "openapi.generator.maven.plugin.schemaMappings")
|
498 | 500 | private List<String> schemaMappings;
|
499 | 501 |
|
| 502 | + /** |
| 503 | + * A map of property names and the new names. |
| 504 | + */ |
| 505 | + @Parameter(name = "nameMappings", property = "openapi.generator.maven.plugin.nameMappings") |
| 506 | + private List<String> nameMappings; |
| 507 | + |
| 508 | + /** |
| 509 | + * A map of enum names and the new names. |
| 510 | + */ |
| 511 | + @Parameter(name = "enumNameMappings", property = "openapi.generator.maven.plugin.enumNameMappings") |
| 512 | + private List<String> enumNameMappings; |
| 513 | + |
| 514 | + |
500 | 515 | public void setBuildContext(BuildContext buildContext) {
|
501 | 516 | this.buildContext = buildContext;
|
502 | 517 | }
|
503 | 518 |
|
| 519 | + public void setNameMappings(List<String> nameMappings) { |
| 520 | + this.nameMappings = nameMappings; |
| 521 | + } |
| 522 | + |
| 523 | + public void setEnumNameMappings(List<String> enumNameMappings) { |
| 524 | + this.enumNameMappings = enumNameMappings; |
| 525 | + } |
| 526 | + |
504 | 527 | @Override
|
505 | 528 | @SuppressWarnings({"java:S3776", "java:S1874"})
|
506 | 529 | public void execute() throws MojoExecutionException, MojoFailureException {
|
@@ -865,6 +888,16 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
865 | 888 | applySchemaMappingsKvpList(schemaMappings, configurator);
|
866 | 889 | }
|
867 | 890 |
|
| 891 | + // Apply Name Mappings |
| 892 | + if (nameMappings != null && (configOptions == null || !configOptions.containsKey("name-mappings"))) { |
| 893 | + applyNameMappingsKvpList(nameMappings, configurator); |
| 894 | + } |
| 895 | + |
| 896 | + // Apply Enum Name Mappings |
| 897 | + if (enumNameMappings != null && (configOptions == null || !configOptions.containsKey("enum-name-mappings"))) { |
| 898 | + applyEnumNameMappingsKvpList(enumNameMappings, configurator); |
| 899 | + } |
| 900 | + |
868 | 901 | if (environmentVariables != null) {
|
869 | 902 |
|
870 | 903 | for (Entry<String, String> entry : environmentVariables.entrySet()) {
|
|
0 commit comments