[core][gradle] User-defined server variable substitutions (#3363)

* [core] Initial support for server variable overrides
* [gradle] Support user overrides for serverVariables
* [core] Clarify server variable overrides, and propagate them to templates in the "servers" array
This commit is contained in:
Jim Schubert
2019-08-11 09:57:36 -04:00
committed by GitHub
parent 07381e7275
commit 06533b977c
29 changed files with 305 additions and 101 deletions

View File

@@ -18,13 +18,7 @@
package org.openapitools.codegen.cmd;
import static org.apache.commons.lang3.StringUtils.isNotEmpty;
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.applyReservedWordsMappingsKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applySystemPropertiesKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.applyTypeMappingsKvpList;
import static org.openapitools.codegen.config.CodegenConfiguratorUtils.*;
import ch.qos.logback.classic.LoggerContext;
import ch.qos.logback.core.spi.FilterAttachable;
@@ -160,6 +154,12 @@ public class Generate implements Runnable {
+ " You can also have multiple occurrences of this option.")
private List<String> importMappings = new ArrayList<>();
@Option(
name = {"--server-variables"},
title = "server variables",
description = "sets server variables overrides for spec documents which support variable templating of servers.")
private List<String> serverVariableOverrides = new ArrayList<>();
@Option(name = {"--invoker-package"}, title = "invoker package",
description = CodegenConstants.INVOKER_PACKAGE_DESC)
private String invokerPackage;
@@ -393,6 +393,7 @@ public class Generate implements Runnable {
applyAdditionalPropertiesKvpList(additionalProperties, configurator);
applyLanguageSpecificPrimitivesCsvList(languageSpecificPrimitives, configurator);
applyReservedWordsMappingsKvpList(reservedWordsMappings, configurator);
applyServerVariablesKvpList(serverVariableOverrides, configurator);
try {
final ClientOptInput clientOptInput = configurator.toClientOptInput();