Merge pull request #1333 from wing328/csharp_fix_accept

[C#] better Accept header selection for C# API client
This commit is contained in:
wing328 2015-10-06 18:26:02 +08:00
commit 228e039046
12 changed files with 669 additions and 79 deletions

View File

@ -326,6 +326,21 @@ namespace {{packageName}}.Client
}
}
}
/// <summary>
/// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it;
/// otherwise use all of them (joining into a string)
/// </summary>
/// <param name="accepts">The accepts array to select from.</param>
/// <returns>The Accept header to use.</returns>
public String SelectHeaderAccept(String[] accepts) {
if (accepts.Length == 0)
return null;
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
return "application/json";
return String.Join(",", accepts);
}
/// <summary>
/// Encode string in base64 format.

View File

@ -16,15 +16,21 @@ namespace {{packageName}}.Api
{
{{#operation}}
/// <summary>
/// {{summary}} {{notes}}
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
/// <summary>
/// {{summary}} {{notes}}
/// {{summary}}
/// </summary>
/// <remarks>
/// {{notes}}
/// </remarks>
{{#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}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
@ -105,6 +111,16 @@ namespace {{packageName}}.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
{{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // path parameter
{{/pathParams}}
@ -150,7 +166,17 @@ namespace {{packageName}}.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
{{#produces}}"{{mediaType}}"{{#hasMore}}, {{/hasMore}}{{/produces}}
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
{{#pathParams}}if ({{paramName}} != null) pathParams.Add("{{baseName}}", ApiClient.ParameterToString({{paramName}})); // path parameter
{{/pathParams}}

View File

@ -8,82 +8,118 @@ using IO.Swagger.Model;
namespace IO.Swagger.Api
{
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface IPetApi
{
/// <summary>
/// Update an existing pet
/// Update an existing pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
void UpdatePet (Pet body);
/// <summary>
/// Update an existing pet
/// 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 UpdatePetAsync (Pet body);
/// <summary>
/// Add a new pet to the store
/// 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>
void AddPet (Pet body);
/// <summary>
/// Add a new pet to the store
/// 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 AddPetAsync (Pet body);
/// <summary>
/// Finds Pets by status Multiple status values can be provided with comma seperated strings
/// 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>List<Pet></returns>
/// <returns></returns>
List<Pet> FindPetsByStatus (List<string> status);
/// <summary>
/// Finds Pets by status Multiple status values can be provided with comma seperated strings
/// 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>List<Pet></returns>
/// <returns></returns>
System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status);
/// <summary>
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
/// 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>List<Pet></returns>
/// <returns></returns>
List<Pet> FindPetsByTags (List<string> tags);
/// <summary>
/// Finds Pets by tags Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.
/// 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>List<Pet></returns>
/// <returns></returns>
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags);
/// <summary>
/// Find pet by ID Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// 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>
Pet GetPetById (long? petId);
/// <summary>
/// Find pet by ID Returns a pet when ID &lt; 10. ID &gt; 10 or nonintegers will simulate API error conditions
/// 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<Pet> GetPetByIdAsync (long? petId);
/// <summary>
/// Updates a pet in the store with form data
/// 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>
@ -91,8 +127,11 @@ namespace IO.Swagger.Api
void UpdatePetWithForm (string petId, string name, string status);
/// <summary>
/// Updates a pet in the store with form data
/// 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>
@ -100,24 +139,33 @@ namespace IO.Swagger.Api
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name, string status);
/// <summary>
/// Deletes a pet
/// Deletes a pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
void DeletePet (long? petId, string apiKey);
/// <summary>
/// Deletes a pet
/// Deletes a pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey);
/// <summary>
/// uploads an image
/// 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>
@ -125,8 +173,11 @@ namespace IO.Swagger.Api
void UploadFile (long? petId, string additionalMetadata, Stream file);
/// <summary>
/// uploads an image
/// 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>
@ -184,7 +235,7 @@ namespace IO.Swagger.Api
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>An instance of the ApiClient</param>
/// <value>An instance of the ApiClient</value>
public ApiClient ApiClient {get; set;}
@ -206,6 +257,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -245,7 +306,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -284,6 +355,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -323,7 +404,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -348,7 +439,7 @@ namespace IO.Swagger.Api
/// 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>List<Pet></returns>
/// <returns></returns>
public List<Pet> FindPetsByStatus (List<string> status)
{
@ -362,6 +453,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (status != null) queryParams.Add("status", ApiClient.ParameterToString(status)); // query parameter
@ -388,7 +489,7 @@ namespace IO.Swagger.Api
/// 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>List<Pet></returns>
/// <returns></returns>
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status)
{
@ -401,7 +502,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (status != null) queryParams.Add("status", ApiClient.ParameterToString(status)); // query parameter
@ -425,7 +536,7 @@ namespace IO.Swagger.Api
/// 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>List<Pet></returns>
/// <returns></returns>
public List<Pet> FindPetsByTags (List<string> tags)
{
@ -439,6 +550,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (tags != null) queryParams.Add("tags", ApiClient.ParameterToString(tags)); // query parameter
@ -465,7 +586,7 @@ namespace IO.Swagger.Api
/// 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>List<Pet></returns>
/// <returns></returns>
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags)
{
@ -478,7 +599,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (tags != null) queryParams.Add("tags", ApiClient.ParameterToString(tags)); // query parameter
@ -519,6 +650,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -560,7 +701,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -603,6 +754,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -648,7 +809,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -693,6 +864,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -736,7 +917,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -781,6 +972,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter
@ -826,7 +1027,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (petId != null) pathParams.Add("petId", ApiClient.ParameterToString(petId)); // path parameter

View File

@ -8,59 +8,86 @@ using IO.Swagger.Model;
namespace IO.Swagger.Api
{
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface IStoreApi
{
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// Returns pet inventories by status
/// </summary>
/// <returns>Dictionary<string, int?></returns>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <returns></returns>
Dictionary<string, int?> GetInventory ();
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// Returns pet inventories by status
/// </summary>
/// <returns>Dictionary<string, int?></returns>
/// <remarks>
/// Returns a map of status codes to quantities
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task<Dictionary<string, int?>> GetInventoryAsync ();
/// <summary>
/// Place an order for a pet
/// Place an order for a pet
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
Order PlaceOrder (Order body);
/// <summary>
/// Place an order for a pet
/// 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<Order> PlaceOrderAsync (Order body);
/// <summary>
/// Find purchase order by ID For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
/// 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>
Order GetOrderById (string orderId);
/// <summary>
/// Find purchase order by ID For valid response try integer IDs with value &lt;= 5 or &gt; 10. Other values will generated exceptions
/// 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<Order> GetOrderByIdAsync (string 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
/// 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>
void DeleteOrder (string 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
/// 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 DeleteOrderAsync (string orderId);
@ -116,14 +143,14 @@ namespace IO.Swagger.Api
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>An instance of the ApiClient</param>
/// <value>An instance of the ApiClient</value>
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>
/// <returns></returns>
public Dictionary<string, int?> GetInventory ()
{
@ -137,6 +164,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -161,7 +198,7 @@ namespace IO.Swagger.Api
/// <summary>
/// Returns pet inventories by status Returns a map of status codes to quantities
/// </summary>
/// <returns>Dictionary<string, int?></returns>
/// <returns></returns>
public async System.Threading.Tasks.Task<Dictionary<string, int?>> GetInventoryAsync ()
{
@ -174,7 +211,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -211,6 +258,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -250,7 +307,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -291,6 +358,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter
@ -332,7 +409,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter
@ -373,6 +460,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter
@ -414,7 +511,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (orderId != null) pathParams.Add("orderId", ApiClient.ParameterToString(orderId)); // path parameter

View File

@ -8,119 +8,170 @@ using IO.Swagger.Model;
namespace IO.Swagger.Api
{
/// <summary>
/// Represents a collection of functions to interact with the API endpoints
/// </summary>
public interface IUserApi
{
/// <summary>
/// Create user This can only be done by the logged in user.
/// Create user
/// </summary>
/// <remarks>
/// This can only be done by the logged in user.
/// </remarks>
/// <param name="body">Created user object</param>
/// <returns></returns>
void CreateUser (User body);
/// <summary>
/// Create user This can only be done by the logged in user.
/// 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 CreateUserAsync (User body);
/// <summary>
/// Creates list of users with given input array
/// Creates list of users with given input array
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
void CreateUsersWithArrayInput (List<User> body);
/// <summary>
/// Creates list of users with given input array
/// 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 CreateUsersWithArrayInputAsync (List<User> body);
/// <summary>
/// Creates list of users with given input array
/// Creates list of users with given input array
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
void CreateUsersWithListInput (List<User> body);
/// <summary>
/// Creates list of users with given input array
/// 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 CreateUsersWithListInputAsync (List<User> body);
/// <summary>
/// Logs user into the system
/// 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>
string LoginUser (string username, string password);
/// <summary>
/// Logs user into the system
/// 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<string> LoginUserAsync (string username, string password);
/// <summary>
/// Logs out current logged in user session
/// Logs out current logged in user session
/// </summary>
/// <remarks>
///
/// </remarks>
/// <returns></returns>
void LogoutUser ();
/// <summary>
/// Logs out current logged in user session
/// Logs out current logged in user session
/// </summary>
/// <remarks>
///
/// </remarks>
/// <returns></returns>
System.Threading.Tasks.Task LogoutUserAsync ();
/// <summary>
/// Get user by user name
/// 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>
User GetUserByName (string username);
/// <summary>
/// Get user by user name
/// 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<User> GetUserByNameAsync (string username);
/// <summary>
/// Updated user This can only be done by the logged in user.
/// 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>
void UpdateUser (string username, User body);
/// <summary>
/// Updated user This can only be done by the logged in user.
/// 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 UpdateUserAsync (string username, User body);
/// <summary>
/// Delete user This can only be done by the logged in user.
/// 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>
void DeleteUser (string username);
/// <summary>
/// Delete user This can only be done by the logged in user.
/// 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 DeleteUserAsync (string username);
@ -176,7 +227,7 @@ namespace IO.Swagger.Api
/// <summary>
/// Gets or sets the API client.
/// </summary>
/// <value>An instance of the ApiClient</param>
/// <value>An instance of the ApiClient</value>
public ApiClient ApiClient {get; set;}
@ -198,6 +249,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -237,7 +298,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -276,6 +347,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -315,7 +396,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -354,6 +445,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -393,7 +494,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -433,6 +544,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) queryParams.Add("username", ApiClient.ParameterToString(username)); // query parameter
@ -474,7 +595,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) queryParams.Add("username", ApiClient.ParameterToString(username)); // query parameter
@ -512,6 +643,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -549,7 +690,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
@ -590,6 +741,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter
@ -631,7 +792,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter
@ -673,6 +844,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter
@ -716,7 +897,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter
@ -759,6 +950,16 @@ namespace IO.Swagger.Api
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter
@ -800,7 +1001,17 @@ namespace IO.Swagger.Api
var formParams = new Dictionary<String, String>();
var fileParams = new Dictionary<String, FileParameter>();
String postBody = null;
// to determine the Accept header
String[] http_header_accepts = new String[] {
"application/json", "application/xml"
};
String http_header_accept = ApiClient.SelectHeaderAccept(http_header_accepts);
if (http_header_accept != null)
headerParams.Add("Accept", ApiClient.SelectHeaderAccept(http_header_accepts));
// set "format" to json by default
// e.g. /pet/{petId}.{format} becomes /pet/{petId}.json
pathParams.Add("format", "json");
if (username != null) pathParams.Add("username", ApiClient.ParameterToString(username)); // path parameter

View File

@ -216,6 +216,7 @@ namespace IO.Swagger.Client
/// </summary>
/// <param name="content">HTTP body (e.g. string, JSON).</param>
/// <param name="type">Object type.</param>
/// <param name="headers"></param>
/// <returns>Object representation of the JSON string.</returns>
public object Deserialize(string content, Type type, IList<Parameter> headers=null)
{
@ -330,6 +331,21 @@ namespace IO.Swagger.Client
}
}
}
/// <summary>
/// Select the Accept header's value from the given accepts array:
/// if JSON exists in the given array, use it;
/// otherwise use all of them (joining into a string)
/// </summary>
/// <param name="accepts">The accepts array to select from.</param>
/// <returns>The Accept header to use.</returns>
public String SelectHeaderAccept(String[] accepts) {
if (accepts.Length == 0)
return null;
if (accepts.Contains("application/json", StringComparer.OrdinalIgnoreCase))
return "application/json";
return String.Join(",", accepts);
}
/// <summary>
/// Encode string in base64 format.

View File

@ -20,7 +20,6 @@ namespace IO.Swagger.Client {
/// <summary>
/// Initializes a new instance of the <see cref="ApiException"/> class.
/// </summary>
/// <param name="basePath">The base path.</param>
public ApiException() {}
/// <summary>

View File

@ -120,7 +120,12 @@ namespace SwaggerClient.TestPet
PetApi petApi = new PetApi ();
//NOTE: please provide a valid file (full path)
FileStream fileStream = new FileStream("/var/tmp/small.gif", FileMode.Open);
// test file upload with form parameters
petApi.UploadFile(petId, "new form name", fileStream);
// test file upload without any form parameters
petApi.UploadFile(petId, null, fileStream);
}