diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
index b11a3a8c1b5..852296ead55 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache
@@ -1,221 +1,497 @@
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;
-using System.Threading.Tasks;
using Newtonsoft.Json;
using RestSharp;
+using RestSharp.Extensions;
-namespace {{packageName}}.Client {
- ///
- /// API client is mainly responible for making the HTTP call to the API backend
- ///
- public class ApiClient {
-
+namespace {{packageName}}.Client
+{
///
- /// Initializes a new instance of the class.
+ /// API client is mainly responible for making the HTTP call to the API backend.
///
- /// The base path.
- public ApiClient(String basePath="{{basePath}}") {
- this.basePath = basePath;
- this.restClient = new RestClient(this.basePath);
- }
-
- ///
- /// Gets or sets the base path.
- ///
- /// The base path.
- public string basePath { get; set; }
-
- ///
- /// Gets or sets the RestClient
- ///
- /// The RestClient.
- public RestClient restClient { get; set; }
-
- private Dictionary defaultHeaderMap = new Dictionary();
-
- public Object CallApi(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody,
- Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, Dictionary PathParams, String[] AuthSettings) {
- var response = Task.Run(async () => {
- var resp = await CallApiAsync(Path, Method, QueryParams, PostBody, HeaderParams, FormParams, FileParams, PathParams, AuthSettings);
- return resp;
- });
- return response.Result;
- }
-
- public async Task CallApiAsync(String Path, RestSharp.Method Method, Dictionary QueryParams, String PostBody,
- Dictionary HeaderParams, Dictionary FormParams, Dictionary FileParams, Dictionary PathParams, String[] AuthSettings) {
-
- var request = new RestRequest(Path, Method);
-
- UpdateParamsForAuth(QueryParams, HeaderParams, AuthSettings);
-
- // add default header, if any
- foreach(KeyValuePair defaultHeader in this.defaultHeaderMap)
- request.AddHeader(defaultHeader.Key, defaultHeader.Value);
-
- // add path parameter, if any
- foreach(KeyValuePair param in PathParams)
- request.AddParameter(param.Key, param.Value, ParameterType.UrlSegment);
-
- // add header parameter, if any
- foreach(KeyValuePair param in HeaderParams)
- request.AddHeader(param.Key, param.Value);
-
- // add query parameter, if any
- foreach(KeyValuePair param in QueryParams)
- request.AddQueryParameter(param.Key, param.Value);
-
- // add form parameter, if any
- foreach(KeyValuePair param in FormParams)
- request.AddParameter(param.Key, param.Value);
-
- // add file parameter, if any
- foreach(KeyValuePair param in FileParams)
- request.AddFile(param.Key, param.Value);
-
- if (PostBody != null) {
- request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter
- }
-
- return (Object) await restClient.ExecuteTaskAsync(request);
-
- }
-
- ///
- /// Add default header
- ///
- /// Header field name
- /// Header field value
- ///
- public void AddDefaultHeader(string key, string value) {
- defaultHeaderMap.Add(key, value);
- }
-
- ///
- /// Get default header
- ///
- /// Dictionary of default header
- public Dictionary GetDefaultHeader() {
- return defaultHeaderMap;
- }
-
- ///
- /// escape string (url-encoded)
- ///
- /// String to be escaped
- /// Escaped string
- public string EscapeString(string str) {
- return str;
- }
-
- ///
- /// if parameter is DateTime, output in ISO8601 format
- /// if parameter is a list of string, join the list with ","
- /// otherwise just return the string
- ///
- /// The parameter (header, path, query, form)
- /// Formatted string
- public string ParameterToString(object obj)
+ public class ApiClient
{
- if (obj is DateTime) {
- return ((DateTime)obj).ToString ("u");
- } else if (obj is List) {
- return String.Join(",", obj as List);
- } else {
- return Convert.ToString (obj);
- }
- }
-
- ///
- /// Deserialize the JSON string into a proper object
- ///
- /// JSON string
- /// Object type
- /// Object representation of the JSON string
- public object Deserialize(string content, Type type) {
- if (type.GetType() == typeof(Object))
- return (Object)content;
-
- try
- {
- return JsonConvert.DeserializeObject(content, type);
- }
- catch (IOException e) {
- throw new ApiException(500, e.Message);
- }
- }
-
- ///
- /// Serialize an object into JSON string
- ///
- /// Object
- /// JSON string
- public string Serialize(object obj) {
- try
- {
- return obj != null ? JsonConvert.SerializeObject(obj) : null;
- }
- catch (Exception e) {
- throw new ApiException(500, e.Message);
- }
- }
-
- ///
- /// Get the API key with prefix
- ///
- /// Object
- /// API key with prefix
- public string GetApiKeyWithPrefix (string apiKey)
- {
- var apiKeyValue = "";
- Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue);
- var apiKeyPrefix = "";
- if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) {
- return apiKeyPrefix + " " + apiKeyValue;
- } else {
- return apiKeyValue;
- }
- }
-
- ///
- /// Update parameters based on authentication
- ///
- /// Query parameters
- /// Header parameters
- /// Authentication settings
- public void UpdateParamsForAuth(Dictionary QueryParams, Dictionary HeaderParams, string[] AuthSettings) {
- if (AuthSettings == null || AuthSettings.Length == 0)
- return;
+ private readonly Dictionary _defaultHeaderMap = new Dictionary();
- foreach (string auth in AuthSettings) {
- // determine which one to use
- switch(auth) {
- {{#authMethods}}
- case "{{name}}":
- {{#isApiKey}}{{#isKeyInHeader}}HeaderParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}QueryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}HeaderParams["Authorization"] = "Basic " + Base64Encode(Configuration.username + ":" + Configuration.password);{{/isBasic}}
- {{#isOAuth}}//TODO support oauth{{/isOAuth}}
- break;
- {{/authMethods}}
- default:
- //TODO show warning about security definition not found
- break;
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// The base path.
+ 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.
+ ///
+ /// An instance of the RestClient
+ public RestClient RestClient { get; set; }
+
+ ///
+ /// Gets the default header.
+ ///
+ public Dictionary DefaultHeader
+ {
+ get { return _defaultHeaderMap; }
+ }
+
+<<<<<<< HEAD
+ // Creates and sets up a RestRequest prior to a call.
+ private RestRequest PrepareRequest(
+ String path, RestSharp.Method method, Dictionary queryParams, String postBody,
+ Dictionary headerParams, Dictionary formParams,
+ Dictionary fileParams, Dictionary pathParams, String[] authSettings)
+ {
+ var request = new RestRequest(path, method);
+
+ UpdateParamsForAuth(queryParams, headerParams, authSettings);
+
+ // 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);
+
+ // add header parameter, if any
+ foreach(var param in headerParams)
+ request.AddHeader(param.Key, param.Value);
+
+ // add query parameter, if any
+ foreach(var param in queryParams)
+ request.AddQueryParameter(param.Key, param.Value);
+
+ // add form parameter, if any
+ foreach(var param in formParams)
+ request.AddParameter(param.Key, param.Value);
+
+ // add file parameter, if any
+ foreach(var param in fileParams)
+ request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
+
+ if (postBody != null) // http body (model) parameter
+ request.AddParameter("application/json", postBody, ParameterType.RequestBody);
+
+ return request;
+ }
+
+ ///
+ /// Makes the HTTP request (Sync).
+ ///
+ /// URL path.
+ /// HTTP method.
+ /// Query parameters.
+ /// HTTP body (POST request).
+ /// Header parameters.
+ /// Form parameters.
+ /// File parameters.
+ /// Path parameters.
+ /// Authentication settings.
+ /// Object
+ public Object CallApi(
+ String path, RestSharp.Method method, Dictionary queryParams, String postBody,
+ Dictionary headerParams, Dictionary formParams,
+ Dictionary fileParams, Dictionary pathParams, String[] authSettings)
+ {
+ var request = PrepareRequest(
+ path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ return (Object)RestClient.Execute(request);
+ }
+
+ ///
+ /// Makes the asynchronous HTTP request.
+ ///
+ /// URL path.
+ /// HTTP method.
+ /// Query parameters.
+ /// HTTP body (POST request).
+ /// Header parameters.
+ /// Form parameters.
+ /// File parameters.
+ /// Path parameters.
+ /// Authentication settings.
+ /// The Task instance.
+ public async System.Threading.Tasks.Task CallApiAsync(
+ String path, RestSharp.Method method, Dictionary queryParams, String postBody,
+ Dictionary headerParams, Dictionary formParams,
+ Dictionary fileParams, Dictionary pathParams, String[] authSettings)
+ {
+ var request = PrepareRequest(
+ path, method, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+ return (Object) await RestClient.ExecuteTaskAsync(request);
+ }
+
+ ///
+ /// Add default header.
+ ///
+ /// Header field name.
+ /// Header field value.
+ ///
+ public void AddDefaultHeader(string key, string value)
+ {
+ _defaultHeaderMap.Add(key, value);
+ }
+
+ ///
+ /// Escape string (url-encoded).
+ ///
+ /// String to be escaped.
+ /// Escaped string.
+ public string EscapeString(string str)
+ {
+ return HttpUtility.UrlEncode(str);
+ }
+
+ ///
+ /// Create FileParameter based on Stream.
+ ///
+ /// Parameter name.
+ /// Input stream.
+ /// FileParameter.
+ public FileParameter ParameterToFile(string name, Stream stream)
+ {
+ if (stream is FileStream)
+ return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
+ else
+ return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
+ }
+
+ ///
+ /// If parameter is DateTime, output in ISO8601 format.
+ /// If parameter is a list of string, join the list with ",".
+ /// Otherwise just return the string.
+ ///
+ /// The parameter (header, path, query, form).
+ /// Formatted string.
+ public string ParameterToString(object obj)
+ {
+ if (obj is DateTime)
+ return ((DateTime)obj).ToString ("u");
+ else if (obj is List)
+ return String.Join(",", obj as List);
+ else
+ return Convert.ToString (obj);
+ }
+
+ ///
+ /// Deserialize the JSON string into a proper object.
+ ///
+ /// HTTP body (e.g. string, JSON).
+ /// Object type.
+ /// Object representation of the JSON string.
+ public object Deserialize(string content, Type type, IList headers=null)
+ {
+ if (type == typeof(Object)) // return an object
+ {
+ return content;
+ }
+
+ if (type == typeof(Stream))
+ {
+ var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
+ ? Path.GetTempPath()
+ : Configuration.TempFolderPath;
+
+=======
+ ///
+ /// Makes the HTTP request (Sync).
+ ///
+ /// 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)
+ {
+
+ var request = new RestRequest(path, method);
+
+ UpdateParamsForAuth(queryParams, headerParams, authSettings);
+
+ // add default header, if any
+ foreach(var defaultHeader in _defaultHeaderMap)
+ request.AddHeader(defaultHeader.Key, defaultHeader.Value);
+
+ // add header parameter, if any
+ foreach(var param in headerParams)
+ request.AddHeader(param.Key, param.Value);
+
+ // add query parameter, if any
+ foreach(var param in queryParams)
+ request.AddQueryParameter(param.Key, param.Value);
+
+ // add form parameter, if any
+ foreach(var param in formParams)
+ request.AddParameter(param.Key, param.Value);
+
+ // add file parameter, if any
+ foreach(var param in fileParams)
+ request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
+
+ if (postBody != null) // http body (model) parameter
+ request.AddParameter("application/json", postBody, ParameterType.RequestBody);
+
+ return (Object)RestClient.Execute(request);
+
+ }
+
+ ///
+ /// Makes the asynchronous HTTP request.
+ ///
+ /// URL path.
+ /// HTTP method.
+ /// Query parameters.
+ /// HTTP body (POST request).
+ /// Header parameters.
+ /// Form parameters.
+ /// File parameters.
+ /// Authentication settings.
+ /// The Task instance.
+ public async System.Threading.Tasks.Task CallApiAsync(String path, RestSharp.Method method, Dictionary queryParams, String postBody,
+ Dictionary headerParams, Dictionary formParams, Dictionary fileParams, String[] authSettings)
+ {
+
+ var request = new RestRequest(path, method);
+
+ UpdateParamsForAuth(queryParams, headerParams, authSettings);
+
+ // add default header, if any
+ foreach(var defaultHeader in _defaultHeaderMap)
+ request.AddHeader(defaultHeader.Key, defaultHeader.Value);
+
+ // add header parameter, if any
+ foreach(var param in headerParams)
+ request.AddHeader(param.Key, param.Value);
+
+ // add query parameter, if any
+ foreach(var param in queryParams)
+ request.AddQueryParameter(param.Key, param.Value);
+
+ // add form parameter, if any
+ foreach(var param in formParams)
+ request.AddParameter(param.Key, param.Value);
+
+ // add file parameter, if any
+ foreach(var param in fileParams)
+ request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
+
+ if (postBody != null) // http body (model) parameter
+ request.AddParameter("application/json", postBody, ParameterType.RequestBody);
+
+ return (Object) await RestClient.ExecuteTaskAsync(request);
+ }
+
+ ///
+ /// Add default header.
+ ///
+ /// Header field name.
+ /// Header field value.
+ ///
+ public void AddDefaultHeader(string key, string value)
+ {
+ _defaultHeaderMap.Add(key, value);
+ }
+
+ ///
+ /// Escape string (url-encoded).
+ ///
+ /// String to be escaped.
+ /// Escaped string.
+ public string EscapeString(string str)
+ {
+ return HttpUtility.UrlEncode(str);
+ }
+
+ ///
+ /// Create FileParameter based on Stream.
+ ///
+ /// Parameter name.
+ /// Input stream.
+ /// FileParameter.
+ public FileParameter ParameterToFile(string name, Stream stream)
+ {
+ if (stream is FileStream)
+ return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
+ else
+ return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
+ }
+
+ ///
+ /// If parameter is DateTime, output in ISO8601 format.
+ /// If parameter is a list of string, join the list with ",".
+ /// Otherwise just return the string.
+ ///
+ /// The parameter (header, path, query, form).
+ /// Formatted string.
+ public string ParameterToString(object obj)
+ {
+ if (obj is DateTime)
+ return ((DateTime)obj).ToString ("u");
+ else if (obj is List)
+ return String.Join(",", obj as List);
+ else
+ return Convert.ToString (obj);
+ }
+
+ ///
+ /// Deserialize the JSON string into a proper object.
+ ///
+ /// HTTP body (e.g. string, JSON).
+ /// Object type.
+ /// Object representation of the JSON string.
+ public object Deserialize(string content, Type type, IList headers=null)
+ {
+ if (type == typeof(Object)) // return an object
+ {
+ return content;
+ }
+
+ if (type == typeof(Stream))
+ {
+ var filePath = String.IsNullOrEmpty(Configuration.TempFolderPath)
+ ? Path.GetTempPath()
+ : Configuration.TempFolderPath;
+
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+ var fileName = filePath + Guid.NewGuid();
+ if (headers != null)
+ {
+ var regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
+ var match = regex.Match(headers.ToString());
+ if (match.Success)
+ fileName = filePath + match.Value.Replace("\"", "").Replace("'", "");
+ }
+ File.WriteAllText(fileName, content);
+ return new FileStream(fileName, FileMode.Open);
+
+ }
+
+ if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
+ {
+ return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
+ }
+
+ if (type == typeof(String) || type.Name.StartsWith("System.Nullable")) // return primitive type
+ {
+ return ConvertType(content, type);
+ }
+
+ // at this point, it must be a model (json)
+ try
+ {
+ return JsonConvert.DeserializeObject(content, type);
+ }
+ catch (IOException e)
+ {
+ throw new ApiException(500, e.Message);
+ }
+ }
+
+ ///
+ /// Serialize an object into JSON string.
+ ///
+ /// Object.
+ /// JSON string.
+ public string Serialize(object obj)
+ {
+ try
+ {
+ return obj != null ? JsonConvert.SerializeObject(obj) : null;
+ }
+ catch (Exception e)
+ {
+ throw new ApiException(500, e.Message);
+ }
+ }
+
+ ///
+ /// Get the API key with prefix.
+ ///
+ /// API key identifier (authentication scheme).
+ /// API key with prefix.
+ public string GetApiKeyWithPrefix (string apiKeyIdentifier)
+ {
+ var apiKeyValue = "";
+ Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
+ var apiKeyPrefix = "";
+ if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
+ return apiKeyPrefix + " " + apiKeyValue;
+ else
+ return apiKeyValue;
+ }
+
+ ///
+ /// Update parameters based on authentication.
+ ///
+ /// Query parameters.
+ /// Header parameters.
+ /// Authentication settings.
+ public void UpdateParamsForAuth(Dictionary queryParams, Dictionary headerParams, string[] authSettings)
+ {
+ if (authSettings == null || authSettings.Length == 0)
+ return;
+
+ foreach (string auth in authSettings)
+ {
+ // determine which one to use
+ switch(auth)
+ {
+ {{#authMethods}}
+ case "{{name}}":
+ {{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
+ {{#isOAuth}}//TODO support oauth{{/isOAuth}}
+ break;
+ {{/authMethods}}
+ default:
+ //TODO show warning about security definition not found
+ break;
+ }
+ }
+ }
+
+ ///
+ /// Encode string in base64 format.
+ ///
+ /// String to be encoded.
+ /// Encoded string.
+ public static string Base64Encode(string text)
+ {
+ var textByte = System.Text.Encoding.UTF8.GetBytes(text);
+ return System.Convert.ToBase64String(textByte);
+ }
+
+ ///
+ /// Dynamically cast the object into target type.
+ /// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
+ ///
+ /// Object to be casted
+ /// Target type
+ /// Casted object
+ public static dynamic ConvertType(dynamic source, Type dest) {
+ return Convert.ChangeType(source, dest);
+ }
+
}
-
- ///
- /// Encode string in base64 format
- ///
- /// String to be encoded
- public static string Base64Encode(string text) {
- var textByte = System.Text.Encoding.UTF8.GetBytes(text);
- return System.Convert.ToBase64String(textByte);
- }
-
- }
}
diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
index 70bc634ca3a..81bc0231170 100644
--- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache
+++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache
@@ -1,177 +1,210 @@
using System;
+using System.IO;
using System.Collections.Generic;
-using System.Threading.Tasks;
using RestSharp;
using {{packageName}}.Client;
-using {{packageName}}.Model;
-{{#imports}}
-{{/imports}}
+{{#hasImport}}using {{packageName}}.Model;
+{{/hasImport}}
-namespace {{packageName}}.Api {
- {{#operations}}
-
- public interface I{{classname}} {
- {{#operation}}
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{/allParams}}
- /// {{#returnType}}{{{returnType}}}{{/returnType}}
- {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
-
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{/allParams}}
- /// {{#returnType}}{{{returnType}}}{{/returnType}}
- {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
- {{/operation}}
- }
-
- ///
- /// Represents a collection of functions to interact with the API endpoints
- ///
- public class {{classname}} : I{{classname}} {
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// an instance of ApiClient (optional)
- ///
- public {{classname}}(ApiClient apiClient = null) {
- if (apiClient == null) { // use the default one in Configuration
- this.apiClient = Configuration.apiClient;
- } else {
- this.apiClient = apiClient;
- }
- }
-
- ///
- /// Initializes a new instance of the class.
- ///
- ///
- public {{classname}}(String basePath)
+namespace {{packageName}}.Api
+{
+ {{#operations}}
+ public interface I{{classname}}
{
- this.apiClient = new ApiClient(basePath);
+ {{#operation}}
+ ///
+ /// {{summary}} {{notes}}
+ ///
+ {{#allParams}}/// {{description}}
+ {{/allParams}}/// {{#returnType}}{{{returnType}}}{{/returnType}}
+ {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+
+ ///
+ /// {{summary}} {{notes}}
+ ///
+ {{#allParams}}/// {{description}}
+ {{/allParams}}/// {{#returnType}}{{{returnType}}}{{/returnType}}
+ {{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
+ {{/operation}}
}
-
+
///
- /// Sets the base path of the API client.
+ /// Represents a collection of functions to interact with the API endpoints
///
- /// The base path
- public void SetBasePath(String basePath) {
- this.apiClient.basePath = basePath;
+ public class {{classname}} : I{{classname}}
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ /// an instance of ApiClient (optional)
+ ///
+ public {{classname}}(ApiClient apiClient = null)
+ {
+ if (apiClient == null) // use the default one in Configuration
+ this.ApiClient = Configuration.DefaultApiClient;
+ else
+ this.ApiClient = apiClient;
+ }
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ ///
+ public {{classname}}(String basePath)
+ {
+ this.ApiClient = new ApiClient(basePath);
+ }
+
+ ///
+ /// Sets the base path of the API client.
+ ///
+ /// The base path
+ /// The base path
+ public void SetBasePath(String basePath)
+ {
+ this.ApiClient.BasePath = basePath;
+ }
+
+ ///
+ /// Gets the base path of the API client.
+ ///
+ /// The base path
+ /// The base path
+ public String GetBasePath(String basePath)
+ {
+ return this.ApiClient.BasePath;
+ }
+
+ ///
+ /// Gets or sets the API client.
+ ///
+ /// An instance of the ApiClient
+ public ApiClient ApiClient {get; set;}
+
+ {{#operation}}
+ ///
+ /// {{summary}} {{notes}}
+ ///
+ {{#allParams}}/// {{description}}
+ {{/allParams}}/// {{#returnType}}{{{returnType}}}{{/returnType}}
+ public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
+ {
+ {{#allParams}}{{#required}}
+ // verify the required parameter '{{paramName}}' is set
+ if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
+ {{/required}}{{/allParams}}
+
+ var path = "{{path}}";
+<<<<<<< HEAD
+
+ var pathParams = new Dictionary();
+=======
+ path = path.Replace("{format}", "json");
+ {{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
+ {{/pathParams}}
+
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+ var queryParams = new Dictionary();
+ var headerParams = new Dictionary();
+ var formParams = new Dictionary();
+ var fileParams = new Dictionary();
+ String postBody = null;
+<<<<<<< HEAD
+
+ pathParams.Add("format", "json");
+ {{#pathParams}} if ({{paramName}} != null) pathParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // path parameter
+ {{/pathParams}}
+=======
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+
+ {{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
+ {{/queryParams}}
+ {{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
+ {{/headerParams}}
+ {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
+ {{/formParams}}
+ {{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
+ {{/bodyParam}}
+
+ // authentication setting, if any
+ String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
+
+ // make the HTTP request
+<<<<<<< HEAD
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+=======
+ IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+
+ if (((int)response.StatusCode) >= 400)
+ throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
+ else if (((int)response.StatusCode) == 0)
+ throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
+
+ {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}return;{{/returnType}}
+ }
+
+ ///
+ /// {{summary}} {{notes}}
+ ///
+ {{#allParams}}/// {{description}}
+ {{/allParams}}/// {{#returnType}}{{{returnType}}}{{/returnType}}
+ {{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
+ {
+ {{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
+ if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
+ {{/required}}{{/allParams}}
+
+ var path = "{{path}}";
+<<<<<<< HEAD
+
+
+
+ var pathParams = new Dictionary();
+=======
+ path = path.Replace("{format}", "json");
+ {{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
+ {{/pathParams}}
+
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+ var queryParams = new Dictionary();
+ var headerParams = new Dictionary();
+ var formParams = new Dictionary();
+ var fileParams = new Dictionary();
+ String postBody = null;
+
+<<<<<<< HEAD
+ pathParams.Add("format", "json");
+ {{#pathParams}} if ({{paramName}} != null) pathParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // path parameter
+ {{/pathParams}}
+
+=======
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+ {{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
+ {{/queryParams}}
+ {{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
+ {{/headerParams}}
+ {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToFile("{{baseName}}", {{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
+ {{/formParams}}
+ {{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
+ {{/bodyParam}}
+
+ // authentication setting, if any
+ String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
+
+ // make the HTTP request
+<<<<<<< HEAD
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
+=======
+ IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
+>>>>>>> e879268043b53fe30ea0238807b9519687c1e5f2
+ if (((int)response.StatusCode) >= 400)
+ throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
+
+ {{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}
+ return;{{/returnType}}
+ }
+ {{/operation}}
}
-
- ///
- /// Gets the base path of the API client.
- ///
- /// The base path
- public String GetBasePath(String basePath) {
- return this.apiClient.basePath;
- }
-
- ///
- /// Gets or sets the API client.
- ///
- /// The API client
- public ApiClient apiClient {get; set;}
-
-
- {{#operation}}
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{/allParams}}
- /// {{#returnType}}{{{returnType}}}{{/returnType}}
- public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
-
- {{#allParams}}{{#required}}
- // verify the required parameter '{{paramName}}' is set
- if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
- {{/required}}{{/allParams}}
-
- var path = "{{path}}";
-
- var pathParams = new Dictionary();
- var queryParams = new Dictionary();
- var headerParams = new Dictionary();
- var formParams = new Dictionary();
- var fileParams = new Dictionary();
- String postBody = null;
-
- pathParams.Add("format", "json");
- {{#pathParams}} if ({{paramName}} != null) pathParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // path parameter
- {{/pathParams}}
-
- {{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
- {{/queryParams}}
- {{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
- {{/headerParams}}
- {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
- {{/formParams}}
- {{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
- {{/bodyParam}}
-
- // authentication setting, if any
- String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
-
- // make the HTTP request
- IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
-
- if (((int)response.StatusCode) >= 400) {
- throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
- }
- {{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
- return;{{/returnType}}
- }
-
- ///
- /// {{summary}} {{notes}}
- ///
- {{#allParams}}/// {{description}}{{/allParams}}
- /// {{#returnType}}{{{returnType}}}{{/returnType}}
- public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
-
- {{#allParams}}{{#required}}
- // verify the required parameter '{{paramName}}' is set
- if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
- {{/required}}{{/allParams}}
-
- var path = "{{path}}";
-
- var pathParams = new Dictionary();
- var queryParams = new Dictionary();
- var headerParams = new Dictionary();
- var formParams = new Dictionary();
- var fileParams = new Dictionary();
- String postBody = null;
-
- pathParams.Add("format", "json");
- {{#pathParams}} if ({{paramName}} != null) pathParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // path parameter
- {{/pathParams}}
-
- {{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
- {{/queryParams}}
- {{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
- {{/headerParams}}
- {{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
- {{/formParams}}
- {{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
- {{/bodyParam}}
-
- // authentication setting, if any
- String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
-
- // make the HTTP request
- IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
- if (((int)response.StatusCode) >= 400) {
- throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
- }
- {{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
- return;{{/returnType}}
- }
- {{/operation}}
- }
- {{/operations}}
+ {{/operations}}
}