forked from loafle/openapi-generator-original
fix comment and use 4-space indentation
This commit is contained in:
parent
57b54d8ad7
commit
d7d6ba957e
289
;
Normal file
289
;
Normal file
@ -0,0 +1,289 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Newtonsoft.Json;
|
||||
using RestSharp;
|
||||
|
||||
namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// API client is mainly responible for making the HTTP call to the API backend
|
||||
/// </summary>
|
||||
public class ApiClient {
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="ApiClient"/> class.
|
||||
/// </summary>
|
||||
/// <param name="basePath">The base path.</param>
|
||||
public ApiClient(String basePath="{{basePath}}") {
|
||||
this.BasePath = basePath;
|
||||
this.RestClient = new RestClient(this.BasePath);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the base path.
|
||||
/// </summary>
|
||||
/// <value>The base path.</value>
|
||||
public string BasePath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the RestClient
|
||||
/// </summary>
|
||||
/// <value>The RestClient.</value>
|
||||
public RestClient RestClient { get; set; }
|
||||
|
||||
private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public Object CallApi(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) {
|
||||
var response = Task.Run(async () => {
|
||||
var resp = await CallApiAsync(path, method, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
return resp;
|
||||
});
|
||||
return response.Result;
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
var request = new RestRequest(path, method);
|
||||
|
||||
UpdateParamsForAuth(queryParams, headerParams, authSettings);
|
||||
|
||||
// add default header, if any
|
||||
foreach(KeyValuePair<string, string> defaultHeader in this.DefaultHeaderMap)
|
||||
request.AddHeader(defaultHeader.Key, defaultHeader.Value);
|
||||
|
||||
// add header parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in headerParams)
|
||||
request.AddHeader(param.Key, param.Value);
|
||||
|
||||
// add query parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in queryParams)
|
||||
request.AddQueryParameter(param.Key, param.Value);
|
||||
|
||||
// add form parameter, if any
|
||||
foreach(KeyValuePair<string, string> param in formParams)
|
||||
request.AddParameter(param.Key, param.Value);
|
||||
|
||||
// add file parameter, if any
|
||||
foreach(KeyValuePair<string, FileParameter> param in fileParams)
|
||||
request.AddFile(param.Value.Name, param.Value.Writer, param.Value.FileName, param.Value.ContentType);
|
||||
|
||||
|
||||
if (postBody != null) {
|
||||
request.AddParameter("application/json", postBody, ParameterType.RequestBody); // http body (model) parameter
|
||||
}
|
||||
|
||||
return (Object) await RestClient.ExecuteTaskAsync(request);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add default header
|
||||
/// </summary>
|
||||
/// <param name="key"> Header field name
|
||||
/// <param name="value"> Header field value
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value) {
|
||||
DefaultHeaderMap.Add(key, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get default header
|
||||
/// </summary>
|
||||
/// <returns>Dictionary of default header</returns>
|
||||
public Dictionary<String, String> GetDefaultHeader() {
|
||||
return DefaultHeaderMap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// escape string (url-encoded)
|
||||
/// </summary>
|
||||
/// <param name="str"> String to be escaped
|
||||
/// <returns>Escaped string</returns>
|
||||
public string EscapeString(string str) {
|
||||
return str;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create FileParameter based on Stream
|
||||
/// </summary>
|
||||
/// <param name="name"> parameter name</param>
|
||||
/// <param name="stream">Stream</param>
|
||||
/// <returns>FileParameter</returns>
|
||||
public FileParameter ParameterToFile(string name, Stream stream)
|
||||
{
|
||||
if (stream is FileStream) {
|
||||
return FileParameter.Create(name, StreamToByteArray(stream), ((FileStream)stream).Name);
|
||||
} else {
|
||||
return FileParameter.Create(name, StreamToByteArray(stream), "temp_name_here");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// if parameter is DateTime, output in ISO8601 format
|
||||
/// if parameter is a list of string, join the list with ","
|
||||
/// otherwise just return the string
|
||||
/// </summary>
|
||||
/// <param name="obj"> The parameter (header, path, query, form)
|
||||
/// <returns>Formatted string</returns>
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
if (obj is DateTime) {
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
} else if (obj is List<string>) {
|
||||
return String.Join(",", obj as List<string>);
|
||||
} else {
|
||||
return Convert.ToString (obj);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object
|
||||
/// </summary>
|
||||
/// <param name="content"> HTTP body (e.g. string, JSON)
|
||||
/// <param name="type"> Object type
|
||||
/// <returns>Object representation of the JSON string</returns>
|
||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
|
||||
if (type.GetType() == typeof(Object)) { // return an object
|
||||
return (Object)content;
|
||||
} else if (type.Name == "Stream") {
|
||||
String fileName, filePath;
|
||||
if (String.IsNullOrEmpty (Configuration.TempFolderPath)) {
|
||||
filePath = System.IO.Path.GetTempPath ();
|
||||
} else {
|
||||
filePath = Configuration.TempFolderPath;
|
||||
}
|
||||
|
||||
Regex regex = new Regex(@"Content-Disposition:.*filename=['""]?([^'""\s]+)['""]?$");
|
||||
Match match = regex.Match(headers.ToString());
|
||||
if (match.Success) {
|
||||
// replace first and last " or ', if found
|
||||
fileName = filePath + match.Value.Replace("\"", "").Replace("'","");
|
||||
} else {
|
||||
fileName = filePath + Guid.NewGuid().ToString();
|
||||
}
|
||||
File.WriteAllText (fileName, content);
|
||||
return new FileStream(fileName, FileMode.Open);
|
||||
} else if (type.Name.StartsWith("System.Nullable`1[[System.DateTime")) { // return a datetime object
|
||||
return DateTime.Parse(content, null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
} else if (type.Name == "String" || type.Name.StartsWith("System.Nullable")) { // return primitive
|
||||
return ConvertType(content, type);
|
||||
}
|
||||
|
||||
// at this point, it must be a model (json)
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject(content, type);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>JSON string</returns>
|
||||
public string Serialize(object obj) {
|
||||
try
|
||||
{
|
||||
return obj != null ? JsonConvert.SerializeObject(obj) : null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new ApiException(500, e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the API key with prefix
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <returns>API key with prefix</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||
{
|
||||
var apiKeyValue = "";
|
||||
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
|
||||
var apiKeyPrefix = "";
|
||||
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) {
|
||||
return apiKeyPrefix + " " + apiKeyValue;
|
||||
} else {
|
||||
return apiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Update parameters based on authentication
|
||||
/// </summary>
|
||||
/// <param name="QueryParams">Query parameters</param>
|
||||
/// <param name="HeaderParams">Header parameters</param>
|
||||
/// <param name="AuthSettings">Authentication settings</param>
|
||||
public void UpdateParamsForAuth(Dictionary<String, String> queryParams, Dictionary<String, String> headerParams, string[] authSettings) {
|
||||
if (authSettings == null || authSettings.Length == 0)
|
||||
return;
|
||||
|
||||
foreach (string auth in authSettings) {
|
||||
// determine which one to use
|
||||
switch(auth) {
|
||||
{{#authMethods}}
|
||||
case "{{name}}":
|
||||
{{#isApiKey}}{{#isKeyInHeader}}headerParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInHeader}}{{#isKeyInQuery}}queryParams["{{keyParamName}}"] = GetApiKeyWithPrefix("{{keyParamName}}");{{/isKeyInQuery}}{{/isApiKey}}{{#isBasic}}headerParams["Authorization"] = "Basic " + Base64Encode(Configuration.Username + ":" + Configuration.Password);{{/isBasic}}
|
||||
{{#isOAuth}}//TODO support oauth{{/isOAuth}}
|
||||
break;
|
||||
{{/authMethods}}
|
||||
default:
|
||||
//TODO show warning about security definition not found
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// convert a stream to byte array (byte[])
|
||||
/// Ref: http://stackoverflow.com/questions/221925/creating-a-byte-array-from-a-stream
|
||||
/// </summary>
|
||||
/// <param name="input">input stream</param>
|
||||
/// <return>Array of Byte</return>
|
||||
public byte[] StreamToByteArray(Stream input)
|
||||
{
|
||||
byte[] buffer = new byte[16*1024];
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
int read;
|
||||
while ((read = input.Read(buffer, 0, buffer.Length)) > 0)
|
||||
{
|
||||
ms.Write(buffer, 0, read);
|
||||
}
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Encode string in base64 format
|
||||
/// </summary>
|
||||
/// <param name="text">String to be encoded</param>
|
||||
public static string Base64Encode(string text) {
|
||||
var textByte = System.Text.Encoding.UTF8.GetBytes(text);
|
||||
return System.Convert.ToBase64String(textByte);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Dynamically cast the object into target type
|
||||
/// Ref: http://stackoverflow.com/questions/4925718/c-dynamic-runtime-cast
|
||||
/// </summary>
|
||||
/// <param name="dynamic">Object to be casted</param>
|
||||
/// <param name="dest">Target type</param>
|
||||
public static dynamic ConvertType(dynamic source, Type dest) {
|
||||
return Convert.ChangeType(source, dest);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -39,7 +39,8 @@ namespace {{packageName}}.Client {
|
||||
private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public Object CallApi(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 response = Task.Run(async () => {
|
||||
var resp = await CallApiAsync(path, method, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
return resp;
|
||||
@ -86,8 +87,8 @@ namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// Add default header
|
||||
/// </summary>
|
||||
/// <param name="key"> Header field name
|
||||
/// <param name="value"> Header field value
|
||||
/// <param name="key"> Header field name </param>
|
||||
/// <param name="value"> Header field value </param>
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value) {
|
||||
DefaultHeaderMap.Add(key, value);
|
||||
@ -104,7 +105,7 @@ namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// escape string (url-encoded)
|
||||
/// </summary>
|
||||
/// <param name="str"> String to be escaped
|
||||
/// <param name="str">String to be escaped</param>
|
||||
/// <returns>Escaped string</returns>
|
||||
public string EscapeString(string str) {
|
||||
return str;
|
||||
@ -114,7 +115,7 @@ namespace {{packageName}}.Client {
|
||||
/// Create FileParameter based on Stream
|
||||
/// </summary>
|
||||
/// <param name="name">parameter name</param>
|
||||
/// <param name="stream">Stream</param>
|
||||
/// <param name="stream">Input stream</param>
|
||||
/// <returns>FileParameter</returns>
|
||||
public FileParameter ParameterToFile(string name, Stream stream)
|
||||
{
|
||||
@ -130,7 +131,7 @@ namespace {{packageName}}.Client {
|
||||
/// if parameter is a list of string, join the list with ","
|
||||
/// otherwise just return the string
|
||||
/// </summary>
|
||||
/// <param name="obj"> The parameter (header, path, query, form)
|
||||
/// <param name="obj">The parameter (header, path, query, form)</param>
|
||||
/// <returns>Formatted string</returns>
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
@ -146,8 +147,8 @@ namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object
|
||||
/// </summary>
|
||||
/// <param name="content"> HTTP body (e.g. string, JSON)
|
||||
/// <param name="type"> Object type
|
||||
/// <param name="content">HTTP body (e.g. string, JSON)</param>
|
||||
/// <param name="type">Object type</param>
|
||||
/// <returns>Object representation of the JSON string</returns>
|
||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
|
||||
if (type.GetType() == typeof(Object)) { // return an object
|
||||
@ -189,7 +190,7 @@ namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <param name="obj">Object</param>
|
||||
/// <returns>JSON string</returns>
|
||||
public string Serialize(object obj) {
|
||||
try
|
||||
@ -204,7 +205,7 @@ namespace {{packageName}}.Client {
|
||||
/// <summary>
|
||||
/// Get the API key with prefix
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <param name="obj">Object</param>
|
||||
/// <returns>API key with prefix</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||
{
|
||||
|
@ -15,15 +15,15 @@ namespace {{packageName}}.Api {
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>{{/returnType}}
|
||||
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>
|
||||
{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>{{/returnType}}
|
||||
{{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>
|
||||
Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
|
||||
{{/operation}}
|
||||
}
|
||||
|
||||
@ -76,14 +76,13 @@ namespace {{packageName}}.Api {
|
||||
/// <value>The API client</value>
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
{{#operation}}
|
||||
/// <summary>
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>{{/returnType}}
|
||||
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>
|
||||
public {{{returnType}}}{{/returnType}}{{^returnType}}public void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
@ -127,11 +126,9 @@ namespace {{packageName}}.Api {
|
||||
/// {{summary}} {{notes}}
|
||||
/// </summary>
|
||||
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>{{/returnType}}
|
||||
public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
|
||||
|
||||
{{#allParams}}{{#required}}
|
||||
// verify the required parameter '{{paramName}}' is set
|
||||
{{/allParams}}{{#returnType}}/// <returns>{{{returnType}}}</returns>
|
||||
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
|
||||
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
|
||||
{{/required}}{{/allParams}}
|
||||
|
||||
|
@ -14,28 +14,24 @@ namespace IO.Swagger.Api {
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
void UpdatePet (Pet body);
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
Task UpdatePetAsync (Pet body);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
void AddPet (Pet body);
|
||||
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
Task AddPetAsync (Pet body);
|
||||
|
||||
/// <summary>
|
||||
@ -86,7 +82,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
void UpdatePetWithForm (string petId, string name, string status);
|
||||
|
||||
/// <summary>
|
||||
@ -95,7 +90,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
Task UpdatePetWithFormAsync (string petId, string name, string status);
|
||||
|
||||
/// <summary>
|
||||
@ -103,7 +97,6 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
void DeletePet (string apiKey, long? petId);
|
||||
|
||||
/// <summary>
|
||||
@ -111,7 +104,6 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
Task DeletePetAsync (string apiKey, long? petId);
|
||||
|
||||
/// <summary>
|
||||
@ -120,7 +112,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
void UploadFile (long? petId, string additionalMetadata, Stream file);
|
||||
|
||||
/// <summary>
|
||||
@ -129,7 +120,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
Task UploadFileAsync (long? petId, string additionalMetadata, Stream file);
|
||||
|
||||
}
|
||||
@ -184,12 +174,10 @@ namespace IO.Swagger.Api {
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
public void UpdatePet (Pet body) {
|
||||
|
||||
|
||||
@ -227,11 +215,9 @@ namespace IO.Swagger.Api {
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
public async Task UpdatePetAsync (Pet body) {
|
||||
|
||||
|
||||
|
||||
var path = "/pet";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -264,7 +250,6 @@ namespace IO.Swagger.Api {
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
public void AddPet (Pet body) {
|
||||
|
||||
|
||||
@ -302,11 +287,9 @@ namespace IO.Swagger.Api {
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
/// <param name="body">Pet object that needs to be added to the store</param>
|
||||
|
||||
public async Task AddPetAsync (Pet body) {
|
||||
|
||||
|
||||
|
||||
var path = "/pet";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -381,7 +364,6 @@ namespace IO.Swagger.Api {
|
||||
public async Task<List<Pet>> FindPetsByStatusAsync (List<string> status) {
|
||||
|
||||
|
||||
|
||||
var path = "/pet/findByStatus";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -455,7 +437,6 @@ namespace IO.Swagger.Api {
|
||||
public async Task<List<Pet>> FindPetsByTagsAsync (List<string> tags) {
|
||||
|
||||
|
||||
|
||||
var path = "/pet/findByTags";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -530,8 +511,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Pet</returns>
|
||||
public async Task<Pet> GetPetByIdAsync (long? petId) {
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
|
||||
|
||||
@ -569,7 +548,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
public void UpdatePetWithForm (string petId, string name, string status) {
|
||||
|
||||
|
||||
@ -614,10 +592,7 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet that needs to be updated</param>
|
||||
/// <param name="name">Updated name of the pet</param>
|
||||
/// <param name="status">Updated status of the pet</param>
|
||||
|
||||
public async Task UpdatePetWithFormAsync (string petId, string name, string status) {
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
|
||||
|
||||
@ -657,7 +632,6 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
public void DeletePet (string apiKey, long? petId) {
|
||||
|
||||
|
||||
@ -700,10 +674,7 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="apiKey"></param>
|
||||
/// <param name="petId">Pet id to delete</param>
|
||||
|
||||
public async Task DeletePetAsync (string apiKey, long? petId) {
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
|
||||
|
||||
@ -743,7 +714,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
public void UploadFile (long? petId, string additionalMetadata, Stream file) {
|
||||
|
||||
|
||||
@ -788,10 +758,7 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="petId">ID of pet to update</param>
|
||||
/// <param name="additionalMetadata">Additional data to pass to server</param>
|
||||
/// <param name="file">file to upload</param>
|
||||
|
||||
public async Task UploadFileAsync (long? petId, string additionalMetadata, Stream file) {
|
||||
|
||||
|
||||
// verify the required parameter 'petId' is set
|
||||
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
|
||||
|
||||
|
@ -54,14 +54,12 @@ namespace IO.Swagger.Api {
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
void DeleteOrder (string orderId);
|
||||
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
Task DeleteOrderAsync (string orderId);
|
||||
|
||||
}
|
||||
@ -116,7 +114,6 @@ namespace IO.Swagger.Api {
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status Returns a map of status codes to quantities
|
||||
/// </summary>
|
||||
@ -160,7 +157,6 @@ namespace IO.Swagger.Api {
|
||||
public async Task<Dictionary<String, int?>> GetInventoryAsync () {
|
||||
|
||||
|
||||
|
||||
var path = "/store/inventory";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -233,7 +229,6 @@ namespace IO.Swagger.Api {
|
||||
public async Task<Order> PlaceOrderAsync (Order body) {
|
||||
|
||||
|
||||
|
||||
var path = "/store/order";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -308,8 +303,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="orderId">ID of pet that needs to be fetched</param>
|
||||
/// <returns>Order</returns>
|
||||
public async Task<Order> GetOrderByIdAsync (string orderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
|
||||
|
||||
@ -345,7 +338,6 @@ namespace IO.Swagger.Api {
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
public void DeleteOrder (string orderId) {
|
||||
|
||||
|
||||
@ -386,10 +378,7 @@ namespace IO.Swagger.Api {
|
||||
/// Delete purchase order by ID For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
/// </summary>
|
||||
/// <param name="orderId">ID of the order that needs to be deleted</param>
|
||||
|
||||
public async Task DeleteOrderAsync (string orderId) {
|
||||
|
||||
|
||||
// verify the required parameter 'orderId' is set
|
||||
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
|
||||
|
||||
|
@ -14,42 +14,36 @@ namespace IO.Swagger.Api {
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
void CreateUser (User body);
|
||||
|
||||
/// <summary>
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
Task CreateUserAsync (User body);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
void CreateUsersWithArrayInput (List<User> body);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
Task CreateUsersWithArrayInputAsync (List<User> body);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
void CreateUsersWithListInput (List<User> body);
|
||||
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
Task CreateUsersWithListInputAsync (List<User> body);
|
||||
|
||||
/// <summary>
|
||||
@ -71,13 +65,11 @@ namespace IO.Swagger.Api {
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
void LogoutUser ();
|
||||
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
Task LogoutUserAsync ();
|
||||
|
||||
/// <summary>
|
||||
@ -99,7 +91,6 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
void UpdateUser (string username, User body);
|
||||
|
||||
/// <summary>
|
||||
@ -107,21 +98,18 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
Task UpdateUserAsync (string username, User body);
|
||||
|
||||
/// <summary>
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
void DeleteUser (string username);
|
||||
|
||||
/// <summary>
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
Task DeleteUserAsync (string username);
|
||||
|
||||
}
|
||||
@ -176,12 +164,10 @@ namespace IO.Swagger.Api {
|
||||
public ApiClient ApiClient {get; set;}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
public void CreateUser (User body) {
|
||||
|
||||
|
||||
@ -219,11 +205,9 @@ namespace IO.Swagger.Api {
|
||||
/// Create user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="body">Created user object</param>
|
||||
|
||||
public async Task CreateUserAsync (User body) {
|
||||
|
||||
|
||||
|
||||
var path = "/user";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -256,7 +240,6 @@ namespace IO.Swagger.Api {
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
public void CreateUsersWithArrayInput (List<User> body) {
|
||||
|
||||
|
||||
@ -294,11 +277,9 @@ namespace IO.Swagger.Api {
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
public async Task CreateUsersWithArrayInputAsync (List<User> body) {
|
||||
|
||||
|
||||
|
||||
var path = "/user/createWithArray";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -331,7 +312,6 @@ namespace IO.Swagger.Api {
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
public void CreateUsersWithListInput (List<User> body) {
|
||||
|
||||
|
||||
@ -369,11 +349,9 @@ namespace IO.Swagger.Api {
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
/// <param name="body">List of user object</param>
|
||||
|
||||
public async Task CreateUsersWithListInputAsync (List<User> body) {
|
||||
|
||||
|
||||
|
||||
var path = "/user/createWithList";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -451,7 +429,6 @@ namespace IO.Swagger.Api {
|
||||
public async Task<string> LoginUserAsync (string username, string password) {
|
||||
|
||||
|
||||
|
||||
var path = "/user/login";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -483,7 +460,6 @@ namespace IO.Swagger.Api {
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
public void LogoutUser () {
|
||||
|
||||
|
||||
@ -519,11 +495,9 @@ namespace IO.Swagger.Api {
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
|
||||
public async Task LogoutUserAsync () {
|
||||
|
||||
|
||||
|
||||
var path = "/user/logout";
|
||||
path = path.Replace("{format}", "json");
|
||||
|
||||
@ -598,8 +572,6 @@ namespace IO.Swagger.Api {
|
||||
/// <param name="username">The name that needs to be fetched. Use user1 for testing. </param>
|
||||
/// <returns>User</returns>
|
||||
public async Task<User> GetUserByNameAsync (string username) {
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
|
||||
|
||||
@ -636,7 +608,6 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
public void UpdateUser (string username, User body) {
|
||||
|
||||
|
||||
@ -679,10 +650,7 @@ namespace IO.Swagger.Api {
|
||||
/// </summary>
|
||||
/// <param name="username">name that need to be deleted</param>
|
||||
/// <param name="body">Updated user object</param>
|
||||
|
||||
public async Task UpdateUserAsync (string username, User body) {
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
|
||||
|
||||
@ -720,7 +688,6 @@ namespace IO.Swagger.Api {
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
public void DeleteUser (string username) {
|
||||
|
||||
|
||||
@ -761,10 +728,7 @@ namespace IO.Swagger.Api {
|
||||
/// Delete user This can only be done by the logged in user.
|
||||
/// </summary>
|
||||
/// <param name="username">The name that needs to be deleted</param>
|
||||
|
||||
public async Task DeleteUserAsync (string username) {
|
||||
|
||||
|
||||
// verify the required parameter 'username' is set
|
||||
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
|
||||
|
||||
|
@ -39,7 +39,8 @@ namespace IO.Swagger.Client {
|
||||
private Dictionary<String, String> DefaultHeaderMap = new Dictionary<String, String>();
|
||||
|
||||
public Object CallApi(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 response = Task.Run(async () => {
|
||||
var resp = await CallApiAsync(path, method, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
|
||||
return resp;
|
||||
@ -86,8 +87,8 @@ namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// Add default header
|
||||
/// </summary>
|
||||
/// <param name="key"> Header field name
|
||||
/// <param name="value"> Header field value
|
||||
/// <param name="key"> Header field name </param>
|
||||
/// <param name="value"> Header field value </param>
|
||||
/// <returns></returns>
|
||||
public void AddDefaultHeader(string key, string value) {
|
||||
DefaultHeaderMap.Add(key, value);
|
||||
@ -104,7 +105,7 @@ namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// escape string (url-encoded)
|
||||
/// </summary>
|
||||
/// <param name="str"> String to be escaped
|
||||
/// <param name="str">String to be escaped</param>
|
||||
/// <returns>Escaped string</returns>
|
||||
public string EscapeString(string str) {
|
||||
return str;
|
||||
@ -114,7 +115,7 @@ namespace IO.Swagger.Client {
|
||||
/// Create FileParameter based on Stream
|
||||
/// </summary>
|
||||
/// <param name="name">parameter name</param>
|
||||
/// <param name="stream">Stream</param>
|
||||
/// <param name="stream">Input stream</param>
|
||||
/// <returns>FileParameter</returns>
|
||||
public FileParameter ParameterToFile(string name, Stream stream)
|
||||
{
|
||||
@ -130,7 +131,7 @@ namespace IO.Swagger.Client {
|
||||
/// if parameter is a list of string, join the list with ","
|
||||
/// otherwise just return the string
|
||||
/// </summary>
|
||||
/// <param name="obj"> The parameter (header, path, query, form)
|
||||
/// <param name="obj">The parameter (header, path, query, form)</param>
|
||||
/// <returns>Formatted string</returns>
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
@ -146,8 +147,8 @@ namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// Deserialize the JSON string into a proper object
|
||||
/// </summary>
|
||||
/// <param name="content"> HTTP body (e.g. string, JSON)
|
||||
/// <param name="type"> Object type
|
||||
/// <param name="content">HTTP body (e.g. string, JSON)</param>
|
||||
/// <param name="type">Object type</param>
|
||||
/// <returns>Object representation of the JSON string</returns>
|
||||
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
|
||||
if (type.GetType() == typeof(Object)) { // return an object
|
||||
@ -189,7 +190,7 @@ namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// Serialize an object into JSON string
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <param name="obj">Object</param>
|
||||
/// <returns>JSON string</returns>
|
||||
public string Serialize(object obj) {
|
||||
try
|
||||
@ -204,7 +205,7 @@ namespace IO.Swagger.Client {
|
||||
/// <summary>
|
||||
/// Get the API key with prefix
|
||||
/// </summary>
|
||||
/// <param name="obj"> Object
|
||||
/// <param name="obj">Object</param>
|
||||
/// <returns>API key with prefix</returns>
|
||||
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
|
||||
{
|
||||
|
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user