diff --git a/custom_templates/Configuration.mustache b/custom_templates/Configuration.mustache
index d6f5642..c6e4b43 100644
--- a/custom_templates/Configuration.mustache
+++ b/custom_templates/Configuration.mustache
@@ -255,12 +255,19 @@ namespace {{packageName}}.Client
///
/// Gets or sets the base path for API access.
///
- public virtual string BasePath
+ public virtual string BasePath
{
get { return _basePath; }
set { _basePath = value; }
}
+ ///
+ /// Gets or sets whether to ignore the per-operation servers defined in the spec and route
+ /// all requests through instead. The default is false. Useful for
+ /// pointing the SDK at a proxy, mock server, or alternate gateway.
+ ///
+ public virtual bool IgnoreOperationServers { get; set; }
+
///
/// Determine whether or not the "default credentials" (e.g. the user account under which the current process is running) will be sent along to the server. The default is false.
///
@@ -563,6 +570,11 @@ namespace {{packageName}}.Client
/// The operation server URL.
public string GetOperationServerUrl(string operation, int index, Dictionary inputVariables)
{
+ if (IgnoreOperationServers)
+ {
+ return null;
+ }
+
if (operation != null && OperationServers.TryGetValue(operation, out var operationServer))
{
return GetServerUrl(operationServer, index, inputVariables);
@@ -727,6 +739,8 @@ namespace {{packageName}}.Client
DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat,
ClientCertificates = second.ClientCertificates ?? first.ClientCertificates,
UseDefaultCredentials = second.UseDefaultCredentials,
+ IgnoreOperationServers = ((second as Configuration)?.IgnoreOperationServers ?? false)
+ || ((first as Configuration)?.IgnoreOperationServers ?? false),
RemoteCertificateValidationCallback = second.RemoteCertificateValidationCallback ?? first.RemoteCertificateValidationCallback,
};
return config;
diff --git a/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs b/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs
index 8707570..c5baec4 100644
--- a/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs
+++ b/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs
@@ -22,4 +22,4 @@ class TokenResponse
[JsonProperty("expires_in")]
public int ExpiresIn { get; set; }
}
-}
\ No newline at end of file
+}
diff --git a/src/Bandwidth.Standard/Client/Configuration.cs b/src/Bandwidth.Standard/Client/Configuration.cs
index d37d683..603438e 100644
--- a/src/Bandwidth.Standard/Client/Configuration.cs
+++ b/src/Bandwidth.Standard/Client/Configuration.cs
@@ -842,12 +842,19 @@ public Configuration(
///
/// Gets or sets the base path for API access.
///
- public virtual string BasePath
+ public virtual string BasePath
{
get { return _basePath; }
set { _basePath = value; }
}
+ ///
+ /// Gets or sets whether to ignore the per-operation servers defined in the spec and route
+ /// all requests through instead. The default is false. Useful for
+ /// pointing the SDK at a proxy, mock server, or alternate gateway.
+ ///
+ public virtual bool IgnoreOperationServers { get; set; }
+
///
/// Determine whether or not the "default credentials" (e.g. the user account under which the current process is running) will be sent along to the server. The default is false.
///
@@ -1145,6 +1152,11 @@ public string GetOperationServerUrl(string operation, int index)
/// The operation server URL.
public string GetOperationServerUrl(string operation, int index, Dictionary inputVariables)
{
+ if (IgnoreOperationServers)
+ {
+ return null;
+ }
+
if (operation != null && OperationServers.TryGetValue(operation, out var operationServer))
{
return GetServerUrl(operationServer, index, inputVariables);
@@ -1290,6 +1302,8 @@ public static IReadableConfiguration MergeConfigurations(IReadableConfiguration
DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat,
ClientCertificates = second.ClientCertificates ?? first.ClientCertificates,
UseDefaultCredentials = second.UseDefaultCredentials,
+ IgnoreOperationServers = ((second as Configuration)?.IgnoreOperationServers ?? false)
+ || ((first as Configuration)?.IgnoreOperationServers ?? false),
RemoteCertificateValidationCallback = second.RemoteCertificateValidationCallback ?? first.RemoteCertificateValidationCallback,
};
return config;