diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index 905931a2991..4206b3434e4 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -1,7 +1,9 @@
using System;
using System.Collections.Generic;
+using System.Globalization;
using System.Text.RegularExpressions;
using System.IO;
+using System.Web;
using System.Linq;
using System.Net;
using System.Text;
@@ -10,222 +12,222 @@ using Newtonsoft.Json;
using RestSharp;
using RestSharp.Extensions;
-namespace {{packageName}}.Client {
+namespace {{packageName}}.Client
+{
///
- /// API client is mainly responible for making the HTTP call to the API backend
+ /// API client is mainly responible for making the HTTP call to the API backend.
///
- public class ApiClient {
+ public class ApiClient
+ {
+ private readonly Dictionary _defaultHeaderMap = new Dictionary();
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
/// The base path.
- public ApiClient(String basePath="{{basePath}}") {
- this.BasePath = basePath;
- this.RestClient = new RestClient(this.BasePath);
+ public ApiClient(String basePath="{{basePath}}")
+ {
+ BasePath = basePath;
+ RestClient = new RestClient(BasePath);
}
///
/// Gets or sets the base path.
///
- /// The base path.
public string BasePath { get; set; }
///
- /// Gets or sets the RestClient
+ /// Gets or sets the RestClient.
///
- /// The RestClient.
public RestClient RestClient { get; set; }
- private Dictionary DefaultHeaderMap = new Dictionary();
+ ///
+ /// Gets the default header.
+ ///
+ public Dictionary DefaultHeader
+ {
+ get { return _defaultHeaderMap; }
+ }
///
- /// Make the HTTP request (Sync)
+ /// Makes the HTTP request (Sync).
///
- /// URL path
- /// HTTP method
- /// Query parameters
- /// HTTP body (POST request)
- /// Header parameters
- /// Form parameters
- /// File parameters
- /// Authentication settings
+ /// URL path.
+ /// HTTP method.
+ /// Query parameters.
+ /// HTTP body (POST request).
+ /// Header parameters.
+ /// Form parameters.
+ /// File parameters.
+ /// Authentication settings.
/// Object
public Object CallApi(String path, RestSharp.Method method, Dictionary queryParams, String postBody,
Dictionary headerParams, Dictionary formParams,
- Dictionary fileParams, String[] authSettings) {
+ Dictionary fileParams, String[] authSettings)
+ {
var request = new RestRequest(path, method);
UpdateParamsForAuth(queryParams, headerParams, authSettings);
// add default header, if any
- foreach(KeyValuePair defaultHeader in this.DefaultHeaderMap)
+ foreach(var defaultHeader in _defaultHeaderMap)
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
// add header parameter, if any
- foreach(KeyValuePair param in headerParams)
+ foreach(var param in headerParams)
request.AddHeader(param.Key, param.Value);
// add query parameter, if any
- foreach(KeyValuePair param in queryParams)
+ foreach(var param in queryParams)
request.AddQueryParameter(param.Key, param.Value);
// add form parameter, if any
- foreach(KeyValuePair param in formParams)
+ foreach(var param in formParams)
request.AddParameter(param.Key, param.Value);
// add file parameter, if any
- foreach(KeyValuePair param in fileParams)
+ foreach(var param in fileParams)
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
-
- if (postBody != null) {
- request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
- }
+ if (postBody != null) // http body (model) parameter
+ request.AddParameter("application/json", postBody, ParameterType.RequestBody);
return (Object)RestClient.Execute(request);
}
///
- /// Make the HTTP request (Async)
+ /// Makes the asynchronous HTTP request.
///
- /// URL path
- /// HTTP method
- /// Query parameters
- /// HTTP body (POST request)
- /// Header parameters
- /// Form parameters
- /// File parameters
- /// Authentication settings
- /// Task
+ /// URL path.
+ /// HTTP method.
+ /// Query parameters.
+ /// HTTP body (POST request).
+ /// Header parameters.
+ /// Form parameters.
+ /// File parameters.
+ /// Authentication settings.
+ /// The Task instance.
public async Task