diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index acc99626c58..5dda78a41a4 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -18,16 +18,16 @@ namespace {{packageName}}.Client /// public class ApiClient { - private readonly Dictionary _defaultHeaderMap = new Dictionary(); - /// /// Initializes a new instance of the class. /// /// The base path. public ApiClient(String basePath="{{basePath}}") { - BasePath = basePath; - RestClient = new RestClient(BasePath); + if (String.IsNullOrEmpty(basePath)) + throw new ArgumentException("basePath cannot be empty"); + + RestClient = new RestClient(basePath); } /// @@ -36,36 +36,12 @@ namespace {{packageName}}.Client /// The default API client. public static ApiClient Default = new ApiClient(); - /// - /// Gets or sets the base path. - /// - /// The base path - public string BasePath { get; set; } - /// /// Gets or sets the RestClient. /// /// An instance of the RestClient public RestClient RestClient { get; set; } - /// - /// Gets the default header. - /// - public Dictionary DefaultHeader - { - get { return _defaultHeaderMap; } - } - - /// - /// Gets the status code of the previous request - /// - public int StatusCode { get; private set; } - - /// - /// Gets the response headers of the previous request - /// - public Dictionary ResponseHeaders { get; private set; } - // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( String path, RestSharp.Method method, Dictionary queryParams, String postBody, @@ -74,10 +50,6 @@ namespace {{packageName}}.Client { var request = new RestRequest(path, method); - // add default header, if any - foreach(var defaultHeader in _defaultHeaderMap) - request.AddHeader(defaultHeader.Key, defaultHeader.Value); - // add path parameter, if any foreach(var param in pathParams) request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); @@ -124,8 +96,6 @@ namespace {{packageName}}.Client var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = RestClient.Execute(request); - StatusCode = (int) response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object) response; } @@ -149,22 +119,9 @@ namespace {{packageName}}.Client var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = await RestClient.ExecuteTaskAsync(request); - StatusCode = (int)response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object)response; } - /// - /// Add default header. - /// - /// Header field name. - /// Header field value. - /// - public void AddDefaultHeader(string key, string value) - { - _defaultHeaderMap.Add(key, value); - } - /// /// Escape string (url-encoded). /// diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index a28b395b0db..46dde35d8d3 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -41,7 +41,28 @@ namespace {{packageName}}.Client /// /// The API client. public ApiClient ApiClient; - + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } + /// /// Gets or sets the username (HTTP basic authentication). /// diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 3689729ce41..7a9fe4d8b09 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -49,8 +49,7 @@ namespace {{packageName}}.Api /// public {{classname}}(String basePath) { - this.Configuration = Configuration.Default; - this.SetBasePath(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// @@ -67,23 +66,13 @@ namespace {{packageName}}.Api this.Configuration = configuration; } - /// - /// Sets the base path of the API client. - /// - /// The base path - /// The base path - public void SetBasePath(String basePath) - { - this.Configuration.ApiClient.BasePath = basePath; - } - /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.Configuration.ApiClient.BasePath; + return this.Configuration.BasePath; } /// @@ -101,6 +90,27 @@ namespace {{packageName}}.Api /// Gets the response headers of the previous request /// public Dictionary ResponseHeaders { get; private set; } + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } {{#operation}} /// @@ -119,7 +129,7 @@ namespace {{packageName}}.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 989ee05d0d9..e3b4aad14cd 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -198,8 +198,7 @@ namespace IO.Swagger.Api /// public PetApi(String basePath) { - this.Configuration = Configuration.Default; - this.SetBasePath(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// @@ -216,23 +215,13 @@ namespace IO.Swagger.Api this.Configuration = configuration; } - /// - /// Sets the base path of the API client. - /// - /// The base path - /// The base path - public void SetBasePath(String basePath) - { - this.Configuration.ApiClient.BasePath = basePath; - } - /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.Configuration.ApiClient.BasePath; + return this.Configuration.BasePath; } /// @@ -250,6 +239,27 @@ namespace IO.Swagger.Api /// Gets the response headers of the previous request /// public Dictionary ResponseHeaders { get; private set; } + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } /// @@ -265,7 +275,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -384,7 +394,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -503,7 +513,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -621,7 +631,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -742,7 +752,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -867,7 +877,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -998,7 +1008,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -1127,7 +1137,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index 2eae0cebc46..5fdd6805a2a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -106,8 +106,7 @@ namespace IO.Swagger.Api /// public StoreApi(String basePath) { - this.Configuration = Configuration.Default; - this.SetBasePath(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// @@ -124,23 +123,13 @@ namespace IO.Swagger.Api this.Configuration = configuration; } - /// - /// Sets the base path of the API client. - /// - /// The base path - /// The base path - public void SetBasePath(String basePath) - { - this.Configuration.ApiClient.BasePath = basePath; - } - /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.Configuration.ApiClient.BasePath; + return this.Configuration.BasePath; } /// @@ -158,6 +147,27 @@ namespace IO.Swagger.Api /// Gets the response headers of the previous request /// public Dictionary ResponseHeaders { get; private set; } + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } /// @@ -172,7 +182,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -287,7 +297,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -392,7 +402,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -499,7 +509,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index e3e67eaa9fb..cb70245d911 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -190,8 +190,7 @@ namespace IO.Swagger.Api /// public UserApi(String basePath) { - this.Configuration = Configuration.Default; - this.SetBasePath(basePath); + this.Configuration = new Configuration(new ApiClient(basePath)); } /// @@ -208,23 +207,13 @@ namespace IO.Swagger.Api this.Configuration = configuration; } - /// - /// Sets the base path of the API client. - /// - /// The base path - /// The base path - public void SetBasePath(String basePath) - { - this.Configuration.ApiClient.BasePath = basePath; - } - /// /// Gets the base path of the API client. /// /// The base path public String GetBasePath() { - return this.Configuration.ApiClient.BasePath; + return this.Configuration.BasePath; } /// @@ -242,6 +231,27 @@ namespace IO.Swagger.Api /// Gets the response headers of the previous request /// public Dictionary ResponseHeaders { get; private set; } + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } /// @@ -257,7 +267,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -360,7 +370,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -463,7 +473,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -567,7 +577,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -671,7 +681,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -774,7 +784,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -882,7 +892,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; @@ -993,7 +1003,7 @@ namespace IO.Swagger.Api var pathParams = new Dictionary(); var queryParams = new Dictionary(); - var headerParams = new Dictionary(); + var headerParams = new Dictionary(Configuration.DefaultHeader); var formParams = new Dictionary(); var fileParams = new Dictionary(); String postBody = null; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index 1d511e7624b..07b31cbf817 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -18,16 +18,16 @@ namespace IO.Swagger.Client /// public class ApiClient { - private readonly Dictionary _defaultHeaderMap = new Dictionary(); - /// /// Initializes a new instance of the class. /// /// The base path. public ApiClient(String basePath="http://petstore.swagger.io/v2") { - BasePath = basePath; - RestClient = new RestClient(BasePath); + if (String.IsNullOrEmpty(basePath)) + throw new ArgumentException("basePath cannot be empty"); + + RestClient = new RestClient(basePath); } /// @@ -36,36 +36,12 @@ namespace IO.Swagger.Client /// The default API client. public static ApiClient Default = new ApiClient(); - /// - /// Gets or sets the base path. - /// - /// The base path - public string BasePath { get; set; } - /// /// Gets or sets the RestClient. /// /// An instance of the RestClient public RestClient RestClient { get; set; } - /// - /// Gets the default header. - /// - public Dictionary DefaultHeader - { - get { return _defaultHeaderMap; } - } - - /// - /// Gets the status code of the previous request - /// - public int StatusCode { get; private set; } - - /// - /// Gets the response headers of the previous request - /// - public Dictionary ResponseHeaders { get; private set; } - // Creates and sets up a RestRequest prior to a call. private RestRequest PrepareRequest( String path, RestSharp.Method method, Dictionary queryParams, String postBody, @@ -74,10 +50,6 @@ namespace IO.Swagger.Client { var request = new RestRequest(path, method); - // add default header, if any - foreach(var defaultHeader in _defaultHeaderMap) - request.AddHeader(defaultHeader.Key, defaultHeader.Value); - // add path parameter, if any foreach(var param in pathParams) request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment); @@ -124,8 +96,6 @@ namespace IO.Swagger.Client var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = RestClient.Execute(request); - StatusCode = (int) response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object) response; } @@ -149,22 +119,9 @@ namespace IO.Swagger.Client var request = PrepareRequest( path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams); var response = await RestClient.ExecuteTaskAsync(request); - StatusCode = (int)response.StatusCode; - ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()); return (Object)response; } - /// - /// Add default header. - /// - /// Header field name. - /// Header field value. - /// - public void AddDefaultHeader(string key, string value) - { - _defaultHeaderMap.Add(key, value); - } - /// /// Escape string (url-encoded). /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs index a25a2d28fbf..79bc86118b8 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs @@ -41,7 +41,34 @@ namespace IO.Swagger.Client /// /// The API client. public ApiClient ApiClient; - + + /// + /// Gets or sets the base path. + /// + /// The base path + public string BasePath { get; set; } + + private readonly Dictionary _defaultHeaderMap = new Dictionary(); + + /// + /// Gets the default header. + /// + public Dictionary DefaultHeader + { + get { return _defaultHeaderMap; } + } + + /// + /// Add default header. + /// + /// Header field name. + /// Header field value. + /// + public void AddDefaultHeader(string key, string value) + { + _defaultHeaderMap.Add(key, value); + } + /// /// Gets or sets the username (HTTP basic authentication). /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 2774e9b7536..2b3d5191461 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,8 +2,7 @@ - - + @@ -11,10 +10,9 @@ - - - - + + + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs index 177fd5bf53f..c508917e7d5 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs @@ -26,9 +26,10 @@ namespace SwaggerClient.TestConfiguration public void TestBasePath () { PetApi p = new PetApi ("http://new-basepath.com"); - Assert.AreEqual (p.Configuration.ApiClient.BasePath, "http://new-basepath.com"); - Assert.AreSame (p.Configuration, Configuration.Default); - + Assert.AreEqual (p.Configuration.ApiClient.RestClient.BaseUrl, "http://new-basepath.com"); + // Given that PetApi is initailized with a base path, a new configuration (with a new ApiClient) + // is created by default + Assert.AreNotSame (p.Configuration, Configuration.Default); } [Test ()] @@ -50,5 +51,29 @@ namespace SwaggerClient.TestConfiguration Assert.AreNotSame (p3.Configuration, p1.Configuration); } + + [Test ()] + public void TestUsage () + { + // basic use case using default base URL + PetApi p1 = new PetApi (); + Assert.AreSame (p1.Configuration, Configuration.Default, "PetApi should use default configuration"); + + // using a different base URL + PetApi p2 = new PetApi ("http://new-base-url.com/"); + Assert.AreEqual (p2.Configuration.ApiClient.RestClient.BaseUrl.ToString(), "http://new-base-url.com/"); + + // using a different configuration + Configuration c1 = new Configuration (); + PetApi p3 = new PetApi (c1); + Assert.AreSame (p3.Configuration, c1); + + // using a different base URL via a new ApiClient + ApiClient a1 = new ApiClient ("http://new-api-client.com"); + Configuration c2 = new Configuration (a1); + PetApi p4 = new PetApi (c2); + Assert.AreSame (p4.Configuration.ApiClient, a1); + } + } } \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index 70db74529f5..af6c40173eb 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index dbafd969d6c..52a34556bcf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt index 67be9ad1f14..b46eed9f9d6 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt +++ b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.csproj.FilesWrittenAbsolute.txt @@ -1,16 +1,8 @@ -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll -/Users/williamcheng/Code/csharp/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb +/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll /Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll -/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb -/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index 70db74529f5..af6c40173eb 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index dbafd969d6c..52a34556bcf 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ