From 8f5329f4f604a441b056e5ffe51837ef51be7c64 Mon Sep 17 00:00:00 2001 From: ckoegel Date: Thu, 25 Jun 2026 14:40:46 -0400 Subject: [PATCH] ignore op server --- custom_templates/Configuration.mustache | 16 +++++++++++++++- .../Client/Auth/TokenResponse.cs | 2 +- src/Bandwidth.Standard/Client/Configuration.cs | 16 +++++++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/custom_templates/Configuration.mustache b/custom_templates/Configuration.mustache index d6f5642d..c6e4b432 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 56e84de6..8335704e 100644 --- a/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs +++ b/src/Bandwidth.Standard/Client/Auth/TokenResponse.cs @@ -20,4 +20,4 @@ class TokenResponse [JsonProperty("access_token")] public string AccessToken { 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 d37d683e..603438e5 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;