Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion custom_templates/Configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,19 @@ namespace {{packageName}}.Client
/// <summary>
/// Gets or sets the base path for API access.
/// </summary>
public virtual string BasePath
public virtual string BasePath
{
get { return _basePath; }
set { _basePath = value; }
}

/// <summary>
/// Gets or sets whether to ignore the per-operation servers defined in the spec and route
/// all requests through <see cref="BasePath"/> instead. The default is false. Useful for
/// pointing the SDK at a proxy, mock server, or alternate gateway.
/// </summary>
public virtual bool IgnoreOperationServers { get; set; }

/// <summary>
/// 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.
/// </summary>
Expand Down Expand Up @@ -563,6 +570,11 @@ namespace {{packageName}}.Client
/// <return>The operation server URL.</return>
public string GetOperationServerUrl(string operation, int index, Dictionary<string, string> inputVariables)
{
if (IgnoreOperationServers)
{
return null;
}

if (operation != null && OperationServers.TryGetValue(operation, out var operationServer))
{
return GetServerUrl(operationServer, index, inputVariables);
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/Bandwidth.Standard/Client/Auth/TokenResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ class TokenResponse
[JsonProperty("expires_in")]
public int ExpiresIn { get; set; }
}
}
}
16 changes: 15 additions & 1 deletion src/Bandwidth.Standard/Client/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,12 +842,19 @@ public Configuration(
/// <summary>
/// Gets or sets the base path for API access.
/// </summary>
public virtual string BasePath
public virtual string BasePath
{
get { return _basePath; }
set { _basePath = value; }
}

/// <summary>
/// Gets or sets whether to ignore the per-operation servers defined in the spec and route
/// all requests through <see cref="BasePath"/> instead. The default is false. Useful for
/// pointing the SDK at a proxy, mock server, or alternate gateway.
/// </summary>
public virtual bool IgnoreOperationServers { get; set; }

/// <summary>
/// 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.
/// </summary>
Expand Down Expand Up @@ -1145,6 +1152,11 @@ public string GetOperationServerUrl(string operation, int index)
/// <return>The operation server URL.</return>
public string GetOperationServerUrl(string operation, int index, Dictionary<string, string> inputVariables)
{
if (IgnoreOperationServers)
{
return null;
}

if (operation != null && OperationServers.TryGetValue(operation, out var operationServer))
{
return GetServerUrl(operationServer, index, inputVariables);
Expand Down Expand Up @@ -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;
Expand Down
Loading