forked from loafle/openapi-generator-original
* Adds server variables overrides option to the Maven plugin
This commit is contained in:
parent
290550ef91
commit
4b6499c636
@ -17,19 +17,8 @@
|
||||
|
||||
package org.openapitools.codegen.plugin;
|
||||
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsv;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvp;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyAdditionalPropertiesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyImportMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyInstantiationTypesKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyLanguageSpecificPrimitivesCsvList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyReservedWordsMappingsKvpList;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
|
||||
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
@ -289,6 +278,12 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
@Parameter(name = "additionalProperties", property = "openapi.generator.maven.plugin.additionalProperties")
|
||||
private List<String> additionalProperties;
|
||||
|
||||
/**
|
||||
* A map of server variable overrides for specs that support server URL templating
|
||||
*/
|
||||
@Parameter(name = "serverVariableOverrides", property = "openapi.generator.maven.plugin.serverVariableOverrides")
|
||||
private List<String> serverVariableOverrides;
|
||||
|
||||
/**
|
||||
* A map of reserved names and how they should be escaped
|
||||
*/
|
||||
@ -615,6 +610,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides == null && configOptions.containsKey("server-variables")) {
|
||||
applyServerVariablesKvp(configOptions.get("server-variables").toString(), configurator);
|
||||
}
|
||||
|
||||
// Retained for backwards-compataibility with configOptions -> reserved-words-mappings
|
||||
if (reservedWordsMappings == null && configOptions.containsKey("reserved-words-mappings")) {
|
||||
applyReservedWordsMappingsKvp(configOptions.get("reserved-words-mappings")
|
||||
@ -648,6 +647,10 @@ public class CodeGenMojo extends AbstractMojo {
|
||||
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
|
||||
}
|
||||
|
||||
if (serverVariableOverrides != null && (configOptions == null || !configOptions.containsKey("server-variables"))) {
|
||||
applyServerVariablesKvpList(serverVariableOverrides, configurator);
|
||||
}
|
||||
|
||||
// Apply Reserved Words Mappings
|
||||
if (reservedWordsMappings != null && (configOptions == null || !configOptions.containsKey("reserved-words-mappings"))) {
|
||||
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
|
||||
|
Loading…
x
Reference in New Issue
Block a user