diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache index bdc24c21a17..619bcb6bfbb 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/ApiClient.mustache @@ -168,9 +168,9 @@ namespace {{packageName}}.Client { private readonly String _baseUrl; - private readonly HttpClientHandler _httpClientHandler; - private readonly HttpClient _httpClient; - private readonly bool _disposeClient; + private readonly HttpClientHandler _httpClientHandler; + private readonly HttpClient _httpClient; + private readonly bool _disposeClient; /// /// Specifies the settings on a object. @@ -192,88 +192,63 @@ namespace {{packageName}}.Client /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient() : this({{packageName}}.Client.GlobalConfiguration.Instance.BasePath) - { + { } - + /// /// Initializes a new instance of the . /// /// The target service's base path in URL format. /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient(String basePath) - { - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + { + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - _httpClientHandler = new HttpClientHandler(); - _httpClient = new HttpClient(_httpClientHandler, true); + _httpClientHandler = new HttpClientHandler(); + _httpClient = new HttpClient(_httpClientHandler, true); _disposeClient = true; - _baseUrl = basePath; + _baseUrl = basePath; } - + /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// /// An instance of HttpClient. - /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. - /// - public ApiClient(HttpClient client) : - this(client, {{packageName}}.Client.GlobalConfiguration.Instance.BasePath) - { + /// + public ApiClient(HttpClient client, HttpClientHandler handler = null) : + this(client, {{packageName}}.Client.GlobalConfiguration.Instance.BasePath, handler) + { } - - /// - /// Initializes a new instance of the - /// - /// An instance of HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. - /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. - /// - public ApiClient(HttpClient client, String basePath) - { - if (client == null) throw new ArgumentNullException("client cannot be null"); - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - - _httpClient = client; - _baseUrl = basePath; - } - - /// - /// Initializes a new instance of the , defaulting to the global configurations' base url. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - public ApiClient(HttpClient client, HttpClientHandler handler) : - this(client, handler, {{packageName}}.Client.GlobalConfiguration.Instance.BasePath) - { - } - - /// + + /// /// Initializes a new instance of the . /// /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - public ApiClient(HttpClient client, HttpClientHandler handler, String basePath) - { - if (client == null) throw new ArgumentNullException("client cannot be null"); - if (handler == null) throw new ArgumentNullException("handler cannot be null"); - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - - _httpClientHandler = handler; - _httpClient = client; - _baseUrl = basePath; + /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, String basePath, HttpClientHandler handler = null) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClientHandler = handler; + _httpClient = client; + _baseUrl = basePath; } /// diff --git a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache index b71ebee0f81..efa52cfbd41 100644 --- a/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache +++ b/modules/openapi-generator/src/main/resources/csharp-netcore/libraries/httpclient/api.mustache @@ -108,6 +108,7 @@ namespace {{packageName}}.{{apiPackage}} /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}() : this((string)null) { } @@ -116,8 +117,9 @@ namespace {{packageName}}.{{apiPackage}} /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}(String basePath) { this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( @@ -138,6 +140,7 @@ namespace {{packageName}}.{{apiPackage}} /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public {{classname}}({{packageName}}.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -158,13 +161,14 @@ namespace {{packageName}}.{{apiPackage}} /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public {{classname}}(HttpClient client) : this(client, (string)null) + public {{classname}}(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -173,14 +177,15 @@ namespace {{packageName}}.{{apiPackage}} /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public {{classname}}(HttpClient client, String basePath) + public {{classname}}(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -188,7 +193,7 @@ namespace {{packageName}}.{{apiPackage}} {{packageName}}.Client.GlobalConfiguration.Instance, new {{packageName}}.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; {{#supportsAsync}} this.AsynchronousClient = this.ApiClient; @@ -201,85 +206,23 @@ namespace {{packageName}}.{{apiPackage}} /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public {{classname}}(HttpClient client, {{packageName}}.Client.Configuration configuration) + public {{classname}}(HttpClient client, {{packageName}}.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( - {{packageName}}.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - {{#supportsAsync}} - this.AsynchronousClient = this.ApiClient; - {{/supportsAsync}} - ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public {{classname}}(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public {{classname}}(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( - {{packageName}}.Client.GlobalConfiguration.Instance, - new {{packageName}}.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new {{packageName}}.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - {{#supportsAsync}} - this.AsynchronousClient = this.ApiClient; - {{/supportsAsync}} - this.ExceptionFactory = {{packageName}}.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public {{classname}}(HttpClient client, HttpClientHandler handler, {{packageName}}.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = {{packageName}}.Client.Configuration.MergeConfigurations( {{packageName}}.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new {{packageName}}.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new {{packageName}}.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; {{#supportsAsync}} this.AsynchronousClient = this.ApiClient; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs index 6ee69d73cd3..83a938cf365 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/AnotherFakeApi.cs @@ -102,6 +102,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi() : this((string)null) { } @@ -110,8 +111,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -130,6 +132,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public AnotherFakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -148,13 +151,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public AnotherFakeApi(HttpClient client) : this(client, (string)null) + public AnotherFakeApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -163,14 +167,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public AnotherFakeApi(HttpClient client, String basePath) + public AnotherFakeApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -178,7 +183,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -189,81 +194,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public AnotherFakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public AnotherFakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public AnotherFakeApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public AnotherFakeApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public AnotherFakeApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs index f79f629815a..84b91a9a171 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/DefaultApi.cs @@ -95,6 +95,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi() : this((string)null) { } @@ -103,8 +104,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -123,6 +125,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public DefaultApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -141,13 +144,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public DefaultApi(HttpClient client) : this(client, (string)null) + public DefaultApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -156,14 +160,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public DefaultApi(HttpClient client, String basePath) + public DefaultApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -171,7 +176,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -182,81 +187,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public DefaultApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public DefaultApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public DefaultApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public DefaultApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public DefaultApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs index 96d3df634d2..305a59a6b5b 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeApi.cs @@ -819,6 +819,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi() : this((string)null) { } @@ -827,8 +828,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -847,6 +849,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -865,13 +868,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeApi(HttpClient client) : this(client, (string)null) + public FakeApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -880,14 +884,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeApi(HttpClient client, String basePath) + public FakeApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -895,7 +900,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -906,81 +911,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public FakeApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public FakeApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public FakeApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public FakeApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs index 1aa57d4b4e2..f9c9d3b33ce 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/FakeClassnameTags123Api.cs @@ -102,6 +102,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api() : this((string)null) { } @@ -110,8 +111,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -130,6 +132,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public FakeClassnameTags123Api(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -148,13 +151,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeClassnameTags123Api(HttpClient client) : this(client, (string)null) + public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -163,14 +167,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeClassnameTags123Api(HttpClient client, String basePath) + public FakeClassnameTags123Api(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -178,7 +183,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -189,81 +194,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public FakeClassnameTags123Api(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public FakeClassnameTags123Api(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public FakeClassnameTags123Api(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs index ab82da44ef0..b43e10ad1ff 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/PetApi.cs @@ -464,6 +464,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi() : this((string)null) { } @@ -472,8 +473,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -492,6 +494,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public PetApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -510,13 +513,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public PetApi(HttpClient client) : this(client, (string)null) + public PetApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -525,14 +529,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public PetApi(HttpClient client, String basePath) + public PetApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -540,7 +545,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -551,81 +556,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public PetApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public PetApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public PetApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public PetApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public PetApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs index 760576e1ec0..f174edf5062 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/StoreApi.cs @@ -227,6 +227,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi() : this((string)null) { } @@ -235,8 +236,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -255,6 +257,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public StoreApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -273,13 +276,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public StoreApi(HttpClient client) : this(client, (string)null) + public StoreApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -288,14 +292,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public StoreApi(HttpClient client, String basePath) + public StoreApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -303,7 +308,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -314,81 +319,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public StoreApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public StoreApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public StoreApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public StoreApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public StoreApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs index c1174daeadf..0426a00745e 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Api/UserApi.cs @@ -399,6 +399,7 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi() : this((string)null) { } @@ -407,8 +408,9 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// The target service's base path in URL format. - /// + /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi(String basePath) { this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( @@ -427,6 +429,7 @@ namespace Org.OpenAPITools.Api /// An instance of Configuration. /// /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public UserApi(Org.OpenAPITools.Client.Configuration configuration) { if (configuration == null) throw new ArgumentNullException("configuration"); @@ -445,13 +448,14 @@ namespace Org.OpenAPITools.Api /// Initializes a new instance of the class. /// /// An instance of HttpClient. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public UserApi(HttpClient client) : this(client, (string)null) + public UserApi(HttpClient client, HttpClientHandler handler = null) : this(client, (string)null, handler) { } @@ -460,14 +464,15 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// - /// + /// /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public UserApi(HttpClient client, String basePath) + public UserApi(HttpClient client, String basePath, HttpClientHandler handler = null) { if (client == null) throw new ArgumentNullException("client"); @@ -475,7 +480,7 @@ namespace Org.OpenAPITools.Api Org.OpenAPITools.Client.GlobalConfiguration.Instance, new Org.OpenAPITools.Client.Configuration { BasePath = basePath } ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; @@ -486,81 +491,23 @@ namespace Org.OpenAPITools.Api /// /// An instance of HttpClient. /// An instance of Configuration. + /// An optional instance of HttpClientHandler that is used by HttpClient. /// /// /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. /// - public UserApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration) + public UserApi(HttpClient client, Org.OpenAPITools.Client.Configuration configuration, HttpClientHandler handler = null) { if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - configuration - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - /// - public UserApi(HttpClient client, HttpClientHandler handler) : this(client, handler, (string)null) - { - } - - /// - /// Initializes a new instance of the class. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - public UserApi(HttpClient client, HttpClientHandler handler, String basePath) - { if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); - - this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( - Org.OpenAPITools.Client.GlobalConfiguration.Instance, - new Org.OpenAPITools.Client.Configuration { BasePath = basePath } - ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); - this.Client = this.ApiClient; - this.AsynchronousClient = this.ApiClient; - this.ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; - } - - /// - /// Initializes a new instance of the class using Configuration object. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// An instance of Configuration. - /// - /// - public UserApi(HttpClient client, HttpClientHandler handler, Org.OpenAPITools.Client.Configuration configuration) - { - if (configuration == null) throw new ArgumentNullException("configuration"); - if (client == null) throw new ArgumentNullException("client"); - if (handler == null) throw new ArgumentNullException("handler"); this.Configuration = Org.OpenAPITools.Client.Configuration.MergeConfigurations( Org.OpenAPITools.Client.GlobalConfiguration.Instance, configuration ); - this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, handler, this.Configuration.BasePath); + this.ApiClient = new Org.OpenAPITools.Client.ApiClient(client, this.Configuration.BasePath, handler); this.Client = this.ApiClient; this.AsynchronousClient = this.ApiClient; ExceptionFactory = Org.OpenAPITools.Client.Configuration.DefaultExceptionFactory; diff --git a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs index 6cf20d59443..26695dd48d4 100644 --- a/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs +++ b/samples/client/petstore/csharp-netcore/OpenAPIClient-httpclient/src/Org.OpenAPITools/Client/ApiClient.cs @@ -168,9 +168,9 @@ namespace Org.OpenAPITools.Client { private readonly String _baseUrl; - private readonly HttpClientHandler _httpClientHandler; - private readonly HttpClient _httpClient; - private readonly bool _disposeClient; + private readonly HttpClientHandler _httpClientHandler; + private readonly HttpClient _httpClient; + private readonly bool _disposeClient; /// /// Specifies the settings on a object. @@ -192,88 +192,63 @@ namespace Org.OpenAPITools.Client /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient() : this(Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) - { + { } - + /// /// Initializes a new instance of the . /// /// The target service's base path in URL format. /// + [Obsolete("Constructors without HttpClient have non-trivial drawbacks and are thus considered deprecated. Check README.md for details.")] public ApiClient(String basePath) - { - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + { + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - _httpClientHandler = new HttpClientHandler(); - _httpClient = new HttpClient(_httpClientHandler, true); + _httpClientHandler = new HttpClientHandler(); + _httpClient = new HttpClient(_httpClientHandler, true); _disposeClient = true; - _baseUrl = basePath; + _baseUrl = basePath; } - + /// /// Initializes a new instance of the , defaulting to the global configurations' base url. /// /// An instance of HttpClient. - /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. - /// - public ApiClient(HttpClient client) : - this(client, Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) - { + /// + public ApiClient(HttpClient client, HttpClientHandler handler = null) : + this(client, Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath, handler) + { } - - /// - /// Initializes a new instance of the - /// - /// An instance of HttpClient. - /// The target service's base path in URL format. - /// - /// - /// - /// Some configuration settings will not be applied without passing an HttpClientHandler. - /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. - /// - public ApiClient(HttpClient client, String basePath) - { - if (client == null) throw new ArgumentNullException("client cannot be null"); - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - - _httpClient = client; - _baseUrl = basePath; - } - - /// - /// Initializes a new instance of the , defaulting to the global configurations' base url. - /// - /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// - public ApiClient(HttpClient client, HttpClientHandler handler) : - this(client, handler, Org.OpenAPITools.Client.GlobalConfiguration.Instance.BasePath) - { - } - - /// + + /// /// Initializes a new instance of the . /// /// An instance of HttpClient. - /// An instance of HttpClientHandler that is used by HttpClient. - /// The target service's base path in URL format. - /// - /// - public ApiClient(HttpClient client, HttpClientHandler handler, String basePath) - { - if (client == null) throw new ArgumentNullException("client cannot be null"); - if (handler == null) throw new ArgumentNullException("handler cannot be null"); - if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); - - _httpClientHandler = handler; - _httpClient = client; - _baseUrl = basePath; + /// The target service's base path in URL format. + /// An optional instance of HttpClientHandler that is used by HttpClient. + /// + /// + /// + /// Some configuration settings will not be applied without passing an HttpClientHandler. + /// The features affected are: Setting and Retrieving Cookies, Client Certificates, Proxy settings. + /// + public ApiClient(HttpClient client, String basePath, HttpClientHandler handler = null) + { + if (client == null) throw new ArgumentNullException("client cannot be null"); + if (string.IsNullOrEmpty(basePath)) throw new ArgumentException("basePath cannot be empty"); + + _httpClientHandler = handler; + _httpClient = client; + _baseUrl = basePath; } ///