add test case for status code and response header

This commit is contained in:
wing328 2015-12-01 14:08:20 +08:00
parent 6405fba663
commit c9f2380f0f
9 changed files with 311 additions and 108 deletions

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using RestSharp;
using {{packageName}}.Client;
{{#hasImport}}using {{packageName}}.Model;
@ -91,6 +92,16 @@ namespace {{packageName}}.Api
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Gets the status code of the previous request
/// </summary>
public int StatusCode { get; private set; }
/// <summary>
/// Gets the response headers of the previous request
/// </summary>
public Dictionary<String, String> ResponseHeaders { get; private set; }
{{#operation}}
/// <summary>
/// {{summary}} {{notes}}
@ -163,10 +174,13 @@ namespace {{packageName}}.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
{{#returnType}}return ({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}return;{{/returnType}}
}
@ -240,8 +254,12 @@ namespace {{packageName}}.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
{{#returnType}}return ({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
@ -203,7 +204,7 @@ namespace IO.Swagger.Api
/// <summary>
/// Initializes a new instance of the <see cref="PetApi"/> class
/// using Configuration object
/// using Configuration object.
/// </summary>
/// <param name="configuration">An instance of Configuration</param>
/// <returns></returns>
@ -235,11 +236,20 @@ namespace IO.Swagger.Api
}
/// <summary>
/// Gets or sets the configuration object
/// Gets or sets the configuration object.
/// </summary>
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Gets the status code of the previous request.
/// </summary>
public int StatusCode { get; private set; }
/// <summary>
/// Gets the response headers of the previous request.
/// </summary>
public Dictionary<String, String> ResponseHeaders { get; private set; }
/// <summary>
/// Update an existing pet
@ -290,10 +300,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -346,8 +359,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdatePet: " + response.Content, response.Content);
return;
@ -402,10 +419,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling AddPet: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -458,8 +478,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling AddPet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling AddPet: " + response.Content, response.Content);
return;
@ -514,10 +538,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
}
@ -570,8 +597,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling FindPetsByStatus: " + response.Content, response.Content);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
}
@ -625,10 +656,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
}
@ -681,8 +715,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling FindPetsByTags: " + response.Content, response.Content);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
}
@ -739,10 +777,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
return (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet));
}
@ -797,8 +838,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetPetById: " + response.Content, response.Content);
return (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet));
}
@ -859,10 +904,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -921,8 +969,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdatePetWithForm: " + response.Content, response.Content);
return;
@ -982,10 +1034,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -1042,8 +1097,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeletePet: " + response.Content, response.Content);
return;
@ -1105,10 +1164,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -1167,8 +1229,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UploadFile: " + response.Content, response.Content);
return;

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
@ -148,6 +149,16 @@ namespace IO.Swagger.Api
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Gets the status code of the previous request
/// </summary>
public int StatusCode { get; private set; }
/// <summary>
/// Gets the response headers of the previous request
/// </summary>
public Dictionary<String, String> ResponseHeaders { get; private set; }
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
@ -196,10 +207,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
return (Dictionary<string, int?>) Configuration.ApiClient.Deserialize(response, typeof(Dictionary<string, int?>));
}
@ -250,8 +264,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetInventory: " + response.Content, response.Content);
return (Dictionary<string, int?>) Configuration.ApiClient.Deserialize(response, typeof(Dictionary<string, int?>));
}
@ -297,10 +315,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
}
@ -345,8 +366,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling PlaceOrder: " + response.Content, response.Content);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
}
@ -395,10 +420,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
}
@ -445,8 +473,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetOrderById: " + response.Content, response.Content);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
}
@ -495,10 +527,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -545,8 +580,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeleteOrder: " + response.Content, response.Content);
return;

View File

@ -1,6 +1,7 @@
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using RestSharp;
using IO.Swagger.Client;
using IO.Swagger.Model;
@ -232,6 +233,16 @@ namespace IO.Swagger.Api
/// <value>An instance of the Configuration</value>
public Configuration Configuration {get; set;}
/// <summary>
/// Gets the status code of the previous request
/// </summary>
public int StatusCode { get; private set; }
/// <summary>
/// Gets the response headers of the previous request
/// </summary>
public Dictionary<String, String> ResponseHeaders { get; private set; }
/// <summary>
/// Create user This can only be done by the logged in user.
@ -274,10 +285,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -322,8 +336,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUser: " + response.Content, response.Content);
return;
@ -370,10 +388,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -418,8 +439,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUsersWithArrayInput: " + response.Content, response.Content);
return;
@ -466,10 +491,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -514,8 +542,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.POST, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling CreateUsersWithListInput: " + response.Content, response.Content);
return;
@ -564,10 +596,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage);
return (string) Configuration.ApiClient.Deserialize(response, typeof(string));
}
@ -614,8 +649,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling LoginUser: " + response.Content, response.Content);
return (string) Configuration.ApiClient.Deserialize(response, typeof(string));
}
@ -659,10 +698,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -705,8 +747,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling LogoutUser: " + response.Content, response.Content);
return;
@ -756,10 +802,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage);
return (User) Configuration.ApiClient.Deserialize(response, typeof(User));
}
@ -806,8 +855,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.GET, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling GetUserByName: " + response.Content, response.Content);
return (User) Configuration.ApiClient.Deserialize(response, typeof(User));
}
@ -858,10 +911,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -910,8 +966,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.PUT, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling UpdateUser: " + response.Content, response.Content);
return;
@ -961,10 +1021,13 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) Configuration.ApiClient.CallApi(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException (StatusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage);
return;
}
@ -1011,8 +1074,12 @@ namespace IO.Swagger.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await Configuration.ApiClient.CallApiAsync(path_, Method.DELETE, queryParams, postBody, headerParams, formParams, fileParams, pathParams);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
StatusCode = (int) response.StatusCode;
ResponseHeaders = response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString());
if (StatusCode >= 400)
throw new ApiException (StatusCode, "Error calling DeleteUser: " + response.Content, response.Content);
return;

View File

@ -229,6 +229,19 @@ namespace SwaggerClient.TestPet
}
/// <summary>
/// Test status code
/// </summary>
[Test ()]
public void TestStatusCodeAndHeader ()
{
PetApi petApi = new PetApi ();
petApi.GetPetById (petId);
Assert.AreEqual (petApi.StatusCode, 200);
Assert.IsTrue (petApi.ResponseHeaders.ContainsKey("Content-Type"));
Assert.AreEqual (petApi.ResponseHeaders["Content-Type"], "application/json");
}
}
}