add async with http info method to C# client

This commit is contained in:
wing328
2015-12-03 22:09:40 +08:00
parent dd28075a0e
commit 0cd801b952
10 changed files with 570 additions and 26 deletions

View File

@@ -45,6 +45,16 @@ namespace {{packageName}}.Api
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
{{#returnType}}System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
/// <summary>
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
{{/operation}}
}
@@ -227,6 +237,18 @@ namespace {{packageName}}.Api
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
{{#returnType}}public async System.Threading.Tasks.Task<{{{returnType}}}>{{/returnType}}{{^returnType}}public async System.Threading.Tasks.Task{{/returnType}} {{operationId}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
{{#returnType}}ApiResponse<{{{returnType}}}> response = await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
return response.Data;{{/returnType}}{{^returnType}}await {{operationId}}AsyncWithHttpInfo({{#allParams}}{{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});{{/returnType}}
}
/// <summary>
/// {{summary}} {{notes}}
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
public async System.Threading.Tasks.Task<ApiResponse<{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}Object{{/returnType}}>> {{operationId}}AsyncWithHttpInfo ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}");
@@ -298,8 +320,12 @@ namespace {{packageName}}.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
{{#returnType}}return ({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}
{{#returnType}}return new ApiResponse<{{{returnType}}}>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
({{{returnType}}}) Configuration.ApiClient.Deserialize(response, typeof({{{returnType}}})));{{/returnType}}
{{^returnType}}return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);{{/returnType}}
}
{{/operation}}
}

View File

@@ -44,6 +44,16 @@ namespace IO.Swagger.Api
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task UpdatePetAsync (Pet body = null);
/// <summary>
/// Update an existing pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> UpdatePetAsyncWithHttpInfo (Pet body = null);
/// <summary>
/// Add a new pet to the store
@@ -74,6 +84,16 @@ namespace IO.Swagger.Api
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task AddPetAsync (Pet body = null);
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> AddPetAsyncWithHttpInfo (Pet body = null);
/// <summary>
/// Finds Pets by status
@@ -104,6 +124,16 @@ namespace IO.Swagger.Api
/// <param name="status">Status values that need to be considered for filter</param>
/// <returns></returns>
System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null);
/// <summary>
/// Finds Pets by status
/// </summary>
/// <remarks>
/// Multiple status values can be provided with comma seperated strings
/// </remarks>
/// <param name="status">Status values that need to be considered for filter</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<List<Pet>>> FindPetsByStatusAsyncWithHttpInfo (List<string> status = null);
/// <summary>
/// Finds Pets by tags
@@ -134,6 +164,16 @@ namespace IO.Swagger.Api
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null);
/// <summary>
/// Finds Pets by tags
/// </summary>
/// <remarks>
/// Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
/// </remarks>
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<List<Pet>>> FindPetsByTagsAsyncWithHttpInfo (List<string> tags = null);
/// <summary>
/// Find pet by ID
@@ -164,6 +204,16 @@ namespace IO.Swagger.Api
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Pet</returns>
System.Threading.Tasks.Task<Pet> GetPetByIdAsync (long? petId);
/// <summary>
/// Find pet by ID
/// </summary>
/// <remarks>
/// Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// </remarks>
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Pet</returns>
System.Threading.Tasks.Task<ApiResponse<Pet>> GetPetByIdAsyncWithHttpInfo (long? petId);
/// <summary>
/// Updates a pet in the store with form data
@@ -200,6 +250,18 @@ namespace IO.Swagger.Api
/// <param name="status">Updated status of the pet</param>
/// <returns></returns>
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null);
/// <summary>
/// Updates a pet in the store with form data
/// </summary>
/// <remarks>
///
/// </remarks>
/// <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>
System.Threading.Tasks.Task<ApiResponse<Object>> UpdatePetWithFormAsyncWithHttpInfo (string petId, string name = null, string status = null);
/// <summary>
/// Deletes a pet
@@ -233,6 +295,17 @@ namespace IO.Swagger.Api
/// <param name="apiKey"></param>
/// <returns></returns>
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null);
/// <summary>
/// Deletes a pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null);
/// <summary>
/// uploads an image
@@ -269,6 +342,18 @@ namespace IO.Swagger.Api
/// <param name="file">file to upload</param>
/// <returns></returns>
System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null);
/// <summary>
/// uploads an image
/// </summary>
/// <remarks>
///
/// </remarks>
/// <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>
System.Threading.Tasks.Task<ApiResponse<Object>> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null);
}
@@ -426,6 +511,17 @@ namespace IO.Swagger.Api
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public async System.Threading.Tasks.Task UpdatePetAsync (Pet body = null)
{
await UpdatePetAsyncWithHttpInfo(body);
}
/// <summary>
/// Update an existing pet
/// </summary>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> UpdatePetAsyncWithHttpInfo (Pet body = null)
{
@@ -477,7 +573,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling UpdatePet: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -558,6 +656,17 @@ namespace IO.Swagger.Api
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public async System.Threading.Tasks.Task AddPetAsync (Pet body = null)
{
await AddPetAsyncWithHttpInfo(body);
}
/// <summary>
/// Add a new pet to the store
/// </summary>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> AddPetAsyncWithHttpInfo (Pet body = null)
{
@@ -609,7 +718,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling AddPet: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -691,6 +802,18 @@ namespace IO.Swagger.Api
/// <param name="status">Status values that need to be considered for filter</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null)
{
ApiResponse<List<Pet>> response = await FindPetsByStatusAsyncWithHttpInfo(status);
return response.Data;
}
/// <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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<List<Pet>>> FindPetsByStatusAsyncWithHttpInfo (List<string> status = null)
{
@@ -741,7 +864,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling FindPetsByStatus: " + response.ErrorMessage, response.ErrorMessage);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
return new ApiResponse<List<Pet>>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>)));
}
/// <summary>
@@ -823,6 +949,18 @@ namespace IO.Swagger.Api
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null)
{
ApiResponse<List<Pet>> response = await FindPetsByTagsAsyncWithHttpInfo(tags);
return response.Data;
}
/// <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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<List<Pet>>> FindPetsByTagsAsyncWithHttpInfo (List<string> tags = null)
{
@@ -873,7 +1011,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling FindPetsByTags: " + response.ErrorMessage, response.ErrorMessage);
return (List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>));
return new ApiResponse<List<Pet>>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(List<Pet>) Configuration.ApiClient.Deserialize(response, typeof(List<Pet>)));
}
/// <summary>
@@ -958,6 +1099,18 @@ namespace IO.Swagger.Api
/// <param name="petId">ID of pet that needs to be fetched</param>
/// <returns>Pet</returns>
public async System.Threading.Tasks.Task<Pet> GetPetByIdAsync (long? petId)
{
ApiResponse<Pet> response = await GetPetByIdAsyncWithHttpInfo(petId);
return response.Data;
}
/// <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>
/// <returns>Pet</returns>
public async System.Threading.Tasks.Task<ApiResponse<Pet>> GetPetByIdAsyncWithHttpInfo (long? petId)
{
// verify the required parameter 'petId' is set
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling GetPetById");
@@ -1010,7 +1163,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling GetPetById: " + response.ErrorMessage, response.ErrorMessage);
return (Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet));
return new ApiResponse<Pet>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Pet) Configuration.ApiClient.Deserialize(response, typeof(Pet)));
}
/// <summary>
@@ -1102,6 +1258,19 @@ namespace IO.Swagger.Api
/// <param name="status">Updated status of the pet</param>
/// <returns></returns>
public async System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null)
{
await UpdatePetWithFormAsyncWithHttpInfo(petId, name, 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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> UpdatePetWithFormAsyncWithHttpInfo (string petId, string name = null, string status = null)
{
// verify the required parameter 'petId' is set
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UpdatePetWithForm");
@@ -1157,7 +1326,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling UpdatePetWithForm: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -1245,6 +1416,18 @@ namespace IO.Swagger.Api
/// <param name="apiKey"></param>
/// <returns></returns>
public async System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null)
{
await DeletePetAsyncWithHttpInfo(petId, apiKey);
}
/// <summary>
/// Deletes a pet
/// </summary>
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> DeletePetAsyncWithHttpInfo (long? petId, string apiKey = null)
{
// verify the required parameter 'petId' is set
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling DeletePet");
@@ -1299,7 +1482,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling DeletePet: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -1391,6 +1576,19 @@ namespace IO.Swagger.Api
/// <param name="file">file to upload</param>
/// <returns></returns>
public async System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null)
{
await UploadFileAsyncWithHttpInfo(petId, additionalMetadata, 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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> UploadFileAsyncWithHttpInfo (long? petId, string additionalMetadata = null, Stream file = null)
{
// verify the required parameter 'petId' is set
if (petId == null) throw new ApiException(400, "Missing required parameter 'petId' when calling UploadFile");
@@ -1446,7 +1644,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling UploadFile: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
}

View File

@@ -41,6 +41,15 @@ namespace IO.Swagger.Api
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task<Dictionary<string, int?>> GetInventoryAsync ();
/// <summary>
/// Returns pet inventories by status
/// </summary>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Dictionary<string, int?>>> GetInventoryAsyncWithHttpInfo ();
/// <summary>
/// Place an order for a pet
@@ -71,6 +80,16 @@ namespace IO.Swagger.Api
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null);
/// <summary>
/// Place an order for a pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
System.Threading.Tasks.Task<ApiResponse<Order>> PlaceOrderAsyncWithHttpInfo (Order body = null);
/// <summary>
/// Find purchase order by ID
@@ -101,6 +120,16 @@ namespace IO.Swagger.Api
/// <param name="orderId">ID of pet that needs to be fetched</param>
/// <returns>Order</returns>
System.Threading.Tasks.Task<Order> GetOrderByIdAsync (string orderId);
/// <summary>
/// Find purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
/// </remarks>
/// <param name="orderId">ID of pet that needs to be fetched</param>
/// <returns>Order</returns>
System.Threading.Tasks.Task<ApiResponse<Order>> GetOrderByIdAsyncWithHttpInfo (string orderId);
/// <summary>
/// Delete purchase order by ID
@@ -131,6 +160,16 @@ namespace IO.Swagger.Api
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <returns></returns>
System.Threading.Tasks.Task DeleteOrderAsync (string orderId);
/// <summary>
/// Delete purchase order by ID
/// </summary>
/// <remarks>
/// For valid response try integer IDs with value &lt; 1000. Anything above 1000 or nonintegers will generate API errors
/// </remarks>
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> DeleteOrderAsyncWithHttpInfo (string orderId);
}
@@ -285,6 +324,17 @@ namespace IO.Swagger.Api
/// </summary>
/// <returns></returns>
public async System.Threading.Tasks.Task<Dictionary<string, int?>> GetInventoryAsync ()
{
ApiResponse<Dictionary<string, int?>> response = await GetInventoryAsyncWithHttpInfo();
return response.Data;
}
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Dictionary<string, int?>>> GetInventoryAsyncWithHttpInfo ()
{
@@ -334,7 +384,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling GetInventory: " + response.ErrorMessage, response.ErrorMessage);
return (Dictionary<string, int?>) Configuration.ApiClient.Deserialize(response, typeof(Dictionary<string, int?>));
return new ApiResponse<Dictionary<string, int?>>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Dictionary<string, int?>) Configuration.ApiClient.Deserialize(response, typeof(Dictionary<string, int?>)));
}
/// <summary>
@@ -408,6 +461,18 @@ namespace IO.Swagger.Api
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null)
{
ApiResponse<Order> response = await PlaceOrderAsyncWithHttpInfo(body);
return response.Data;
}
/// <summary>
/// Place an order for a pet
/// </summary>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
public async System.Threading.Tasks.Task<ApiResponse<Order>> PlaceOrderAsyncWithHttpInfo (Order body = null)
{
@@ -450,7 +515,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling PlaceOrder: " + response.ErrorMessage, response.ErrorMessage);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
return new ApiResponse<Order>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Order) Configuration.ApiClient.Deserialize(response, typeof(Order)));
}
/// <summary>
@@ -527,6 +595,18 @@ namespace IO.Swagger.Api
/// <param name="orderId">ID of pet that needs to be fetched</param>
/// <returns>Order</returns>
public async System.Threading.Tasks.Task<Order> GetOrderByIdAsync (string orderId)
{
ApiResponse<Order> response = await GetOrderByIdAsyncWithHttpInfo(orderId);
return response.Data;
}
/// <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>
/// <returns>Order</returns>
public async System.Threading.Tasks.Task<ApiResponse<Order>> GetOrderByIdAsyncWithHttpInfo (string orderId)
{
// verify the required parameter 'orderId' is set
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling GetOrderById");
@@ -571,7 +651,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling GetOrderById: " + response.ErrorMessage, response.ErrorMessage);
return (Order) Configuration.ApiClient.Deserialize(response, typeof(Order));
return new ApiResponse<Order>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(Order) Configuration.ApiClient.Deserialize(response, typeof(Order)));
}
/// <summary>
@@ -647,6 +730,17 @@ namespace IO.Swagger.Api
/// <param name="orderId">ID of the order that needs to be deleted</param>
/// <returns></returns>
public async System.Threading.Tasks.Task DeleteOrderAsync (string orderId)
{
await DeleteOrderAsyncWithHttpInfo(orderId);
}
/// <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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> DeleteOrderAsyncWithHttpInfo (string orderId)
{
// verify the required parameter 'orderId' is set
if (orderId == null) throw new ApiException(400, "Missing required parameter 'orderId' when calling DeleteOrder");
@@ -692,7 +786,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling DeleteOrder: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
}

View File

@@ -44,6 +44,16 @@ namespace IO.Swagger.Api
/// <param name="body">Created user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUserAsync (User body = null);
/// <summary>
/// Create user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name="body">Created user object</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> CreateUserAsyncWithHttpInfo (User body = null);
/// <summary>
/// Creates list of users with given input array
@@ -74,6 +84,16 @@ namespace IO.Swagger.Api
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> CreateUsersWithArrayInputAsyncWithHttpInfo (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
@@ -104,6 +124,16 @@ namespace IO.Swagger.Api
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> CreateUsersWithListInputAsyncWithHttpInfo (List<User> body = null);
/// <summary>
/// Logs user into the system
@@ -137,6 +167,17 @@ namespace IO.Swagger.Api
/// <param name="password">The password for login in clear text</param>
/// <returns>string</returns>
System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null);
/// <summary>
/// Logs user into the system
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="username">The user name for login</param>
/// <param name="password">The password for login in clear text</param>
/// <returns>string</returns>
System.Threading.Tasks.Task<ApiResponse<string>> LoginUserAsyncWithHttpInfo (string username = null, string password = null);
/// <summary>
/// Logs out current logged in user session
@@ -164,6 +205,15 @@ namespace IO.Swagger.Api
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task LogoutUserAsync ();
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <remarks>
///
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> LogoutUserAsyncWithHttpInfo ();
/// <summary>
/// Get user by user name
@@ -194,6 +244,16 @@ namespace IO.Swagger.Api
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
/// <returns>User</returns>
System.Threading.Tasks.Task<User> GetUserByNameAsync (string username);
/// <summary>
/// Get user by user name
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
/// <returns>User</returns>
System.Threading.Tasks.Task<ApiResponse<User>> GetUserByNameAsyncWithHttpInfo (string username);
/// <summary>
/// Updated user
@@ -227,6 +287,17 @@ namespace IO.Swagger.Api
/// <param name="body">Updated user object</param>
/// <returns></returns>
System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null);
/// <summary>
/// Updated user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name="username">name that need to be deleted</param>
/// <param name="body">Updated user object</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> UpdateUserAsyncWithHttpInfo (string username, User body = null);
/// <summary>
/// Delete user
@@ -257,6 +328,16 @@ namespace IO.Swagger.Api
/// <param name="username">The name that needs to be deleted</param>
/// <returns></returns>
System.Threading.Tasks.Task DeleteUserAsync (string username);
/// <summary>
/// Delete user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name="username">The name that needs to be deleted</param>
/// <returns></returns>
System.Threading.Tasks.Task<ApiResponse<Object>> DeleteUserAsyncWithHttpInfo (string username);
}
@@ -406,6 +487,17 @@ namespace IO.Swagger.Api
/// <param name="body">Created user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUserAsync (User body = null)
{
await CreateUserAsyncWithHttpInfo(body);
}
/// <summary>
/// Create user This can only be done by the logged in user.
/// </summary>
/// <param name="body">Created user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> CreateUserAsyncWithHttpInfo (User body = null)
{
@@ -449,7 +541,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling CreateUser: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -522,6 +616,17 @@ namespace IO.Swagger.Api
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null)
{
await CreateUsersWithArrayInputAsyncWithHttpInfo(body);
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> CreateUsersWithArrayInputAsyncWithHttpInfo (List<User> body = null)
{
@@ -565,7 +670,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling CreateUsersWithArrayInput: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -638,6 +745,17 @@ namespace IO.Swagger.Api
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null)
{
await CreateUsersWithListInputAsyncWithHttpInfo(body);
}
/// <summary>
/// Creates list of users with given input array
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> CreateUsersWithListInputAsyncWithHttpInfo (List<User> body = null)
{
@@ -681,7 +799,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling CreateUsersWithListInput: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -759,6 +879,19 @@ namespace IO.Swagger.Api
/// <param name="password">The password for login in clear text</param>
/// <returns>string</returns>
public async System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null)
{
ApiResponse<string> response = await LoginUserAsyncWithHttpInfo(username, password);
return response.Data;
}
/// <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>
/// <returns>string</returns>
public async System.Threading.Tasks.Task<ApiResponse<string>> LoginUserAsyncWithHttpInfo (string username = null, string password = null)
{
@@ -802,7 +935,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling LoginUser: " + response.ErrorMessage, response.ErrorMessage);
return (string) Configuration.ApiClient.Deserialize(response, typeof(string));
return new ApiResponse<string>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(string) Configuration.ApiClient.Deserialize(response, typeof(string)));
}
/// <summary>
@@ -871,6 +1007,16 @@ namespace IO.Swagger.Api
/// </summary>
/// <returns></returns>
public async System.Threading.Tasks.Task LogoutUserAsync ()
{
await LogoutUserAsyncWithHttpInfo();
}
/// <summary>
/// Logs out current logged in user session
/// </summary>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> LogoutUserAsyncWithHttpInfo ()
{
@@ -913,7 +1059,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling LogoutUser: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -990,6 +1138,18 @@ namespace IO.Swagger.Api
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
/// <returns>User</returns>
public async System.Threading.Tasks.Task<User> GetUserByNameAsync (string username)
{
ApiResponse<User> response = await GetUserByNameAsyncWithHttpInfo(username);
return response.Data;
}
/// <summary>
/// Get user by user name
/// </summary>
/// <param name="username">The name that needs to be fetched. Use user1 for testing.</param>
/// <returns>User</returns>
public async System.Threading.Tasks.Task<ApiResponse<User>> GetUserByNameAsyncWithHttpInfo (string username)
{
// verify the required parameter 'username' is set
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling GetUserByName");
@@ -1034,7 +1194,10 @@ namespace IO.Swagger.Api
else if (statusCode == 0)
throw new ApiException (statusCode, "Error calling GetUserByName: " + response.ErrorMessage, response.ErrorMessage);
return (User) Configuration.ApiClient.Deserialize(response, typeof(User));
return new ApiResponse<User>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
(User) Configuration.ApiClient.Deserialize(response, typeof(User)));
}
/// <summary>
@@ -1114,6 +1277,18 @@ namespace IO.Swagger.Api
/// <param name="body">Updated user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null)
{
await UpdateUserAsyncWithHttpInfo(username, 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>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> UpdateUserAsyncWithHttpInfo (string username, User body = null)
{
// verify the required parameter 'username' is set
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling UpdateUser");
@@ -1160,7 +1335,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling UpdateUser: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
/// <summary>
@@ -1236,6 +1413,17 @@ namespace IO.Swagger.Api
/// <param name="username">The name that needs to be deleted</param>
/// <returns></returns>
public async System.Threading.Tasks.Task DeleteUserAsync (string username)
{
await DeleteUserAsyncWithHttpInfo(username);
}
/// <summary>
/// Delete user This can only be done by the logged in user.
/// </summary>
/// <param name="username">The name that needs to be deleted</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<ApiResponse<Object>> DeleteUserAsyncWithHttpInfo (string username)
{
// verify the required parameter 'username' is set
if (username == null) throw new ApiException(400, "Missing required parameter 'username' when calling DeleteUser");
@@ -1281,7 +1469,9 @@ namespace IO.Swagger.Api
throw new ApiException (statusCode, "Error calling DeleteUser: " + response.ErrorMessage, response.ErrorMessage);
return;
return new ApiResponse<Object>(statusCode,
response.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()),
null);
}
}

View File

@@ -76,6 +76,38 @@ namespace SwaggerClient.TestPet
}
/// <summary>
/// Test GetPetByIdAsyncWithHttpInfo
/// </summary>
[Test ()]
public void TestGetPetByIdAsyncWithHttpInfo ()
{
PetApi petApi = new PetApi ();
var task = petApi.GetPetByIdAsyncWithHttpInfo (petId);
Assert.AreEqual (200, task.Result.StatusCode);
Assert.IsTrue (task.Result.Headers.ContainsKey("Content-Type"));
Assert.AreEqual (task.Result.Headers["Content-Type"], "application/json");
Pet response = task.Result.Data;
Assert.IsInstanceOf<Pet> (response, "Response is a Pet");
Assert.AreEqual ("Csharp test", response.Name);
Assert.AreEqual ("available", response.Status);
Assert.IsInstanceOf<List<Tag>> (response.Tags, "Response.Tags is a Array");
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual ("sample tag name1", response.Tags [0].Name);
Assert.IsInstanceOf<List<String>> (response.PhotoUrls, "Response.PhotoUrls is a Array");
Assert.AreEqual ("sample photoUrls", response.PhotoUrls [0]);
Assert.IsInstanceOf<Category> (response.Category, "Response.Category is a Category");
Assert.AreEqual (56, response.Category.Id);
Assert.AreEqual ("sample category name2", response.Category.Name);
}
/// <summary>
/// Test GetPetById
/// </summary>
@@ -252,7 +284,7 @@ namespace SwaggerClient.TestPet
// there should be a warning for using AddDefaultHeader (deprecated) below
petApi.AddDefaultHeader ("header_key", "header_value");
// the following should be used instead as suggested in the doc
petApi.Configuration.AddDefaultHeader ("header_key", "header_value");
petApi.Configuration.AddDefaultHeader ("header_key2", "header_value2");
}
}

View File

@@ -1,8 +1,8 @@
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/.NETFramework,Version=v4.5.AssemblyAttribute.cs
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/Newtonsoft.Json.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/nunit.framework.dll
/Users/williamcheng/Code/wing328/swagger-codegen/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/RestSharp.dll