forked from loafle/openapi-generator-original
update c# style
This commit is contained in:
parent
94768d44b5
commit
b1b0e28f59
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Web;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -10,222 +12,222 @@ using Newtonsoft.Json;
|
|||||||
using RestSharp;
|
using RestSharp;
|
||||||
using RestSharp.Extensions;
|
using RestSharp.Extensions;
|
||||||
|
|
||||||
namespace {{packageName}}.Client {
|
namespace {{packageName}}.Client
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ApiClient {
|
public class ApiClient
|
||||||
|
{
|
||||||
|
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ApiClient"/> class.
|
/// Initializes a new instance of the <see cref="ApiClient" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="basePath">The base path.</param>
|
/// <param name="basePath">The base path.</param>
|
||||||
public ApiClient(String basePath="{{basePath}}") {
|
public ApiClient(String basePath="{{basePath}}")
|
||||||
this.BasePath = basePath;
|
{
|
||||||
this.RestClient = new RestClient(this.BasePath);
|
BasePath = basePath;
|
||||||
|
RestClient = new RestClient(BasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the base path.
|
/// Gets or sets the base path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path.</value>
|
|
||||||
public string BasePath { get; set; }
|
public string BasePath { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the RestClient
|
/// Gets or sets the RestClient.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The RestClient.</value>
|
|
||||||
public RestClient RestClient { get; set; }
|
public RestClient RestClient { get; set; }
|
||||||
|
|
||||||
private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
|
/// <summary>
|
||||||
|
/// Gets the default header.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<String, String> DefaultHeader
|
||||||
|
{
|
||||||
|
get { return _defaultHeaderMap; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make the HTTP request (Sync)
|
/// Makes the HTTP request (Sync).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">URL path</param>
|
/// <param name="path">URL path.</param>
|
||||||
/// <param name="method">HTTP method</param>
|
/// <param name="method">HTTP method.</param>
|
||||||
/// <param name="queryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="postBody">HTTP body (POST request)</param>
|
/// <param name="postBody">HTTP body (POST request).</param>
|
||||||
/// <param name="headerParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="formParams">Form parameters</param>
|
/// <param name="formParams">Form parameters.</param>
|
||||||
/// <param name="fileParams">File parameters</param>
|
/// <param name="fileParams">File parameters.</param>
|
||||||
/// <param name="authSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
/// <returns>Object</returns>
|
/// <returns>Object</returns>
|
||||||
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
||||||
Dictionary<String, FileParameter> fileParams, String[] authSettings) {
|
Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||||
|
{
|
||||||
|
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
|
||||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||||
|
|
||||||
// add default header, if any
|
// add default header, if any
|
||||||
foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
|
foreach(var defaultHeader in _defaultHeaderMap)
|
||||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||||
|
|
||||||
// add header parameter, if any
|
// add header parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in headerParams)
|
foreach(var param in headerParams)
|
||||||
request.AddHeader(param.Key, param.Value);
|
request.AddHeader(param.Key, param.Value);
|
||||||
|
|
||||||
// add query parameter, if any
|
// add query parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in queryParams)
|
foreach(var param in queryParams)
|
||||||
request.AddQueryParameter(param.Key, param.Value);
|
request.AddQueryParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in formParams)
|
foreach(var param in formParams)
|
||||||
request.AddParameter(param.Key, param.Value);
|
request.AddParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add file parameter, if any
|
// add file parameter, if any
|
||||||
foreach(KeyValuePair<string, FileParameter> param in fileParams)
|
foreach(var param in fileParams)
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||||
|
|
||||||
|
if (postBody != null) // http body (model) parameter
|
||||||
if (postBody != null) {
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Object)RestClient.Execute(request);
|
return (Object)RestClient.Execute(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make the HTTP request (Async)
|
/// Makes the asynchronous HTTP request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">URL path</param>
|
/// <param name="path">URL path.</param>
|
||||||
/// <param name="method">HTTP method</param>
|
/// <param name="method">HTTP method.</param>
|
||||||
/// <param name="queryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="postBody">HTTP body (POST request)</param>
|
/// <param name="postBody">HTTP body (POST request).</param>
|
||||||
/// <param name="headerParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="formParams">Form parameters</param>
|
/// <param name="formParams">Form parameters.</param>
|
||||||
/// <param name="fileParams">File parameters</param>
|
/// <param name="fileParams">File parameters.</param>
|
||||||
/// <param name="authSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
/// <returns>Task</returns>
|
/// <returns>The Task instance.</returns>
|
||||||
public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
|
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||||
|
{
|
||||||
|
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
|
||||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||||
|
|
||||||
// add default header, if any
|
// add default header, if any
|
||||||
foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
|
foreach(var defaultHeader in _defaultHeaderMap)
|
||||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||||
|
|
||||||
// add header parameter, if any
|
// add header parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in headerParams)
|
foreach(var param in headerParams)
|
||||||
request.AddHeader(param.Key, param.Value);
|
request.AddHeader(param.Key, param.Value);
|
||||||
|
|
||||||
// add query parameter, if any
|
// add query parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in queryParams)
|
foreach(var param in queryParams)
|
||||||
request.AddQueryParameter(param.Key, param.Value);
|
request.AddQueryParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in formParams)
|
foreach(var param in formParams)
|
||||||
request.AddParameter(param.Key, param.Value);
|
request.AddParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add file parameter, if any
|
// add file parameter, if any
|
||||||
foreach(KeyValuePair<string, FileParameter> param in fileParams)
|
foreach(var param in fileParams)
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||||
|
|
||||||
|
if (postBody != null) // http body (model) parameter
|
||||||
if (postBody != null) {
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Object) await RestClient.ExecuteTaskAsync(request);
|
return (Object) await RestClient.ExecuteTaskAsync(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add default header
|
/// Add default header.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"> Header field name </param>
|
/// <param name="key">Header field name.</param>
|
||||||
/// <param name="value"> Header field value </param>
|
/// <param name="value">Header field value.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void AddDefaultHeader(string key, string value) {
|
public void AddDefaultHeader(string key, string value)
|
||||||
DefaultHeaderMap.Add(key, value);
|
{
|
||||||
|
_defaultHeaderMap.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get default header
|
/// Escape string (url-encoded).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary of default header</returns>
|
/// <param name="str">String to be escaped.</param>
|
||||||
public Dictionary<String, String> GetDefaultHeader() {
|
/// <returns>Escaped string.</returns>
|
||||||
return DefaultHeaderMap;
|
public string EscapeString(string str)
|
||||||
|
{
|
||||||
|
return HttpUtility.UrlEncode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// escape string (url-encoded)
|
/// Create FileParameter based on Stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">String to be escaped</param>
|
/// <param name="name">Parameter name.</param>
|
||||||
/// <returns>Escaped string</returns>
|
/// <param name="stream">Input stream.</param>
|
||||||
public string EscapeString(string str) {
|
/// <returns>FileParameter.</returns>
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create FileParameter based on Stream
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">parameter name</param>
|
|
||||||
/// <param name="stream">Input stream</param>
|
|
||||||
/// <returns>FileParameter</returns>
|
|
||||||
public FileParameter ParameterToFile(string name, Stream stream)
|
public FileParameter ParameterToFile(string name, Stream stream)
|
||||||
{
|
{
|
||||||
if (stream is FileStream) {
|
if (stream is FileStream)
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
||||||
} else {
|
else
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// if parameter is DateTime, output in ISO8601 format
|
/// If parameter is DateTime, output in ISO8601 format.
|
||||||
/// if parameter is a list of string, join the list with ","
|
/// If parameter is a list of string, join the list with ",".
|
||||||
/// otherwise just return the string
|
/// Otherwise just return the string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The parameter (header, path, query, form)</param>
|
/// <param name="obj">The parameter (header, path, query, form).</param>
|
||||||
/// <returns>Formatted string</returns>
|
/// <returns>Formatted string.</returns>
|
||||||
public string ParameterToString(object obj)
|
public string ParameterToString(object obj)
|
||||||
{
|
{
|
||||||
if (obj is DateTime) {
|
if (obj is DateTime)
|
||||||
return ((DateTime)obj).ToString ("u");
|
return ((DateTime)obj).ToString ("u");
|
||||||
} else if (obj is List<string>) {
|
else if (obj is List<string>)
|
||||||
return String.Join(",", obj as List<string>);
|
return String.Join(",", obj as List<string>);
|
||||||
} else {
|
else
|
||||||
return Convert.ToString (obj);
|
return Convert.ToString (obj);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserialize the JSON string into a proper object
|
/// Deserialize the JSON string into a proper object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="content">HTTP body (e.g. string, JSON)</param>
|
/// <param name="content">HTTP body (e.g. string, JSON).</param>
|
||||||
/// <param name="type">Object type</param>
|
/// <param name="type">Object type.</param>
|
||||||
/// <returns>Object representation of the JSON string</returns>
|
/// <returns>Object representation of the JSON string.</returns>
|
||||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
|
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
|
||||||
if (type == typeof(Object)) { // return an object
|
{
|
||||||
|
if (type == typeof(Object)) // return an object
|
||||||
|
{
|
||||||
return (Object)content;
|
return (Object)content;
|
||||||
} else if (type == typeof(Stream)) {
|
} else if (type == typeof(Stream))
|
||||||
|
{
|
||||||
String fileName, filePath;
|
String fileName, filePath;
|
||||||
if (String.IsNullOrEmpty (Configuration.TempFolderPath)) {
|
if (String.IsNullOrEmpty (Configuration.TempFolderPath))
|
||||||
filePath = System.IO.Path.GetTempPath ();
|
filePath = System.IO.Path.GetTempPath ();
|
||||||
} else {
|
else
|
||||||
filePath = Configuration.TempFolderPath;
|
filePath = Configuration.TempFolderPath;
|
||||||
}
|
|
||||||
|
|
||||||
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||||
Match match = regex.Match(headers.ToString());
|
Match match = regex.Match(headers.ToString());
|
||||||
if (match.Success) {
|
if (match.Success) // replace first and last " or ', if found
|
||||||
// replace first and last " or ', if found
|
|
||||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
||||||
} else {
|
else
|
||||||
fileName = filePath + Guid.NewGuid().ToString();
|
fileName = filePath + Guid.NewGuid().ToString();
|
||||||
}
|
|
||||||
File.WriteAllText (fileName, content);
|
File.WriteAllText (fileName, content);
|
||||||
return new FileStream(fileName, FileMode.Open);
|
return new FileStream(fileName, FileMode.Open);
|
||||||
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) { // return a datetime object
|
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||||
|
{
|
||||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||||
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) { // return primitive
|
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||||
|
{
|
||||||
return ConvertType(content, type);
|
return ConvertType(content, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,56 +236,61 @@ namespace {{packageName}}.Client {
|
|||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject(content, type);
|
return JsonConvert.DeserializeObject(content, type);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e)
|
||||||
|
{
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize an object into JSON string
|
/// Serialize an object into JSON string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Object</param>
|
/// <param name="obj">Object.</param>
|
||||||
/// <returns>JSON string</returns>
|
/// <returns>JSON string.</returns>
|
||||||
public string Serialize(object obj) {
|
public string Serialize(object obj)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e)
|
||||||
|
{
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the API key with prefix
|
/// Get the API key with prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Object</param>
|
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
||||||
/// <returns>API key with prefix</returns>
|
/// <returns>API key with prefix.</returns>
|
||||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||||
{
|
{
|
||||||
var apiKeyValue = "";
|
var apiKeyValue = "";
|
||||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
||||||
var apiKeyPrefix = "";
|
var apiKeyPrefix = "";
|
||||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) {
|
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
||||||
return apiKeyPrefix + " " + apiKeyValue;
|
return apiKeyPrefix + " " + apiKeyValue;
|
||||||
} else {
|
else
|
||||||
return apiKeyValue;
|
return apiKeyValue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update parameters based on authentication
|
/// Update parameters based on authentication.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="QueryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="HeaderParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="AuthSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings) {
|
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings)
|
||||||
|
{
|
||||||
if (authSettings == null || authSettings.Length == 0)
|
if (authSettings == null || authSettings.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (string auth in authSettings) {
|
foreach (string auth in authSettings)
|
||||||
|
{
|
||||||
// determine which one to use
|
// determine which one to use
|
||||||
switch(auth) {
|
switch(auth)
|
||||||
|
{
|
||||||
{{#authMethods}}
|
{{#authMethods}}
|
||||||
case "{{name}}":
|
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}}
|
{{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
|
||||||
@ -295,24 +302,26 @@ namespace {{packageName}}.Client {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encode string in base64 format
|
/// Encode string in base64 format.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">String to be encoded</param>
|
/// <param name="text">String to be encoded.</param>
|
||||||
public static string Base64Encode(string text) {
|
/// <returns>Encoded string.</returns>
|
||||||
|
public static string Base64Encode(string text)
|
||||||
|
{
|
||||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||||
return System.Convert.ToBase64String(textByte);
|
return System.Convert.ToBase64String(textByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dynamically cast the object into target type
|
/// Dynamically cast the object into target type.
|
||||||
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dynamic">Object to be casted</param>
|
/// <param name="source">Object to be casted</param>
|
||||||
/// <param name="dest">Target type</param>
|
/// <param name="dest">Target type</param>
|
||||||
|
/// <returns>Casted object</returns>
|
||||||
public static dynamic ConvertType(dynamic source, Type dest) {
|
public static dynamic ConvertType(dynamic source, Type dest) {
|
||||||
return Convert.ChangeType(source, dest);
|
return Convert.ChangeType(source, dest);
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,20 @@ using System.Reflection;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace {{packageName}}.Client {
|
namespace {{packageName}}.Client
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a set of configuration settings
|
/// Represents a set of configuration settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Configuration{
|
public class Configuration
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the package
|
/// Version of the package.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>Version of the package.</value>
|
||||||
public const string Version = "{{packageVersion}}";
|
public const string Version = "{{packageVersion}}";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -24,25 +26,25 @@ namespace {{packageName}}.Client {
|
|||||||
public static ApiClient DefaultApiClient = new ApiClient();
|
public static ApiClient DefaultApiClient = new ApiClient();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the username (HTTP basic authentication)
|
/// Gets or sets the username (HTTP basic authentication).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The username.</value>
|
/// <value>The username.</value>
|
||||||
public static String Username { get; set; }
|
public static String Username { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the password (HTTP basic authentication)
|
/// Gets or sets the password (HTTP basic authentication).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The password.</value>
|
/// <value>The password.</value>
|
||||||
public static String Password { get; set; }
|
public static String Password { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API key based on the authentication name
|
/// Gets or sets the API key based on the authentication name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API key.</value>
|
/// <value>The API key.</value>
|
||||||
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
|
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The prefix of the API key.</value>
|
/// <value>The prefix of the API key.</value>
|
||||||
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
||||||
@ -50,46 +52,46 @@ namespace {{packageName}}.Client {
|
|||||||
private static string _tempFolderPath = Path.GetTempPath();
|
private static string _tempFolderPath = Path.GetTempPath();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the temporary folder path to store the files downloaded from the server
|
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Folder path</value>
|
/// <value>Folder path.</value>
|
||||||
public static String TempFolderPath {
|
public static String TempFolderPath
|
||||||
get {
|
{
|
||||||
return _tempFolderPath;
|
get { return _tempFolderPath; }
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
set
|
||||||
if (String.IsNullOrEmpty(value)) {
|
{
|
||||||
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
_tempFolderPath = value;
|
_tempFolderPath = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the directory if it does not exist
|
// create the directory if it does not exist
|
||||||
if (!Directory.Exists(value)) {
|
if (!Directory.Exists(value))
|
||||||
Directory.CreateDirectory(value);
|
Directory.CreateDirectory(value);
|
||||||
}
|
|
||||||
|
|
||||||
// check if the path contains directory separator at the end
|
// check if the path contains directory separator at the end
|
||||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
|
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
||||||
_tempFolderPath = value;
|
_tempFolderPath = value;
|
||||||
} else {
|
else
|
||||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a string contain essential information for debugging
|
/// Returns a string with essential information for debugging.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Folder path</value>
|
/// <value>Debugging Report</value>
|
||||||
public static String ToDebugReport() {
|
public static String ToDebugReport()
|
||||||
|
{
|
||||||
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
|
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
|
||||||
report += " OS: " + Environment.OSVersion + "\n";
|
report += " OS: " + Environment.OSVersion + "\n";
|
||||||
report += " .NET Framework Version: " + Assembly
|
report += " .NET Framework Version: " + Assembly
|
||||||
.GetExecutingAssembly()
|
.GetExecutingAssembly()
|
||||||
.GetReferencedAssemblies()
|
.GetReferencedAssemblies()
|
||||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
||||||
report += " Swagger Spec Version: {{version}}\n";
|
report += " Version of the API: {{version}}\n";
|
||||||
report += " SDK Package Version: {{packageVersion}}\n";
|
report += " SDK Package Version: {{packageVersion}}\n";
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
|
@ -7,9 +7,11 @@ using {{packageName}}.Client;
|
|||||||
{{#hasImport}}using {{packageName}}.Model;
|
{{#hasImport}}using {{packageName}}.Model;
|
||||||
{{/hasImport}}
|
{{/hasImport}}
|
||||||
|
|
||||||
namespace {{packageName}}.Api {
|
namespace {{packageName}}.Api
|
||||||
|
{
|
||||||
{{#operations}}
|
{{#operations}}
|
||||||
public interface I{{classname}} {
|
public interface I{{classname}}
|
||||||
|
{
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// {{summary}} {{notes}}
|
/// {{summary}} {{notes}}
|
||||||
@ -30,19 +32,19 @@ namespace {{packageName}}.Api {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class {{classname}} : I{{classname}} {
|
public class {{classname}} : I{{classname}}
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
/// Initializes a new instance of the <see cref="{{classname}}"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public {{classname}}(ApiClient apiClient = null) {
|
public {{classname}}(ApiClient apiClient = null)
|
||||||
if (apiClient == null) { // use the default one in Configuration
|
{
|
||||||
|
if (apiClient == null) // use the default one in Configuration
|
||||||
this.ApiClient = Configuration.DefaultApiClient;
|
this.ApiClient = Configuration.DefaultApiClient;
|
||||||
} else {
|
else
|
||||||
this.ApiClient = apiClient;
|
this.ApiClient = apiClient;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -58,7 +60,8 @@ namespace {{packageName}}.Api {
|
|||||||
/// Sets the base path of the API client.
|
/// Sets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public void SetBasePath(String basePath) {
|
public void SetBasePath(String basePath)
|
||||||
|
{
|
||||||
this.ApiClient.BasePath = basePath;
|
this.ApiClient.BasePath = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +69,15 @@ namespace {{packageName}}.Api {
|
|||||||
/// Gets the base path of the API client.
|
/// Gets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public String GetBasePath(String basePath) {
|
public String GetBasePath(String basePath)
|
||||||
|
{
|
||||||
return this.ApiClient.BasePath;
|
return this.ApiClient.BasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API client.
|
/// Gets or sets the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient {get; set;}
|
public ApiClient ApiClient {get; set;}
|
||||||
|
|
||||||
{{#operation}}
|
{{#operation}}
|
||||||
@ -82,8 +86,8 @@ namespace {{packageName}}.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
|
{
|
||||||
{{#allParams}}{{#required}}
|
{{#allParams}}{{#required}}
|
||||||
// verify the required parameter '{{paramName}}' is set
|
// verify the required parameter '{{paramName}}' is set
|
||||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||||
@ -115,11 +119,10 @@ namespace {{packageName}}.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
|
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}}
|
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}return;{{/returnType}}
|
||||||
}
|
}
|
||||||
@ -129,7 +132,8 @@ namespace {{packageName}}.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||||
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
|
||||||
{{#returnType}}public async Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
{{#returnType}}public async Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||||
|
{
|
||||||
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
|
||||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||||
{{/required}}{{/allParams}}
|
{{/required}}{{/allParams}}
|
||||||
@ -159,9 +163,9 @@ namespace {{packageName}}.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
|
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}}
|
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}), response.Headers);{{/returnType}}{{^returnType}}
|
||||||
return;{{/returnType}}
|
return;{{/returnType}}
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ using RestSharp;
|
|||||||
using IO.Swagger.Client;
|
using IO.Swagger.Client;
|
||||||
using IO.Swagger.Model;
|
using IO.Swagger.Model;
|
||||||
|
|
||||||
namespace IO.Swagger.Api {
|
namespace IO.Swagger.Api
|
||||||
|
{
|
||||||
|
|
||||||
public interface IPetApi {
|
public interface IPetApi
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update an existing pet
|
/// Update an existing pet
|
||||||
@ -137,19 +139,19 @@ namespace IO.Swagger.Api {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class PetApi : IPetApi {
|
public class PetApi : IPetApi
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="PetApi"/> class.
|
/// Initializes a new instance of the <see cref="PetApi"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public PetApi(ApiClient apiClient = null) {
|
public PetApi(ApiClient apiClient = null)
|
||||||
if (apiClient == null) { // use the default one in Configuration
|
{
|
||||||
|
if (apiClient == null) // use the default one in Configuration
|
||||||
this.ApiClient = Configuration.DefaultApiClient;
|
this.ApiClient = Configuration.DefaultApiClient;
|
||||||
} else {
|
else
|
||||||
this.ApiClient = apiClient;
|
this.ApiClient = apiClient;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -165,7 +167,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Sets the base path of the API client.
|
/// Sets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public void SetBasePath(String basePath) {
|
public void SetBasePath(String basePath)
|
||||||
|
{
|
||||||
this.ApiClient.BasePath = basePath;
|
this.ApiClient.BasePath = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,14 +176,15 @@ namespace IO.Swagger.Api {
|
|||||||
/// Gets the base path of the API client.
|
/// Gets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public String GetBasePath(String basePath) {
|
public String GetBasePath(String basePath)
|
||||||
|
{
|
||||||
return this.ApiClient.BasePath;
|
return this.ApiClient.BasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API client.
|
/// Gets or sets the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient {get; set;}
|
public ApiClient ApiClient {get; set;}
|
||||||
|
|
||||||
|
|
||||||
@ -189,8 +193,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void UpdatePet (Pet body) {
|
public void UpdatePet (Pet body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet";
|
var path = "/pet";
|
||||||
@ -215,11 +219,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -229,7 +232,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UpdatePetAsync (Pet body) {
|
public async Task UpdatePetAsync (Pet body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet";
|
var path = "/pet";
|
||||||
@ -253,9 +257,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -265,8 +269,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void AddPet (Pet body) {
|
public void AddPet (Pet body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet";
|
var path = "/pet";
|
||||||
@ -291,11 +295,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -305,7 +308,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task AddPetAsync (Pet body) {
|
public async Task AddPetAsync (Pet body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet";
|
var path = "/pet";
|
||||||
@ -329,9 +333,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -341,8 +345,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="status">Status values that need to be considered for filter</param>
|
/// <param name="status">Status values that need to be considered for filter</param>
|
||||||
/// <returns>List<Pet></returns>
|
/// <returns>List<Pet></returns>
|
||||||
public List<Pet> FindPetsByStatus (List<string> status) {
|
public List<Pet> FindPetsByStatus (List<string> status)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet/findByStatus";
|
var path = "/pet/findByStatus";
|
||||||
@ -367,11 +371,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
||||||
}
|
}
|
||||||
@ -381,7 +384,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="status">Status values that need to be considered for filter</param>
|
/// <param name="status">Status values that need to be considered for filter</param>
|
||||||
/// <returns>List<Pet></returns>
|
/// <returns>List<Pet></returns>
|
||||||
public async Task<List<Pet>> FindPetsByStatusAsync (List<string> status) {
|
public async Task<List<Pet>> FindPetsByStatusAsync (List<string> status)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet/findByStatus";
|
var path = "/pet/findByStatus";
|
||||||
@ -405,9 +409,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,8 +420,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tags">Tags to filter by</param>
|
/// <param name="tags">Tags to filter by</param>
|
||||||
/// <returns>List<Pet></returns>
|
/// <returns>List<Pet></returns>
|
||||||
public List<Pet> FindPetsByTags (List<string> tags) {
|
public List<Pet> FindPetsByTags (List<string> tags)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet/findByTags";
|
var path = "/pet/findByTags";
|
||||||
@ -442,11 +446,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
||||||
}
|
}
|
||||||
@ -456,7 +459,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="tags">Tags to filter by</param>
|
/// <param name="tags">Tags to filter by</param>
|
||||||
/// <returns>List<Pet></returns>
|
/// <returns>List<Pet></returns>
|
||||||
public async Task<List<Pet>> FindPetsByTagsAsync (List<string> tags) {
|
public async Task<List<Pet>> FindPetsByTagsAsync (List<string> tags)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/pet/findByTags";
|
var path = "/pet/findByTags";
|
||||||
@ -480,9 +484,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -491,8 +495,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="petId">ID of pet that needs to be fetched</param>
|
/// <param name="petId">ID of pet that needs to be fetched</param>
|
||||||
/// <returns>Pet</returns>
|
/// <returns>Pet</returns>
|
||||||
public Pet GetPetById (long? petId) {
|
public Pet GetPetById (long? petId)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
|
||||||
@ -520,11 +524,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
|
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
|
||||||
}
|
}
|
||||||
@ -534,7 +537,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="petId">ID of pet that needs to be fetched</param>
|
/// <param name="petId">ID of pet that needs to be fetched</param>
|
||||||
/// <returns>Pet</returns>
|
/// <returns>Pet</returns>
|
||||||
public async Task<Pet> GetPetByIdAsync (long? petId) {
|
public async Task<Pet> GetPetByIdAsync (long? petId)
|
||||||
|
{
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
|
||||||
|
|
||||||
@ -560,9 +564,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
|
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,8 +577,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="name">Updated name of the pet</param>
|
/// <param name="name">Updated name of the pet</param>
|
||||||
/// <param name="status">Updated status of the pet</param>
|
/// <param name="status">Updated status of the pet</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void UpdatePetWithForm (string petId, string name, string status) {
|
public void UpdatePetWithForm (string petId, string name, string status)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
||||||
@ -604,11 +608,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -620,7 +623,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="name">Updated name of the pet</param>
|
/// <param name="name">Updated name of the pet</param>
|
||||||
/// <param name="status">Updated status of the pet</param>
|
/// <param name="status">Updated status of the pet</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UpdatePetWithFormAsync (string petId, string name, string status) {
|
public async Task UpdatePetWithFormAsync (string petId, string name, string status)
|
||||||
|
{
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
||||||
|
|
||||||
@ -648,9 +652,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -661,8 +665,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="apiKey"></param>
|
/// <param name="apiKey"></param>
|
||||||
/// <param name="petId">Pet id to delete</param>
|
/// <param name="petId">Pet id to delete</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void DeletePet (string apiKey, long? petId) {
|
public void DeletePet (string apiKey, long? petId)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
||||||
@ -691,11 +695,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -706,7 +709,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="apiKey"></param>
|
/// <param name="apiKey"></param>
|
||||||
/// <param name="petId">Pet id to delete</param>
|
/// <param name="petId">Pet id to delete</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task DeletePetAsync (string apiKey, long? petId) {
|
public async Task DeletePetAsync (string apiKey, long? petId)
|
||||||
|
{
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
||||||
|
|
||||||
@ -733,9 +737,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -747,8 +751,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||||
/// <param name="file">file to upload</param>
|
/// <param name="file">file to upload</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void UploadFile (long? petId, string additionalMetadata, Stream file) {
|
public void UploadFile (long? petId, string additionalMetadata, Stream file)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
||||||
@ -778,11 +782,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -794,7 +797,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||||
/// <param name="file">file to upload</param>
|
/// <param name="file">file to upload</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UploadFileAsync (long? petId, string additionalMetadata, Stream file) {
|
public async Task UploadFileAsync (long? petId, string additionalMetadata, Stream file)
|
||||||
|
{
|
||||||
// verify the required parameter 'petId' is set
|
// verify the required parameter 'petId' is set
|
||||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
||||||
|
|
||||||
@ -822,9 +826,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ using RestSharp;
|
|||||||
using IO.Swagger.Client;
|
using IO.Swagger.Client;
|
||||||
using IO.Swagger.Model;
|
using IO.Swagger.Model;
|
||||||
|
|
||||||
namespace IO.Swagger.Api {
|
namespace IO.Swagger.Api
|
||||||
|
{
|
||||||
|
|
||||||
public interface IStoreApi {
|
public interface IStoreApi
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||||
@ -69,19 +71,19 @@ namespace IO.Swagger.Api {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class StoreApi : IStoreApi {
|
public class StoreApi : IStoreApi
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
/// Initializes a new instance of the <see cref="StoreApi"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public StoreApi(ApiClient apiClient = null) {
|
public StoreApi(ApiClient apiClient = null)
|
||||||
if (apiClient == null) { // use the default one in Configuration
|
{
|
||||||
|
if (apiClient == null) // use the default one in Configuration
|
||||||
this.ApiClient = Configuration.DefaultApiClient;
|
this.ApiClient = Configuration.DefaultApiClient;
|
||||||
} else {
|
else
|
||||||
this.ApiClient = apiClient;
|
this.ApiClient = apiClient;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -97,7 +99,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Sets the base path of the API client.
|
/// Sets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public void SetBasePath(String basePath) {
|
public void SetBasePath(String basePath)
|
||||||
|
{
|
||||||
this.ApiClient.BasePath = basePath;
|
this.ApiClient.BasePath = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,14 +108,15 @@ namespace IO.Swagger.Api {
|
|||||||
/// Gets the base path of the API client.
|
/// Gets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public String GetBasePath(String basePath) {
|
public String GetBasePath(String basePath)
|
||||||
|
{
|
||||||
return this.ApiClient.BasePath;
|
return this.ApiClient.BasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API client.
|
/// Gets or sets the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient {get; set;}
|
public ApiClient ApiClient {get; set;}
|
||||||
|
|
||||||
|
|
||||||
@ -120,8 +124,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary<String, int?></returns>
|
/// <returns>Dictionary<String, int?></returns>
|
||||||
public Dictionary<String, int?> GetInventory () {
|
public Dictionary<String, int?> GetInventory ()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/store/inventory";
|
var path = "/store/inventory";
|
||||||
@ -145,11 +149,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
||||||
}
|
}
|
||||||
@ -158,7 +161,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary<String, int?></returns>
|
/// <returns>Dictionary<String, int?></returns>
|
||||||
public async Task<Dictionary<String, int?>> GetInventoryAsync () {
|
public async Task<Dictionary<String, int?>> GetInventoryAsync ()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/store/inventory";
|
var path = "/store/inventory";
|
||||||
@ -181,9 +185,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,8 +196,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">order placed for purchasing the pet</param>
|
/// <param name="body">order placed for purchasing the pet</param>
|
||||||
/// <returns>Order</returns>
|
/// <returns>Order</returns>
|
||||||
public Order PlaceOrder (Order body) {
|
public Order PlaceOrder (Order body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/store/order";
|
var path = "/store/order";
|
||||||
@ -218,11 +222,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||||
}
|
}
|
||||||
@ -232,7 +235,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">order placed for purchasing the pet</param>
|
/// <param name="body">order placed for purchasing the pet</param>
|
||||||
/// <returns>Order</returns>
|
/// <returns>Order</returns>
|
||||||
public async Task<Order> PlaceOrderAsync (Order body) {
|
public async Task<Order> PlaceOrderAsync (Order body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/store/order";
|
var path = "/store/order";
|
||||||
@ -256,9 +260,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,8 +271,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||||
/// <returns>Order</returns>
|
/// <returns>Order</returns>
|
||||||
public Order GetOrderById (string orderId) {
|
public Order GetOrderById (string orderId)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
||||||
@ -296,11 +300,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||||
}
|
}
|
||||||
@ -310,7 +313,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||||
/// <returns>Order</returns>
|
/// <returns>Order</returns>
|
||||||
public async Task<Order> GetOrderByIdAsync (string orderId) {
|
public async Task<Order> GetOrderByIdAsync (string orderId)
|
||||||
|
{
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
||||||
|
|
||||||
@ -336,9 +340,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
return (Order) ApiClient.Deserialize(response.Content, typeof(Order), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,8 +351,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void DeleteOrder (string orderId) {
|
public void DeleteOrder (string orderId)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
||||||
@ -376,11 +380,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -390,7 +393,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task DeleteOrderAsync (string orderId) {
|
public async Task DeleteOrderAsync (string orderId)
|
||||||
|
{
|
||||||
// verify the required parameter 'orderId' is set
|
// verify the required parameter 'orderId' is set
|
||||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
||||||
|
|
||||||
@ -416,9 +420,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -6,9 +6,11 @@ using RestSharp;
|
|||||||
using IO.Swagger.Client;
|
using IO.Swagger.Client;
|
||||||
using IO.Swagger.Model;
|
using IO.Swagger.Model;
|
||||||
|
|
||||||
namespace IO.Swagger.Api {
|
namespace IO.Swagger.Api
|
||||||
|
{
|
||||||
|
|
||||||
public interface IUserApi {
|
public interface IUserApi
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create user This can only be done by the logged in user.
|
/// Create user This can only be done by the logged in user.
|
||||||
@ -129,19 +131,19 @@ namespace IO.Swagger.Api {
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a collection of functions to interact with the API endpoints
|
/// Represents a collection of functions to interact with the API endpoints
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class UserApi : IUserApi {
|
public class UserApi : IUserApi
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="UserApi"/> class.
|
/// Initializes a new instance of the <see cref="UserApi"/> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
/// <param name="apiClient"> an instance of ApiClient (optional)</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public UserApi(ApiClient apiClient = null) {
|
public UserApi(ApiClient apiClient = null)
|
||||||
if (apiClient == null) { // use the default one in Configuration
|
{
|
||||||
|
if (apiClient == null) // use the default one in Configuration
|
||||||
this.ApiClient = Configuration.DefaultApiClient;
|
this.ApiClient = Configuration.DefaultApiClient;
|
||||||
} else {
|
else
|
||||||
this.ApiClient = apiClient;
|
this.ApiClient = apiClient;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -157,7 +159,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Sets the base path of the API client.
|
/// Sets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public void SetBasePath(String basePath) {
|
public void SetBasePath(String basePath)
|
||||||
|
{
|
||||||
this.ApiClient.BasePath = basePath;
|
this.ApiClient.BasePath = basePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,14 +168,15 @@ namespace IO.Swagger.Api {
|
|||||||
/// Gets the base path of the API client.
|
/// Gets the base path of the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path</value>
|
/// <value>The base path</value>
|
||||||
public String GetBasePath(String basePath) {
|
public String GetBasePath(String basePath)
|
||||||
|
{
|
||||||
return this.ApiClient.BasePath;
|
return this.ApiClient.BasePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API client.
|
/// Gets or sets the API client.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API client</value>
|
/// <value>The API client.</value>
|
||||||
public ApiClient ApiClient {get; set;}
|
public ApiClient ApiClient {get; set;}
|
||||||
|
|
||||||
|
|
||||||
@ -181,8 +185,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Created user object</param>
|
/// <param name="body">Created user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void CreateUser (User body) {
|
public void CreateUser (User body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user";
|
var path = "/user";
|
||||||
@ -207,11 +211,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -221,7 +224,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">Created user object</param>
|
/// <param name="body">Created user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CreateUserAsync (User body) {
|
public async Task CreateUserAsync (User body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user";
|
var path = "/user";
|
||||||
@ -245,9 +249,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -257,8 +261,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">List of user object</param>
|
/// <param name="body">List of user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void CreateUsersWithArrayInput (List<User> body) {
|
public void CreateUsersWithArrayInput (List<User> body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/createWithArray";
|
var path = "/user/createWithArray";
|
||||||
@ -283,11 +287,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -297,7 +300,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">List of user object</param>
|
/// <param name="body">List of user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CreateUsersWithArrayInputAsync (List<User> body) {
|
public async Task CreateUsersWithArrayInputAsync (List<User> body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/createWithArray";
|
var path = "/user/createWithArray";
|
||||||
@ -321,9 +325,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -333,8 +337,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">List of user object</param>
|
/// <param name="body">List of user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void CreateUsersWithListInput (List<User> body) {
|
public void CreateUsersWithListInput (List<User> body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/createWithList";
|
var path = "/user/createWithList";
|
||||||
@ -359,11 +363,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -373,7 +376,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="body">List of user object</param>
|
/// <param name="body">List of user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task CreateUsersWithListInputAsync (List<User> body) {
|
public async Task CreateUsersWithListInputAsync (List<User> body)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/createWithList";
|
var path = "/user/createWithList";
|
||||||
@ -397,9 +401,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -410,8 +414,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="username">The user name for login</param>
|
/// <param name="username">The user name for login</param>
|
||||||
/// <param name="password">The password for login in clear text</param>
|
/// <param name="password">The password for login in clear text</param>
|
||||||
/// <returns>string</returns>
|
/// <returns>string</returns>
|
||||||
public string LoginUser (string username, string password) {
|
public string LoginUser (string username, string password)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/login";
|
var path = "/user/login";
|
||||||
@ -437,11 +441,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (string) ApiClient.Deserialize(response.Content, typeof(string), response.Headers);
|
return (string) ApiClient.Deserialize(response.Content, typeof(string), response.Headers);
|
||||||
}
|
}
|
||||||
@ -452,7 +455,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="username">The user name for login</param>
|
/// <param name="username">The user name for login</param>
|
||||||
/// <param name="password">The password for login in clear text</param>
|
/// <param name="password">The password for login in clear text</param>
|
||||||
/// <returns>string</returns>
|
/// <returns>string</returns>
|
||||||
public async Task<string> LoginUserAsync (string username, string password) {
|
public async Task<string> LoginUserAsync (string username, string password)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/login";
|
var path = "/user/login";
|
||||||
@ -477,9 +481,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (string) ApiClient.Deserialize(response.Content, typeof(string), response.Headers);
|
return (string) ApiClient.Deserialize(response.Content, typeof(string), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,8 +491,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Logs out current logged in user session
|
/// Logs out current logged in user session
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void LogoutUser () {
|
public void LogoutUser ()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/logout";
|
var path = "/user/logout";
|
||||||
@ -512,11 +516,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -525,7 +528,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// Logs out current logged in user session
|
/// Logs out current logged in user session
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task LogoutUserAsync () {
|
public async Task LogoutUserAsync ()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
var path = "/user/logout";
|
var path = "/user/logout";
|
||||||
@ -548,9 +552,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -560,8 +564,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
||||||
/// <returns>User</returns>
|
/// <returns>User</returns>
|
||||||
public User GetUserByName (string username) {
|
public User GetUserByName (string username)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
|
||||||
@ -589,11 +593,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return (User) ApiClient.Deserialize(response.Content, typeof(User), response.Headers);
|
return (User) ApiClient.Deserialize(response.Content, typeof(User), response.Headers);
|
||||||
}
|
}
|
||||||
@ -603,7 +606,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
||||||
/// <returns>User</returns>
|
/// <returns>User</returns>
|
||||||
public async Task<User> GetUserByNameAsync (string username) {
|
public async Task<User> GetUserByNameAsync (string username)
|
||||||
|
{
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
|
||||||
|
|
||||||
@ -629,9 +633,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
return (User) ApiClient.Deserialize(response.Content, typeof(User), response.Headers);
|
return (User) ApiClient.Deserialize(response.Content, typeof(User), response.Headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -641,8 +645,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="username">name that need to be deleted</param>
|
/// <param name="username">name that need to be deleted</param>
|
||||||
/// <param name="body">Updated user object</param>
|
/// <param name="body">Updated user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void UpdateUser (string username, User body) {
|
public void UpdateUser (string username, User body)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
||||||
@ -671,11 +675,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -686,7 +689,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// <param name="username">name that need to be deleted</param>
|
/// <param name="username">name that need to be deleted</param>
|
||||||
/// <param name="body">Updated user object</param>
|
/// <param name="body">Updated user object</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task UpdateUserAsync (string username, User body) {
|
public async Task UpdateUserAsync (string username, User body)
|
||||||
|
{
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
||||||
|
|
||||||
@ -713,9 +717,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -725,8 +729,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="username">The name that needs to be deleted</param>
|
/// <param name="username">The name that needs to be deleted</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void DeleteUser (string username) {
|
public void DeleteUser (string username)
|
||||||
|
{
|
||||||
|
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
|
||||||
@ -754,11 +758,10 @@ namespace IO.Swagger.Api {
|
|||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
|
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
|
||||||
} else if (((int)response.StatusCode) == 0) {
|
else if (((int)response.StatusCode) == 0)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -768,7 +771,8 @@ namespace IO.Swagger.Api {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="username">The name that needs to be deleted</param>
|
/// <param name="username">The name that needs to be deleted</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task DeleteUserAsync (string username) {
|
public async Task DeleteUserAsync (string username)
|
||||||
|
{
|
||||||
// verify the required parameter 'username' is set
|
// verify the required parameter 'username' is set
|
||||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
|
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
|
||||||
|
|
||||||
@ -794,9 +798,9 @@ namespace IO.Swagger.Api {
|
|||||||
|
|
||||||
// make the HTTP request
|
// make the HTTP request
|
||||||
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||||
if (((int)response.StatusCode) >= 400) {
|
if (((int)response.StatusCode) >= 400)
|
||||||
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
|
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Web;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -10,222 +12,222 @@ using Newtonsoft.Json;
|
|||||||
using RestSharp;
|
using RestSharp;
|
||||||
using RestSharp.Extensions;
|
using RestSharp.Extensions;
|
||||||
|
|
||||||
namespace IO.Swagger.Client {
|
namespace IO.Swagger.Client
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 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.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ApiClient {
|
public class ApiClient
|
||||||
|
{
|
||||||
|
private readonly Dictionary<String, String> _defaultHeaderMap = new Dictionary<String, String>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initializes a new instance of the <see cref="ApiClient"/> class.
|
/// Initializes a new instance of the <see cref="ApiClient" /> class.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="basePath">The base path.</param>
|
/// <param name="basePath">The base path.</param>
|
||||||
public ApiClient(String basePath="http://petstore.swagger.io/v2") {
|
public ApiClient(String basePath="http://petstore.swagger.io/v2")
|
||||||
this.BasePath = basePath;
|
{
|
||||||
this.RestClient = new RestClient(this.BasePath);
|
BasePath = basePath;
|
||||||
|
RestClient = new RestClient(BasePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the base path.
|
/// Gets or sets the base path.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The base path.</value>
|
|
||||||
public string BasePath { get; set; }
|
public string BasePath { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the RestClient
|
/// Gets or sets the RestClient.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The RestClient.</value>
|
|
||||||
public RestClient RestClient { get; set; }
|
public RestClient RestClient { get; set; }
|
||||||
|
|
||||||
private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
|
/// <summary>
|
||||||
|
/// Gets the default header.
|
||||||
|
/// </summary>
|
||||||
|
public Dictionary<String, String> DefaultHeader
|
||||||
|
{
|
||||||
|
get { return _defaultHeaderMap; }
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make the HTTP request (Sync)
|
/// Makes the HTTP request (Sync).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">URL path</param>
|
/// <param name="path">URL path.</param>
|
||||||
/// <param name="method">HTTP method</param>
|
/// <param name="method">HTTP method.</param>
|
||||||
/// <param name="queryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="postBody">HTTP body (POST request)</param>
|
/// <param name="postBody">HTTP body (POST request).</param>
|
||||||
/// <param name="headerParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="formParams">Form parameters</param>
|
/// <param name="formParams">Form parameters.</param>
|
||||||
/// <param name="fileParams">File parameters</param>
|
/// <param name="fileParams">File parameters.</param>
|
||||||
/// <param name="authSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
/// <returns>Object</returns>
|
/// <returns>Object</returns>
|
||||||
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
public Object CallApi(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
Dictionary<String, String> headerParams, Dictionary<String, String> formParams,
|
||||||
Dictionary<String, FileParameter> fileParams, String[] authSettings) {
|
Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||||
|
{
|
||||||
|
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
|
||||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||||
|
|
||||||
// add default header, if any
|
// add default header, if any
|
||||||
foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
|
foreach(var defaultHeader in _defaultHeaderMap)
|
||||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||||
|
|
||||||
// add header parameter, if any
|
// add header parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in headerParams)
|
foreach(var param in headerParams)
|
||||||
request.AddHeader(param.Key, param.Value);
|
request.AddHeader(param.Key, param.Value);
|
||||||
|
|
||||||
// add query parameter, if any
|
// add query parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in queryParams)
|
foreach(var param in queryParams)
|
||||||
request.AddQueryParameter(param.Key, param.Value);
|
request.AddQueryParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in formParams)
|
foreach(var param in formParams)
|
||||||
request.AddParameter(param.Key, param.Value);
|
request.AddParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add file parameter, if any
|
// add file parameter, if any
|
||||||
foreach(KeyValuePair<string, FileParameter> param in fileParams)
|
foreach(var param in fileParams)
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||||
|
|
||||||
|
if (postBody != null) // http body (model) parameter
|
||||||
if (postBody != null) {
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Object)RestClient.Execute(request);
|
return (Object)RestClient.Execute(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Make the HTTP request (Async)
|
/// Makes the asynchronous HTTP request.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="path">URL path</param>
|
/// <param name="path">URL path.</param>
|
||||||
/// <param name="method">HTTP method</param>
|
/// <param name="method">HTTP method.</param>
|
||||||
/// <param name="queryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="postBody">HTTP body (POST request)</param>
|
/// <param name="postBody">HTTP body (POST request).</param>
|
||||||
/// <param name="headerParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="formParams">Form parameters</param>
|
/// <param name="formParams">Form parameters.</param>
|
||||||
/// <param name="fileParams">File parameters</param>
|
/// <param name="fileParams">File parameters.</param>
|
||||||
/// <param name="authSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
/// <returns>Task</returns>
|
/// <returns>The Task instance.</returns>
|
||||||
public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
public async Task<Object> CallApiAsync(String path, RestSharp.Method method, Dictionary<String, String> queryParams, String postBody,
|
||||||
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings) {
|
Dictionary<String, String> headerParams, Dictionary<String, String> formParams, Dictionary<String, FileParameter> fileParams, String[] authSettings)
|
||||||
|
{
|
||||||
|
|
||||||
var request = new RestRequest(path, method);
|
var request = new RestRequest(path, method);
|
||||||
|
|
||||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||||
|
|
||||||
// add default header, if any
|
// add default header, if any
|
||||||
foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
|
foreach(var defaultHeader in _defaultHeaderMap)
|
||||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||||
|
|
||||||
// add header parameter, if any
|
// add header parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in headerParams)
|
foreach(var param in headerParams)
|
||||||
request.AddHeader(param.Key, param.Value);
|
request.AddHeader(param.Key, param.Value);
|
||||||
|
|
||||||
// add query parameter, if any
|
// add query parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in queryParams)
|
foreach(var param in queryParams)
|
||||||
request.AddQueryParameter(param.Key, param.Value);
|
request.AddQueryParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add form parameter, if any
|
// add form parameter, if any
|
||||||
foreach(KeyValuePair<string, string> param in formParams)
|
foreach(var param in formParams)
|
||||||
request.AddParameter(param.Key, param.Value);
|
request.AddParameter(param.Key, param.Value);
|
||||||
|
|
||||||
// add file parameter, if any
|
// add file parameter, if any
|
||||||
foreach(KeyValuePair<string, FileParameter> param in fileParams)
|
foreach(var param in fileParams)
|
||||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||||
|
|
||||||
|
if (postBody != null) // http body (model) parameter
|
||||||
if (postBody != null) {
|
request.AddParameter("application/json", postBody, ParameterType.RequestBody);
|
||||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Object) await RestClient.ExecuteTaskAsync(request);
|
return (Object) await RestClient.ExecuteTaskAsync(request);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Add default header
|
/// Add default header.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="key"> Header field name </param>
|
/// <param name="key">Header field name.</param>
|
||||||
/// <param name="value"> Header field value </param>
|
/// <param name="value">Header field value.</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void AddDefaultHeader(string key, string value) {
|
public void AddDefaultHeader(string key, string value)
|
||||||
DefaultHeaderMap.Add(key, value);
|
{
|
||||||
|
_defaultHeaderMap.Add(key, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get default header
|
/// Escape string (url-encoded).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>Dictionary of default header</returns>
|
/// <param name="str">String to be escaped.</param>
|
||||||
public Dictionary<String, String> GetDefaultHeader() {
|
/// <returns>Escaped string.</returns>
|
||||||
return DefaultHeaderMap;
|
public string EscapeString(string str)
|
||||||
|
{
|
||||||
|
return HttpUtility.UrlEncode(str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// escape string (url-encoded)
|
/// Create FileParameter based on Stream.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="str">String to be escaped</param>
|
/// <param name="name">Parameter name.</param>
|
||||||
/// <returns>Escaped string</returns>
|
/// <param name="stream">Input stream.</param>
|
||||||
public string EscapeString(string str) {
|
/// <returns>FileParameter.</returns>
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Create FileParameter based on Stream
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="name">parameter name</param>
|
|
||||||
/// <param name="stream">Input stream</param>
|
|
||||||
/// <returns>FileParameter</returns>
|
|
||||||
public FileParameter ParameterToFile(string name, Stream stream)
|
public FileParameter ParameterToFile(string name, Stream stream)
|
||||||
{
|
{
|
||||||
if (stream is FileStream) {
|
if (stream is FileStream)
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
return FileParameter.Create(name, stream.ReadAsBytes(), Path.GetFileName(((FileStream)stream).Name));
|
||||||
} else {
|
else
|
||||||
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
return FileParameter.Create(name, stream.ReadAsBytes(), "no_file_name_provided");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// if parameter is DateTime, output in ISO8601 format
|
/// If parameter is DateTime, output in ISO8601 format.
|
||||||
/// if parameter is a list of string, join the list with ","
|
/// If parameter is a list of string, join the list with ",".
|
||||||
/// otherwise just return the string
|
/// Otherwise just return the string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">The parameter (header, path, query, form)</param>
|
/// <param name="obj">The parameter (header, path, query, form).</param>
|
||||||
/// <returns>Formatted string</returns>
|
/// <returns>Formatted string.</returns>
|
||||||
public string ParameterToString(object obj)
|
public string ParameterToString(object obj)
|
||||||
{
|
{
|
||||||
if (obj is DateTime) {
|
if (obj is DateTime)
|
||||||
return ((DateTime)obj).ToString ("u");
|
return ((DateTime)obj).ToString ("u");
|
||||||
} else if (obj is List<string>) {
|
else if (obj is List<string>)
|
||||||
return String.Join(",", obj as List<string>);
|
return String.Join(",", obj as List<string>);
|
||||||
} else {
|
else
|
||||||
return Convert.ToString (obj);
|
return Convert.ToString (obj);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Deserialize the JSON string into a proper object
|
/// Deserialize the JSON string into a proper object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="content">HTTP body (e.g. string, JSON)</param>
|
/// <param name="content">HTTP body (e.g. string, JSON).</param>
|
||||||
/// <param name="type">Object type</param>
|
/// <param name="type">Object type.</param>
|
||||||
/// <returns>Object representation of the JSON string</returns>
|
/// <returns>Object representation of the JSON string.</returns>
|
||||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
|
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
|
||||||
if (type == typeof(Object)) { // return an object
|
{
|
||||||
|
if (type == typeof(Object)) // return an object
|
||||||
|
{
|
||||||
return (Object)content;
|
return (Object)content;
|
||||||
} else if (type == typeof(Stream)) {
|
} else if (type == typeof(Stream))
|
||||||
|
{
|
||||||
String fileName, filePath;
|
String fileName, filePath;
|
||||||
if (String.IsNullOrEmpty (Configuration.TempFolderPath)) {
|
if (String.IsNullOrEmpty (Configuration.TempFolderPath))
|
||||||
filePath = System.IO.Path.GetTempPath ();
|
filePath = System.IO.Path.GetTempPath ();
|
||||||
} else {
|
else
|
||||||
filePath = Configuration.TempFolderPath;
|
filePath = Configuration.TempFolderPath;
|
||||||
}
|
|
||||||
|
|
||||||
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||||
Match match = regex.Match(headers.ToString());
|
Match match = regex.Match(headers.ToString());
|
||||||
if (match.Success) {
|
if (match.Success) // replace first and last " or ', if found
|
||||||
// replace first and last " or ', if found
|
|
||||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
||||||
} else {
|
else
|
||||||
fileName = filePath + Guid.NewGuid().ToString();
|
fileName = filePath + Guid.NewGuid().ToString();
|
||||||
}
|
|
||||||
File.WriteAllText (fileName, content);
|
File.WriteAllText (fileName, content);
|
||||||
return new FileStream(fileName, FileMode.Open);
|
return new FileStream(fileName, FileMode.Open);
|
||||||
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) { // return a datetime object
|
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) // return a datetime object
|
||||||
|
{
|
||||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||||
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) { // return primitive
|
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) // return primitive type
|
||||||
|
{
|
||||||
return ConvertType(content, type);
|
return ConvertType(content, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -234,56 +236,61 @@ namespace IO.Swagger.Client {
|
|||||||
{
|
{
|
||||||
return JsonConvert.DeserializeObject(content, type);
|
return JsonConvert.DeserializeObject(content, type);
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e)
|
||||||
|
{
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Serialize an object into JSON string
|
/// Serialize an object into JSON string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Object</param>
|
/// <param name="obj">Object.</param>
|
||||||
/// <returns>JSON string</returns>
|
/// <returns>JSON string.</returns>
|
||||||
public string Serialize(object obj) {
|
public string Serialize(object obj)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e)
|
||||||
|
{
|
||||||
throw new ApiException(500, e.Message);
|
throw new ApiException(500, e.Message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the API key with prefix
|
/// Get the API key with prefix.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="obj">Object</param>
|
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
||||||
/// <returns>API key with prefix</returns>
|
/// <returns>API key with prefix.</returns>
|
||||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||||
{
|
{
|
||||||
var apiKeyValue = "";
|
var apiKeyValue = "";
|
||||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
||||||
var apiKeyPrefix = "";
|
var apiKeyPrefix = "";
|
||||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) {
|
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix))
|
||||||
return apiKeyPrefix + " " + apiKeyValue;
|
return apiKeyPrefix + " " + apiKeyValue;
|
||||||
} else {
|
else
|
||||||
return apiKeyValue;
|
return apiKeyValue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Update parameters based on authentication
|
/// Update parameters based on authentication.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="QueryParams">Query parameters</param>
|
/// <param name="queryParams">Query parameters.</param>
|
||||||
/// <param name="HeaderParams">Header parameters</param>
|
/// <param name="headerParams">Header parameters.</param>
|
||||||
/// <param name="AuthSettings">Authentication settings</param>
|
/// <param name="authSettings">Authentication settings.</param>
|
||||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings) {
|
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings)
|
||||||
|
{
|
||||||
if (authSettings == null || authSettings.Length == 0)
|
if (authSettings == null || authSettings.Length == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
foreach (string auth in authSettings) {
|
foreach (string auth in authSettings)
|
||||||
|
{
|
||||||
// determine which one to use
|
// determine which one to use
|
||||||
switch(auth) {
|
switch(auth)
|
||||||
|
{
|
||||||
|
|
||||||
case "api_key":
|
case "api_key":
|
||||||
headerParams["api_key"] = GetApiKeyWithPrefix("api_key");
|
headerParams["api_key"] = GetApiKeyWithPrefix("api_key");
|
||||||
@ -300,24 +307,26 @@ namespace IO.Swagger.Client {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Encode string in base64 format
|
/// Encode string in base64 format.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="text">String to be encoded</param>
|
/// <param name="text">String to be encoded.</param>
|
||||||
public static string Base64Encode(string text) {
|
/// <returns>Encoded string.</returns>
|
||||||
|
public static string Base64Encode(string text)
|
||||||
|
{
|
||||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||||
return System.Convert.ToBase64String(textByte);
|
return System.Convert.ToBase64String(textByte);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Dynamically cast the object into target type
|
/// Dynamically cast the object into target type.
|
||||||
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="dynamic">Object to be casted</param>
|
/// <param name="source">Object to be casted</param>
|
||||||
/// <param name="dest">Target type</param>
|
/// <param name="dest">Target type</param>
|
||||||
|
/// <returns>Casted object</returns>
|
||||||
public static dynamic ConvertType(dynamic source, Type dest) {
|
public static dynamic ConvertType(dynamic source, Type dest) {
|
||||||
return Convert.ChangeType(source, dest);
|
return Convert.ChangeType(source, dest);
|
||||||
}
|
}
|
||||||
|
@ -3,18 +3,20 @@ using System.Reflection;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace IO.Swagger.Client {
|
namespace IO.Swagger.Client
|
||||||
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a set of configuration settings
|
/// Represents a set of configuration settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class Configuration{
|
public class Configuration
|
||||||
|
{
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Version of the package
|
/// Version of the package.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
/// <value>Version of the package.</value>
|
||||||
public const string Version = "1.0.0";
|
public const string Version = "1.0.0";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -24,25 +26,25 @@ namespace IO.Swagger.Client {
|
|||||||
public static ApiClient DefaultApiClient = new ApiClient();
|
public static ApiClient DefaultApiClient = new ApiClient();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the username (HTTP basic authentication)
|
/// Gets or sets the username (HTTP basic authentication).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The username.</value>
|
/// <value>The username.</value>
|
||||||
public static String Username { get; set; }
|
public static String Username { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the password (HTTP basic authentication)
|
/// Gets or sets the password (HTTP basic authentication).
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The password.</value>
|
/// <value>The password.</value>
|
||||||
public static String Password { get; set; }
|
public static String Password { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the API key based on the authentication name
|
/// Gets or sets the API key based on the authentication name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The API key.</value>
|
/// <value>The API key.</value>
|
||||||
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
public static Dictionary<String, String> ApiKey = new Dictionary<String, String>();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
|
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>The prefix of the API key.</value>
|
/// <value>The prefix of the API key.</value>
|
||||||
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
public static Dictionary<String, String> ApiKeyPrefix = new Dictionary<String, String>();
|
||||||
@ -50,46 +52,46 @@ namespace IO.Swagger.Client {
|
|||||||
private static string _tempFolderPath = Path.GetTempPath();
|
private static string _tempFolderPath = Path.GetTempPath();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the temporary folder path to store the files downloaded from the server
|
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Folder path</value>
|
/// <value>Folder path.</value>
|
||||||
public static String TempFolderPath {
|
public static String TempFolderPath
|
||||||
get {
|
{
|
||||||
return _tempFolderPath;
|
get { return _tempFolderPath; }
|
||||||
}
|
|
||||||
|
|
||||||
set {
|
set
|
||||||
if (String.IsNullOrEmpty(value)) {
|
{
|
||||||
|
if (String.IsNullOrEmpty(value))
|
||||||
|
{
|
||||||
_tempFolderPath = value;
|
_tempFolderPath = value;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// create the directory if it does not exist
|
// create the directory if it does not exist
|
||||||
if (!Directory.Exists(value)) {
|
if (!Directory.Exists(value))
|
||||||
Directory.CreateDirectory(value);
|
Directory.CreateDirectory(value);
|
||||||
}
|
|
||||||
|
|
||||||
// check if the path contains directory separator at the end
|
// check if the path contains directory separator at the end
|
||||||
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
|
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
||||||
_tempFolderPath = value;
|
_tempFolderPath = value;
|
||||||
} else {
|
else
|
||||||
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Return a string contain essential information for debugging
|
/// Returns a string with essential information for debugging.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <value>Folder path</value>
|
/// <value>Debugging Report</value>
|
||||||
public static String ToDebugReport() {
|
public static String ToDebugReport()
|
||||||
|
{
|
||||||
String report = "C# SDK () Debug Report:\n";
|
String report = "C# SDK () Debug Report:\n";
|
||||||
report += " OS: " + Environment.OSVersion + "\n";
|
report += " OS: " + Environment.OSVersion + "\n";
|
||||||
report += " .NET Framework Version: " + Assembly
|
report += " .NET Framework Version: " + Assembly
|
||||||
.GetExecutingAssembly()
|
.GetExecutingAssembly()
|
||||||
.GetReferencedAssemblies()
|
.GetReferencedAssemblies()
|
||||||
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
|
||||||
report += " Swagger Spec Version: 1.0.0\n";
|
report += " Version of the API: 1.0.0\n";
|
||||||
report += " SDK Package Version: 1.0.0\n";
|
report += " SDK Package Version: 1.0.0\n";
|
||||||
|
|
||||||
return report;
|
return report;
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
<Reference Include="nunit.framework">
|
<Reference Include="nunit.framework">
|
||||||
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
<HintPath>packages\NUnit.2.6.4\lib\nunit.framework.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />
|
<Compile Include="Lib\SwaggerClient\src\main\csharp\IO\Swagger\Api\PetApi.cs" />
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
|
||||||
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
|
||||||
<Files>
|
<Files>
|
||||||
<File FileName="TestPet.cs" Line="57" Column="19" />
|
<File FileName="TestPet.cs" Line="31" Column="19" />
|
||||||
</Files>
|
</Files>
|
||||||
</MonoDevelop.Ide.Workbench>
|
</MonoDevelop.Ide.Workbench>
|
||||||
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
<MonoDevelop.Ide.DebuggingService.Breakpoints>
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user