add file response support for c# (passed test cases)

This commit is contained in:
wing328 2015-06-29 12:17:49 +08:00
parent 4143e28637
commit 76ece5a4eb
14 changed files with 440 additions and 269 deletions

View File

@ -68,7 +68,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
typeMapping.put("number", "double?");
typeMapping.put("datetime", "DateTime?");
typeMapping.put("date", "DateTime?");
typeMapping.put("file", "string"); // path to file
typeMapping.put("file", "FileStream");
typeMapping.put("array", "List");
typeMapping.put("list", "List");
typeMapping.put("map", "Dictionary");

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;
using System.Net;
@ -19,21 +20,21 @@ namespace {{packageName}}.Client {
/// </summary>
/// <param name="basePath">The base path.</param>
public ApiClient(String basePath="{{basePath}}") {
this.basePath = basePath;
this.restClient = new RestClient(this.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; }
public string BasePath { get; set; }
/// <summary>
/// Gets or sets the RestClient
/// </summary>
/// <value>The RestClient.</value>
public RestClient restClient { get; set; }
public RestClient RestClient { get; set; }
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();
@ -77,7 +78,7 @@ namespace {{packageName}}.Client {
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter
}
return (Object) await restClient.ExecuteTaskAsync(request);
return (Object) await RestClient.ExecuteTaskAsync(request);
}
@ -119,10 +120,12 @@ namespace {{packageName}}.Client {
{
if (obj is DateTime) {
return ((DateTime)obj).ToString ("u");
} else if (obj is FileStream) {
return ((FileStream)obj).Name;
} else if (obj is List<string>) {
return String.Join(",", obj as List<string>);
} else {
return Convert.ToString (obj);
return Convert.ToString (obj);
}
}
@ -132,16 +135,38 @@ namespace {{packageName}}.Client {
/// <param name="json"> JSON string
/// <param name="type"> Object type
/// <returns>Object representation of the JSON string</returns>
public object Deserialize(string content, Type type) {
if (type.GetType() == typeof(Object))
return (Object)content;
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
if (type.GetType() == typeof(Object)) {
return (Object)content;
} else if (type.Name == "FileStream") {
// e.g. Content-Disposition: attachment; filename=checkimage.jpp
String fileName;
String 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();
}
System.IO.File.WriteAllText (fileName, content);
return File.Open (fileName, FileMode.Open);
}
try
{
return JsonConvert.DeserializeObject(content, type);
}
catch (IOException e) {
throw new ApiException(500, e.Message);
throw new ApiException(500, e.Message);
}
}
@ -165,12 +190,12 @@ namespace {{packageName}}.Client {
/// </summary>
/// <param name="obj"> Object
/// <returns>API key with prefix</returns>
public string GetApiKeyWithPrefix (string apiKey)
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
{
var apiKeyValue = "";
Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue);
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
var apiKeyPrefix = "";
if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) {
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) {
return apiKeyPrefix + " " + apiKeyValue;
} else {
return apiKeyValue;
@ -192,7 +217,7 @@ namespace {{packageName}}.Client {
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}}
{{#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}}

View File

@ -1,4 +1,5 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -17,35 +18,81 @@ namespace {{packageName}}.Client {
public const string Version = "{{packageVersion}}";
/// <summary>
/// Gets or sets the API client. This is the default API client for making HTTP calls.
/// Gets or sets the default API client for making HTTP calls.
/// </summary>
/// <value>The API client.</value>
public static ApiClient apiClient = new ApiClient();
public static ApiClient DefaultApiClient = new ApiClient();
/// <summary>
/// Gets or sets the username (HTTP basic authentication)
/// </summary>
/// <value>The username.</value>
public static String username { get; set; }
public static String Username { get; set; }
/// <summary>
/// Gets or sets the password (HTTP basic authentication)
/// </summary>
/// <value>The password.</value>
public static String password { get; set; }
public static String Password { get; set; }
/// <summary>
/// Gets or sets the API key based on the authentication name
/// </summary>
/// <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>
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
/// </summary>
/// <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>();
private static string _tempFolderPath = Path.GetTempPath();
/// <summary>
/// Gets or sets the temporary folder path to store the files downloaded from the server
/// </summary>
/// <value>Folder path</value>
public static String TempFolderPath {
get {
return _tempFolderPath;
}
set {
if (!String.IsNullOrEmpty(value)) {
_tempFolderPath = value;
return;
}
// create the directory if it does not exist
if (!Directory.Exists(value)) {
Directory.CreateDirectory(value);
}
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
_tempFolderPath = value;
} else {
_tempFolderPath = value + Path.DirectorySeparatorChar;
}
}
}
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK ({{invokerPackage}}) Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: {{version}}\n";
report += " SDK Package Version: {{version}}\n";
return report;
}
}
}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using RestSharp;
@ -15,15 +16,15 @@ namespace {{packageName}}.Api {
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}
}
@ -40,9 +41,9 @@ namespace {{packageName}}.Api {
/// <returns></returns>
public {{classname}}(ApiClient apiClient = null) {
if (apiClient == null) { // use the default one in Configuration
this.apiClient = Configuration.apiClient;
this.ApiClient = Configuration.DefaultApiClient;
} else {
this.apiClient = apiClient;
this.ApiClient = apiClient;
}
}
@ -52,7 +53,7 @@ namespace {{packageName}}.Api {
/// <returns></returns>
public {{classname}}(String basePath)
{
this.apiClient = new ApiClient(basePath);
this.ApiClient = new ApiClient(basePath);
}
/// <summary>
@ -60,7 +61,7 @@ namespace {{packageName}}.Api {
/// </summary>
/// <value>The base path</value>
public void SetBasePath(String basePath) {
this.apiClient.basePath = basePath;
this.ApiClient.BasePath = basePath;
}
/// <summary>
@ -68,22 +69,22 @@ namespace {{packageName}}.Api {
/// </summary>
/// <value>The base path</value>
public String GetBasePath(String basePath) {
return this.apiClient.basePath;
return this.ApiClient.BasePath;
}
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>The API client</value>
public ApiClient apiClient {get; set;}
public ApiClient ApiClient {get; set;}
{{#operation}}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
{{#allParams}}{{#required}}
@ -93,7 +94,7 @@ namespace {{packageName}}.Api {
var path = "{{path}}";
path = path.Replace("{format}", "json");
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", apiClient.ParameterToString({{{paramName}}}));
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
{{/pathParams}}
var queryParams = new Dictionary<String, String>();
@ -102,33 +103,33 @@ namespace {{packageName}}.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
{{/queryParams}}
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
{{/headerParams}}
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
{{/formParams}}
{{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
{{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
{{/bodyParam}}
// authentication setting, if any
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
// make the HTTP request
IRestResponse response = (IRestResponse) apiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
IRestResponse response = (IRestResponse) ApiClient.CallApi(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
if (((int)response.StatusCode) >= 400) {
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
}
{{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}
}
/// <summary>
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>{{/allParams}}
/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{{returnType}}}{{/returnType}}</returns>
public async {{#returnType}}Task<{{{returnType}}}>{{/returnType}}{{^returnType}}Task{{/returnType}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) {
{{#allParams}}{{#required}}
@ -138,7 +139,7 @@ namespace {{packageName}}.Api {
var path = "{{path}}";
path = path.Replace("{format}", "json");
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", apiClient.ParameterToString({{{paramName}}}));
{{#pathParams}}path = path.Replace("{" + "{{baseName}}" + "}", ApiClient.ParameterToString({{{paramName}}}));
{{/pathParams}}
var queryParams = new Dictionary<String, String>();
@ -147,24 +148,24 @@ namespace {{packageName}}.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // query parameter
{{#queryParams}} if ({{paramName}} != null) queryParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // query parameter
{{/queryParams}}
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // header parameter
{{#headerParams}} if ({{paramName}} != null) headerParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // header parameter
{{/headerParams}}
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", {{paramName}});{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", apiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
{{#formParams}}if ({{paramName}} != null) {{#isFile}}fileParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}}));{{/isFile}}{{^isFile}}formParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // form parameter{{/isFile}}
{{/formParams}}
{{#bodyParam}}postBody = apiClient.Serialize({{paramName}}); // http body (model) parameter
{{#bodyParam}}postBody = ApiClient.Serialize({{paramName}}); // http body (model) parameter
{{/bodyParam}}
// authentication setting, if any
String[] authSettings = new String[] { {{#authMethods}}"{{name}}"{{#hasMore}}, {{/hasMore}}{{/authMethods}} };
// make the HTTP request
IRestResponse response = (IRestResponse) await apiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, authSettings);
if (((int)response.StatusCode) >= 400) {
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
}
{{#returnType}}return ({{{returnType}}}) apiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response.Content, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}
}
{{/operation}}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using RestSharp;
@ -83,44 +84,54 @@ namespace IO.Swagger.Api {
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
void UpdatePetWithForm (string PetId, string Name, string Status);
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
Task UpdatePetWithFormAsync (string PetId, string Name, string Status);
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name="ApiKey"></param>/// <param name="PetId">Pet id to delete</param>
/// <param name="ApiKey"></param>
/// <param name="PetId">Pet id to delete</param>
/// <returns></returns>
void DeletePet (string ApiKey, long? PetId);
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name="ApiKey"></param>/// <param name="PetId">Pet id to delete</param>
/// <param name="ApiKey"></param>
/// <param name="PetId">Pet id to delete</param>
/// <returns></returns>
Task DeletePetAsync (string ApiKey, long? PetId);
/// <summary>
/// uploads an image
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
void UploadFile (long? PetId, string AdditionalMetadata, string File);
void UploadFile (long? PetId, string AdditionalMetadata, FileStream File);
/// <summary>
/// uploads an image
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File);
Task UploadFileAsync (long? PetId, string AdditionalMetadata, FileStream File);
}
@ -136,9 +147,9 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public PetApi(ApiClient apiClient = null) {
if (apiClient == null) { // use the default one in Configuration
this.apiClient = Configuration.apiClient;
this.ApiClient = Configuration.DefaultApiClient;
} else {
this.apiClient = apiClient;
this.ApiClient = apiClient;
}
}
@ -148,7 +159,7 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public PetApi(String basePath)
{
this.apiClient = new ApiClient(basePath);
this.ApiClient = new ApiClient(basePath);
}
/// <summary>
@ -156,7 +167,7 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public void SetBasePath(String basePath) {
this.apiClient.basePath = basePath;
this.ApiClient.BasePath = basePath;
}
/// <summary>
@ -164,14 +175,14 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public String GetBasePath(String basePath) {
return this.apiClient.basePath;
return this.ApiClient.BasePath;
}
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>The API client</value>
public ApiClient apiClient {get; set;}
public ApiClient ApiClient {get; set;}
@ -197,14 +208,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
@ -212,8 +223,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Update an existing pet
/// </summary>
/// <param name="Body">Pet object that needs to be added to the store</param>
@ -235,14 +246,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
}
@ -272,14 +283,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
@ -287,8 +298,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <param name="Body">Pet object that needs to be added to the store</param>
@ -310,14 +321,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
}
@ -344,7 +355,7 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter
if (Status != null) queryParams.Add("status", ApiClient.ParameterToString(Status)); // query parameter
@ -354,15 +365,15 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
}
return (List<Pet>) apiClient.Deserialize(response.Content, typeof(List<Pet>));
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>));
}
/// <summary>
/// <summary>
/// Finds Pets by status Multiple status values can be provided with comma seperated strings
/// </summary>
/// <param name="Status">Status values that need to be considered for filter</param>
@ -381,7 +392,7 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Status != null) queryParams.Add("status", apiClient.ParameterToString(Status)); // query parameter
if (Status != null) queryParams.Add("status", ApiClient.ParameterToString(Status)); // query parameter
@ -391,11 +402,11 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
}
return (List<Pet>) apiClient.Deserialize(response.Content, typeof(List<Pet>));
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>));
}
/// <summary>
@ -417,7 +428,7 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter
if (Tags != null) queryParams.Add("tags", ApiClient.ParameterToString(Tags)); // query parameter
@ -427,15 +438,15 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
}
return (List<Pet>) apiClient.Deserialize(response.Content, typeof(List<Pet>));
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>));
}
/// <summary>
/// <summary>
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
/// </summary>
/// <param name="Tags">Tags to filter by</param>
@ -454,7 +465,7 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Tags != null) queryParams.Add("tags", apiClient.ParameterToString(Tags)); // query parameter
if (Tags != null) queryParams.Add("tags", ApiClient.ParameterToString(Tags)); // query parameter
@ -464,11 +475,11 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
}
return (List<Pet>) apiClient.Deserialize(response.Content, typeof(List<Pet>));
return (List<Pet>) ApiClient.Deserialize(response.Content, typeof(List<Pet>));
}
/// <summary>
@ -485,7 +496,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -503,15 +514,15 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "api_key", "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
}
return (Pet) apiClient.Deserialize(response.Content, typeof(Pet));
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet));
}
/// <summary>
/// <summary>
/// Find pet by ID Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </summary>
/// <param name="PetId">ID of pet that needs to be fetched</param>
@ -525,7 +536,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -543,17 +554,19 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "api_key", "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
}
return (Pet) apiClient.Deserialize(response.Content, typeof(Pet));
return (Pet) ApiClient.Deserialize(response.Content, typeof(Pet));
}
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
public void UpdatePetWithForm (string PetId, string Name, string Status) {
@ -564,7 +577,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -575,8 +588,8 @@ namespace IO.Swagger.Api {
if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter
if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter
if (Name != null) formParams.Add("name", ApiClient.ParameterToString(Name)); // form parameter
if (Status != null) formParams.Add("status", ApiClient.ParameterToString(Status)); // form parameter
@ -584,7 +597,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
@ -592,11 +605,13 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
public async Task UpdatePetWithFormAsync (string PetId, string Name, string Status) {
@ -607,7 +622,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -618,8 +633,8 @@ namespace IO.Swagger.Api {
if (Name != null) formParams.Add("name", apiClient.ParameterToString(Name)); // form parameter
if (Status != null) formParams.Add("status", apiClient.ParameterToString(Status)); // form parameter
if (Name != null) formParams.Add("name", ApiClient.ParameterToString(Name)); // form parameter
if (Status != null) formParams.Add("status", ApiClient.ParameterToString(Status)); // form parameter
@ -627,7 +642,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
}
@ -638,7 +653,8 @@ namespace IO.Swagger.Api {
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name="ApiKey"></param>/// <param name="PetId">Pet id to delete</param>
/// <param name="ApiKey"></param>
/// <param name="PetId">Pet id to delete</param>
/// <returns></returns>
public void DeletePet (string ApiKey, long? PetId) {
@ -649,7 +665,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -659,7 +675,7 @@ namespace IO.Swagger.Api {
String postBody = null;
if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter
if (ApiKey != null) headerParams.Add("api_key", ApiClient.ParameterToString(ApiKey)); // header parameter
@ -668,7 +684,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
@ -676,11 +692,12 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name="ApiKey"></param>/// <param name="PetId">Pet id to delete</param>
/// <param name="ApiKey"></param>
/// <param name="PetId">Pet id to delete</param>
/// <returns></returns>
public async Task DeletePetAsync (string ApiKey, long? PetId) {
@ -691,7 +708,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -701,7 +718,7 @@ namespace IO.Swagger.Api {
String postBody = null;
if (ApiKey != null) headerParams.Add("api_key", apiClient.ParameterToString(ApiKey)); // header parameter
if (ApiKey != null) headerParams.Add("api_key", ApiClient.ParameterToString(ApiKey)); // header parameter
@ -710,7 +727,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
}
@ -721,9 +738,11 @@ namespace IO.Swagger.Api {
/// <summary>
/// uploads an image
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
public void UploadFile (long? PetId, string AdditionalMetadata, string File) {
public void UploadFile (long? PetId, string AdditionalMetadata, FileStream File) {
// verify the required parameter 'PetId' is set
@ -732,7 +751,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}/uploadImage";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -743,8 +762,8 @@ namespace IO.Swagger.Api {
if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter
if (File != null) fileParams.Add("file", File);
if (AdditionalMetadata != null) formParams.Add("additionalMetadata", ApiClient.ParameterToString(AdditionalMetadata)); // form parameter
if (File != null) fileParams.Add("file", ApiClient.ParameterToString(File));
@ -752,7 +771,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
@ -760,13 +779,15 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// uploads an image
/// </summary>
/// <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>
/// <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>
/// <returns></returns>
public async Task UploadFileAsync (long? PetId, string AdditionalMetadata, string File) {
public async Task UploadFileAsync (long? PetId, string AdditionalMetadata, FileStream File) {
// verify the required parameter 'PetId' is set
@ -775,7 +796,7 @@ namespace IO.Swagger.Api {
var path = "/pet/{petId}/uploadImage";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "petId" + "}", apiClient.ParameterToString(PetId));
path = path.Replace("{" + "petId" + "}", ApiClient.ParameterToString(PetId));
var queryParams = new Dictionary<String, String>();
@ -786,8 +807,8 @@ namespace IO.Swagger.Api {
if (AdditionalMetadata != null) formParams.Add("additionalMetadata", apiClient.ParameterToString(AdditionalMetadata)); // form parameter
if (File != null) fileParams.Add("file", File);
if (AdditionalMetadata != null) formParams.Add("additionalMetadata", ApiClient.ParameterToString(AdditionalMetadata)); // form parameter
if (File != null) fileParams.Add("file", ApiClient.ParameterToString(File));
@ -795,7 +816,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "petstore_auth" };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using RestSharp;
@ -13,14 +14,12 @@ namespace IO.Swagger.Api {
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns>Dictionary<String, int?></returns>
Dictionary<String, int?> GetInventory ();
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns>Dictionary<String, int?></returns>
Task<Dictionary<String, int?>> GetInventoryAsync ();
@ -80,9 +79,9 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public StoreApi(ApiClient apiClient = null) {
if (apiClient == null) { // use the default one in Configuration
this.apiClient = Configuration.apiClient;
this.ApiClient = Configuration.DefaultApiClient;
} else {
this.apiClient = apiClient;
this.ApiClient = apiClient;
}
}
@ -92,7 +91,7 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public StoreApi(String basePath)
{
this.apiClient = new ApiClient(basePath);
this.ApiClient = new ApiClient(basePath);
}
/// <summary>
@ -100,7 +99,7 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public void SetBasePath(String basePath) {
this.apiClient.basePath = basePath;
this.ApiClient.BasePath = basePath;
}
/// <summary>
@ -108,21 +107,20 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public String GetBasePath(String basePath) {
return this.apiClient.basePath;
return this.ApiClient.BasePath;
}
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>The API client</value>
public ApiClient apiClient {get; set;}
public ApiClient ApiClient {get; set;}
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns>Dictionary<String, int?></returns>
public Dictionary<String, int?> GetInventory () {
@ -147,18 +145,17 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "api_key" };
// 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) {
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?>));
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>));
}
/// <summary>
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns>Dictionary<String, int?></returns>
public async Task<Dictionary<String, int?>> GetInventoryAsync () {
@ -183,11 +180,11 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { "api_key" };
// 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) {
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?>));
return (Dictionary<String, int?>) ApiClient.Deserialize(response.Content, typeof(Dictionary<String, int?>));
}
/// <summary>
@ -212,22 +209,22 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
}
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
return (Order) ApiClient.Deserialize(response.Content, typeof(Order));
}
/// <summary>
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name="Body">order placed for purchasing the pet</param>
@ -249,18 +246,18 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
}
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
return (Order) ApiClient.Deserialize(response.Content, typeof(Order));
}
/// <summary>
@ -277,7 +274,7 @@ namespace IO.Swagger.Api {
var path = "/store/order/{orderId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(OrderId));
var queryParams = new Dictionary<String, String>();
@ -295,15 +292,15 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
}
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
return (Order) ApiClient.Deserialize(response.Content, typeof(Order));
}
/// <summary>
/// <summary>
/// Find purchase order by ID For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
/// </summary>
/// <param name="OrderId">ID of pet that needs to be fetched</param>
@ -317,7 +314,7 @@ namespace IO.Swagger.Api {
var path = "/store/order/{orderId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(OrderId));
var queryParams = new Dictionary<String, String>();
@ -335,11 +332,11 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
}
return (Order) apiClient.Deserialize(response.Content, typeof(Order));
return (Order) ApiClient.Deserialize(response.Content, typeof(Order));
}
/// <summary>
@ -356,7 +353,7 @@ namespace IO.Swagger.Api {
var path = "/store/order/{orderId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(OrderId));
var queryParams = new Dictionary<String, String>();
@ -374,7 +371,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
@ -382,8 +379,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Delete purchase order by ID For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
/// </summary>
/// <param name="OrderId">ID of the order that needs to be deleted</param>
@ -397,7 +394,7 @@ namespace IO.Swagger.Api {
var path = "/store/order/{orderId}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "orderId" + "}", apiClient.ParameterToString(OrderId));
path = path.Replace("{" + "orderId" + "}", ApiClient.ParameterToString(OrderId));
var queryParams = new Dictionary<String, String>();
@ -415,7 +412,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
}

View File

@ -1,4 +1,5 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Threading.Tasks;
using RestSharp;
@ -55,28 +56,28 @@ namespace IO.Swagger.Api {
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name="Username">The user name for login</param>/// <param name="Password">The password for login in clear text</param>
/// <param name="Username">The user name for login</param>
/// <param name="Password">The password for login in clear text</param>
/// <returns>string</returns>
string LoginUser (string Username, string Password);
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name="Username">The user name for login</param>/// <param name="Password">The password for login in clear text</param>
/// <param name="Username">The user name for login</param>
/// <param name="Password">The password for login in clear text</param>
/// <returns>string</returns>
Task<string> LoginUserAsync (string Username, string Password);
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <returns></returns>
void LogoutUser ();
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <returns></returns>
Task LogoutUserAsync ();
@ -97,14 +98,16 @@ namespace IO.Swagger.Api {
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="Username">name that need to be deleted</param>/// <param name="Body">Updated user object</param>
/// <param name="Username">name that need to be deleted</param>
/// <param name="Body">Updated user object</param>
/// <returns></returns>
void UpdateUser (string Username, User Body);
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="Username">name that need to be deleted</param>/// <param name="Body">Updated user object</param>
/// <param name="Username">name that need to be deleted</param>
/// <param name="Body">Updated user object</param>
/// <returns></returns>
Task UpdateUserAsync (string Username, User Body);
@ -136,9 +139,9 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public UserApi(ApiClient apiClient = null) {
if (apiClient == null) { // use the default one in Configuration
this.apiClient = Configuration.apiClient;
this.ApiClient = Configuration.DefaultApiClient;
} else {
this.apiClient = apiClient;
this.ApiClient = apiClient;
}
}
@ -148,7 +151,7 @@ namespace IO.Swagger.Api {
/// <returns></returns>
public UserApi(String basePath)
{
this.apiClient = new ApiClient(basePath);
this.ApiClient = new ApiClient(basePath);
}
/// <summary>
@ -156,7 +159,7 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public void SetBasePath(String basePath) {
this.apiClient.basePath = basePath;
this.ApiClient.BasePath = basePath;
}
/// <summary>
@ -164,14 +167,14 @@ namespace IO.Swagger.Api {
/// </summary>
/// <value>The base path</value>
public String GetBasePath(String basePath) {
return this.apiClient.basePath;
return this.ApiClient.BasePath;
}
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>The API client</value>
public ApiClient apiClient {get; set;}
public ApiClient ApiClient {get; set;}
@ -197,14 +200,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
@ -212,8 +215,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Create user This can only be done by the logged in user.
/// </summary>
/// <param name="Body">Created user object</param>
@ -235,14 +238,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
}
@ -272,14 +275,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
@ -287,8 +290,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name="Body">List of user object</param>
@ -310,14 +313,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
}
@ -347,14 +350,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
@ -362,8 +365,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name="Body">List of user object</param>
@ -385,14 +388,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
}
@ -403,7 +406,8 @@ namespace IO.Swagger.Api {
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name="Username">The user name for login</param>/// <param name="Password">The password for login in clear text</param>
/// <param name="Username">The user name for login</param>
/// <param name="Password">The password for login in clear text</param>
/// <returns>string</returns>
public string LoginUser (string Username, string Password) {
@ -419,8 +423,8 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter
if (Password != null) queryParams.Add("password", apiClient.ParameterToString(Password)); // query parameter
if (Username != null) queryParams.Add("username", ApiClient.ParameterToString(Username)); // query parameter
if (Password != null) queryParams.Add("password", ApiClient.ParameterToString(Password)); // query parameter
@ -430,18 +434,19 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
}
return (string) apiClient.Deserialize(response.Content, typeof(string));
return (string) ApiClient.Deserialize(response.Content, typeof(string));
}
/// <summary>
/// <summary>
/// Logs user into the system
/// </summary>
/// <param name="Username">The user name for login</param>/// <param name="Password">The password for login in clear text</param>
/// <param name="Username">The user name for login</param>
/// <param name="Password">The password for login in clear text</param>
/// <returns>string</returns>
public async Task<string> LoginUserAsync (string Username, string Password) {
@ -457,8 +462,8 @@ namespace IO.Swagger.Api {
var fileParams = new Dictionary<String, String>();
String postBody = null;
if (Username != null) queryParams.Add("username", apiClient.ParameterToString(Username)); // query parameter
if (Password != null) queryParams.Add("password", apiClient.ParameterToString(Password)); // query parameter
if (Username != null) queryParams.Add("username", ApiClient.ParameterToString(Username)); // query parameter
if (Password != null) queryParams.Add("password", ApiClient.ParameterToString(Password)); // query parameter
@ -468,17 +473,16 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
}
return (string) apiClient.Deserialize(response.Content, typeof(string));
return (string) ApiClient.Deserialize(response.Content, typeof(string));
}
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <returns></returns>
public void LogoutUser () {
@ -503,7 +507,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
@ -511,11 +515,10 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <returns></returns>
public async Task LogoutUserAsync () {
@ -540,7 +543,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
}
@ -562,7 +565,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -580,15 +583,15 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
}
return (User) apiClient.Deserialize(response.Content, typeof(User));
return (User) ApiClient.Deserialize(response.Content, typeof(User));
}
/// <summary>
/// <summary>
/// Get user by user name
/// </summary>
/// <param name="Username">The name that needs to be fetched. Use user1 for testing. </param>
@ -602,7 +605,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -620,17 +623,18 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
}
return (User) apiClient.Deserialize(response.Content, typeof(User));
return (User) ApiClient.Deserialize(response.Content, typeof(User));
}
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="Username">name that need to be deleted</param>/// <param name="Body">Updated user object</param>
/// <param name="Username">name that need to be deleted</param>
/// <param name="Body">Updated user object</param>
/// <returns></returns>
public void UpdateUser (string Username, User Body) {
@ -641,7 +645,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -653,14 +657,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
@ -668,11 +672,12 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <summary>
/// Updated user This can only be done by the logged in user.
/// </summary>
/// <param name="Username">name that need to be deleted</param>/// <param name="Body">Updated user object</param>
/// <param name="Username">name that need to be deleted</param>
/// <param name="Body">Updated user object</param>
/// <returns></returns>
public async Task UpdateUserAsync (string Username, User Body) {
@ -683,7 +688,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -695,14 +700,14 @@ namespace IO.Swagger.Api {
postBody = apiClient.Serialize(Body); // http body (model) parameter
postBody = ApiClient.Serialize(Body); // http body (model) parameter
// authentication setting, if any
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
}
@ -724,7 +729,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -742,7 +747,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
@ -750,8 +755,8 @@ namespace IO.Swagger.Api {
return;
}
/// <summary>
/// <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>
@ -765,7 +770,7 @@ namespace IO.Swagger.Api {
var path = "/user/{username}";
path = path.Replace("{format}", "json");
path = path.Replace("{" + "username" + "}", apiClient.ParameterToString(Username));
path = path.Replace("{" + "username" + "}", ApiClient.ParameterToString(Username));
var queryParams = new Dictionary<String, String>();
@ -783,7 +788,7 @@ namespace IO.Swagger.Api {
String[] authSettings = new String[] { };
// 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) {
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
}

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.IO;
using System.Linq;
using System.Net;
@ -19,21 +20,21 @@ namespace IO.Swagger.Client {
/// </summary>
/// <param name="basePath">The base path.</param>
public ApiClient(String basePath="http://petstore.swagger.io/v2") {
this.basePath = basePath;
this.restClient = new RestClient(this.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; }
public string BasePath { get; set; }
/// <summary>
/// Gets or sets the RestClient
/// </summary>
/// <value>The RestClient.</value>
public RestClient restClient { get; set; }
public RestClient RestClient { get; set; }
private Dictionary<String, String> defaultHeaderMap = new Dictionary<String, String>();
@ -77,7 +78,7 @@ namespace IO.Swagger.Client {
request.AddParameter("application/json", PostBody, ParameterType.RequestBody); // http body (model) parameter
}
return (Object) await restClient.ExecuteTaskAsync(request);
return (Object) await RestClient.ExecuteTaskAsync(request);
}
@ -119,10 +120,12 @@ namespace IO.Swagger.Client {
{
if (obj is DateTime) {
return ((DateTime)obj).ToString ("u");
} else if (obj is FileStream) {
return ((FileStream)obj).Name;
} else if (obj is List<string>) {
return String.Join(",", obj as List<string>);
} else {
return Convert.ToString (obj);
return Convert.ToString (obj);
}
}
@ -132,16 +135,38 @@ namespace IO.Swagger.Client {
/// <param name="json"> JSON string
/// <param name="type"> Object type
/// <returns>Object representation of the JSON string</returns>
public object Deserialize(string content, Type type) {
if (type.GetType() == typeof(Object))
return (Object)content;
public object Deserialize(string content, Type type, IList<Parameter> headers=null) {
if (type.GetType() == typeof(Object)) {
return (Object)content;
} else if (type.Name == "FileStream") {
// e.g. Content-Disposition: attachment; filename=checkimage.jpp
String fileName;
String 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();
}
System.IO.File.WriteAllText (fileName, content);
return File.Open (fileName, FileMode.Open);
}
try
{
return JsonConvert.DeserializeObject(content, type);
}
catch (IOException e) {
throw new ApiException(500, e.Message);
throw new ApiException(500, e.Message);
}
}
@ -165,12 +190,12 @@ namespace IO.Swagger.Client {
/// </summary>
/// <param name="obj"> Object
/// <returns>API key with prefix</returns>
public string GetApiKeyWithPrefix (string apiKey)
public string GetApiKeyWithPrefix (string apiKeyIdentifier)
{
var apiKeyValue = "";
Configuration.apiKey.TryGetValue (apiKey, out apiKeyValue);
Configuration.ApiKey.TryGetValue (apiKeyIdentifier, out apiKeyValue);
var apiKeyPrefix = "";
if (Configuration.apiKeyPrefix.TryGetValue (apiKey, out apiKeyPrefix)) {
if (Configuration.ApiKeyPrefix.TryGetValue (apiKeyIdentifier, out apiKeyPrefix)) {
return apiKeyPrefix + " " + apiKeyValue;
} else {
return apiKeyValue;

View File

@ -1,4 +1,5 @@
using System;
using System.Reflection;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@ -17,35 +18,81 @@ namespace IO.Swagger.Client {
public const string Version = "1.0.0";
/// <summary>
/// Gets or sets the API client. This is the default API client for making HTTP calls.
/// Gets or sets the default API client for making HTTP calls.
/// </summary>
/// <value>The API client.</value>
public static ApiClient apiClient = new ApiClient();
public static ApiClient DefaultApiClient = new ApiClient();
/// <summary>
/// Gets or sets the username (HTTP basic authentication)
/// </summary>
/// <value>The username.</value>
public static String username { get; set; }
public static String Username { get; set; }
/// <summary>
/// Gets or sets the password (HTTP basic authentication)
/// </summary>
/// <value>The password.</value>
public static String password { get; set; }
public static String Password { get; set; }
/// <summary>
/// Gets or sets the API key based on the authentication name
/// </summary>
/// <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>
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name
/// </summary>
/// <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>();
private static string _tempFolderPath = Path.GetTempPath();
/// <summary>
/// Gets or sets the temporary folder path to store the files downloaded from the server
/// </summary>
/// <value>Folder path</value>
public static String TempFolderPath {
get {
return _tempFolderPath;
}
set {
if (!String.IsNullOrEmpty(value)) {
_tempFolderPath = value;
return;
}
// create the directory if it does not exist
if (!Directory.Exists(value)) {
Directory.CreateDirectory(value);
}
// check if the path contains directory separator at the end
if (value[value.Length - 1] == Path.DirectorySeparatorChar) {
_tempFolderPath = value;
} else {
_tempFolderPath = value + Path.DirectorySeparatorChar;
}
}
}
/// <summary>
/// Return a string contain essential information for debugging
/// </summary>
/// <value>Folder path</value>
public static String ToDebugReport() {
String report = "C# SDK () Debug Report:\n";
report += " OS: " + Environment.OSVersion + "\n";
report += " .NET Framework Version: " + Assembly
.GetExecutingAssembly()
.GetReferencedAssemblies()
.Where(x => x.Name == "System.Core").First().Version.ToString() + "\n";
report += " Swagger Spec Version: 1.0.0\n";
report += " SDK Package Version: 1.0.0\n";
return report;
}
}
}

View File

@ -1,9 +1,12 @@
<Properties StartupItem="SwaggerClientTest.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs">
<Files>
<File FileName="TestPet.cs" Line="110" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs" Line="11" Column="7" />
<File FileName="TestPet.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs" Line="1" Column="1" />
<File FileName="Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs" Line="791" Column="36" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>