add optional parameter to c# api client (enabled by default)

This commit is contained in:
wing328 2015-11-28 15:40:44 +08:00
parent 1fbdb92625
commit dfc0813a18
14 changed files with 86 additions and 63 deletions

View File

@ -46,4 +46,6 @@ public class CodegenConstants {
public static final String PACKAGE_NAME = "packageName";
public static final String PACKAGE_VERSION = "packageVersion";
public static final String POD_VERSION = "podVersion";
public static final String OPTIONAL_METHOD_ARGUMENT = "optionalMethodArgument";
}

View File

@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory;
public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig {
private static final Logger LOGGER = LoggerFactory.getLogger(CSharpClientCodegen.class);
protected boolean optionalMethodArgumentFlag = true;
protected String packageName = "IO.Swagger";
protected String packageVersion = "1.0.0";
protected String clientPackage = "IO.Swagger.Client";
@ -91,6 +92,7 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
.defaultValue("IO.Swagger"));
cliOptions.add(new CliOption(CodegenConstants.PACKAGE_VERSION, "C# package version.").defaultValue("1.0.0"));
cliOptions.add(new CliOption(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG_DESC));
cliOptions.add(new CliOption(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only). Default: false").defaultValue("false"));
}
@Override
@ -113,6 +115,12 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
}
additionalProperties.put("clientPackage", clientPackage);
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_METHOD_ARGUMENT)) {
setOptionalMethodArgumentFlag(Boolean.valueOf(additionalProperties
.get(CodegenConstants.OPTIONAL_METHOD_ARGUMENT).toString()));
}
additionalProperties.put("optionalMethodArgument", optionalMethodArgumentFlag);
supportingFiles.add(new SupportingFile("Configuration.mustache",
sourceFolder + File.separator + clientPackage.replace(".", java.io.File.separator), "Configuration.cs"));
@ -261,6 +269,10 @@ public class CSharpClientCodegen extends DefaultCodegen implements CodegenConfig
return camelize(sanitizeName(operationId));
}
public void setOptionalMethodArgumentFlag(boolean flag) {
this.optionalMethodArgumentFlag = flag;
}
public void setPackageName(String packageName) {
this.packageName = packageName;
}

View File

@ -23,7 +23,7 @@ namespace {{packageName}}.Api
/// </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}});
{{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#allParams}}{{{dataType}}} {{paramName}}{{^required}}{{#optionalMethodArgument}} = null{{/optionalMethodArgument}}{{/required}}{{#hasMore}}, {{/hasMore}}{{/allParams}});
/// <summary>
/// {{summary}}
@ -33,7 +33,7 @@ namespace {{packageName}}.Api
/// </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}});
{{#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}});
{{/operation}}
}
@ -95,11 +95,11 @@ namespace {{packageName}}.Api
/// </summary>
{{#allParams}}/// <param name="{{paramName}}">{{description}}</param>
{{/allParams}}/// <returns>{{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}}</returns>
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{nickname}} ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
public {{#returnType}}{{{returnType}}}{{/returnType}}{{^returnType}}void{{/returnType}} {{operationId}} ({{#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 {{nickname}}");
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}");
{{/required}}{{/allParams}}
var path_ = "{{path}}";
@ -140,9 +140,9 @@ namespace {{packageName}}.Api
IRestResponse response = (IRestResponse) ApiClient.CallApi(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
else if (((int)response.StatusCode) == 0)
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.ErrorMessage, response.ErrorMessage);
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.ErrorMessage, response.ErrorMessage);
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}return;{{/returnType}}
}
@ -152,10 +152,10 @@ namespace {{packageName}}.Api
/// </summary>
{{#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}} {{nickname}}Async ({{#allParams}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
{{#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}})
{
{{#allParams}}{{#required}}// verify the required parameter '{{paramName}}' is set
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{nickname}}");
if ({{paramName}} == null) throw new ApiException(400, "Missing required parameter '{{paramName}}' when calling {{operationId}}");
{{/required}}{{/allParams}}
var path_ = "{{path}}";
@ -195,7 +195,7 @@ namespace {{packageName}}.Api
// make the HTTP request
IRestResponse response = (IRestResponse) await ApiClient.CallApiAsync(path_, Method.{{httpMethod}}, queryParams, postBody, headerParams, formParams, fileParams, pathParams, authSettings);
if (((int)response.StatusCode) >= 400)
throw new ApiException ((int)response.StatusCode, "Error calling {{nickname}}: " + response.Content, response.Content);
throw new ApiException ((int)response.StatusCode, "Error calling {{operationId}}: " + response.Content, response.Content);
{{#returnType}}return ({{{returnType}}}) ApiClient.Deserialize(response, typeof({{{returnType}}}));{{/returnType}}{{^returnType}}
return;{{/returnType}}

View File

@ -27,6 +27,8 @@ public class CSharpClientOptionsTest extends AbstractOptionsTest {
new Expectations(clientCodegen) {{
clientCodegen.setPackageName(CSharpClientOptionsProvider.PACKAGE_NAME_VALUE);
times = 1;
clientCodegen.setOptionalMethodArgumentFlag(true);
times = 1;
clientCodegen.setPackageVersion(CSharpClientOptionsProvider.PACKAGE_VERSION_VALUE);
times = 1;
}};

View File

@ -21,6 +21,7 @@ public class CSharpClientOptionsProvider implements OptionsProvider {
return builder.put(CodegenConstants.PACKAGE_NAME, PACKAGE_NAME_VALUE)
.put(CodegenConstants.PACKAGE_VERSION, PACKAGE_VERSION_VALUE)
.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, "true")
.put(CodegenConstants.OPTIONAL_METHOD_ARGUMENT, "true")
.build();
}

View File

@ -22,7 +22,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
void UpdatePet (Pet body);
void UpdatePet (Pet body = null);
/// <summary>
/// Update an existing pet
@ -32,7 +32,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task UpdatePetAsync (Pet body);
System.Threading.Tasks.Task UpdatePetAsync (Pet body = null);
/// <summary>
/// Add a new pet to the store
@ -42,7 +42,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
void AddPet (Pet body);
void AddPet (Pet body = null);
/// <summary>
/// Add a new pet to the store
@ -52,7 +52,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
System.Threading.Tasks.Task AddPetAsync (Pet body);
System.Threading.Tasks.Task AddPetAsync (Pet body = null);
/// <summary>
/// Finds Pets by status
@ -62,7 +62,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="status">Status values that need to be considered for filter</param>
/// <returns></returns>
List<Pet> FindPetsByStatus (List<string> status);
List<Pet> FindPetsByStatus (List<string> status = null);
/// <summary>
/// Finds Pets by status
@ -72,7 +72,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <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);
System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null);
/// <summary>
/// Finds Pets by tags
@ -82,7 +82,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
List<Pet> FindPetsByTags (List<string> tags);
List<Pet> FindPetsByTags (List<string> tags = null);
/// <summary>
/// Finds Pets by tags
@ -92,7 +92,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags);
System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null);
/// <summary>
/// Find pet by ID
@ -124,7 +124,7 @@ namespace IO.Swagger.Api
/// <param name="name">Updated name of the pet</param>
/// <param name="status">Updated status of the pet</param>
/// <returns></returns>
void UpdatePetWithForm (string petId, string name, string status);
void UpdatePetWithForm (string petId, string name = null, string status = null);
/// <summary>
/// Updates a pet in the store with form data
@ -136,7 +136,7 @@ namespace IO.Swagger.Api
/// <param name="name">Updated name of the pet</param>
/// <param name="status">Updated status of the pet</param>
/// <returns></returns>
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name, string status);
System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null);
/// <summary>
/// Deletes a pet
@ -147,7 +147,7 @@ namespace IO.Swagger.Api
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
void DeletePet (long? petId, string apiKey);
void DeletePet (long? petId, string apiKey = null);
/// <summary>
/// Deletes a pet
@ -158,7 +158,7 @@ namespace IO.Swagger.Api
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey);
System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null);
/// <summary>
/// uploads an image
@ -170,7 +170,7 @@ namespace IO.Swagger.Api
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="file">file to upload</param>
/// <returns></returns>
void UploadFile (long? petId, string additionalMetadata, Stream file);
void UploadFile (long? petId, string additionalMetadata = null, Stream file = null);
/// <summary>
/// uploads an image
@ -182,7 +182,7 @@ namespace IO.Swagger.Api
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="file">file to upload</param>
/// <returns></returns>
System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata, Stream file);
System.Threading.Tasks.Task UploadFileAsync (long? petId, string additionalMetadata = null, Stream file = null);
}
@ -244,7 +244,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public void UpdatePet (Pet body)
public void UpdatePet (Pet body = null)
{
@ -294,7 +294,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <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)
public async System.Threading.Tasks.Task UpdatePetAsync (Pet body = null)
{
@ -342,7 +342,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">Pet object that needs to be added to the store</param>
/// <returns></returns>
public void AddPet (Pet body)
public void AddPet (Pet body = null)
{
@ -392,7 +392,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <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)
public async System.Threading.Tasks.Task AddPetAsync (Pet body = null)
{
@ -440,7 +440,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="status">Status values that need to be considered for filter</param>
/// <returns></returns>
public List<Pet> FindPetsByStatus (List<string> status)
public List<Pet> FindPetsByStatus (List<string> status = null)
{
@ -490,7 +490,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <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)
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByStatusAsync (List<string> status = null)
{
@ -537,7 +537,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
public List<Pet> FindPetsByTags (List<string> tags)
public List<Pet> FindPetsByTags (List<string> tags = null)
{
@ -587,7 +587,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="tags">Tags to filter by</param>
/// <returns></returns>
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags)
public async System.Threading.Tasks.Task<List<Pet>> FindPetsByTagsAsync (List<string> tags = null)
{
@ -738,7 +738,7 @@ namespace IO.Swagger.Api
/// <param name="name">Updated name of the pet</param>
/// <param name="status">Updated status of the pet</param>
/// <returns></returns>
public void UpdatePetWithForm (string petId, string name, string status)
public void UpdatePetWithForm (string petId, string name = null, string status = null)
{
// verify the required parameter 'petId' is set
@ -795,7 +795,7 @@ namespace IO.Swagger.Api
/// <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 UpdatePetWithFormAsync (string petId, string name, string status)
public async System.Threading.Tasks.Task UpdatePetWithFormAsync (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");
@ -848,7 +848,7 @@ namespace IO.Swagger.Api
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
public void DeletePet (long? petId, string apiKey)
public void DeletePet (long? petId, string apiKey = null)
{
// verify the required parameter 'petId' is set
@ -903,7 +903,7 @@ namespace IO.Swagger.Api
/// <param name="petId">Pet id to delete</param>
/// <param name="apiKey"></param>
/// <returns></returns>
public async System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey)
public async System.Threading.Tasks.Task DeletePetAsync (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");
@ -956,7 +956,7 @@ namespace IO.Swagger.Api
/// <param name="additionalMetadata">Additional data to pass to server</param>
/// <param name="file">file to upload</param>
/// <returns></returns>
public void UploadFile (long? petId, string additionalMetadata, Stream file)
public void UploadFile (long? petId, string additionalMetadata = null, Stream file = null)
{
// verify the required parameter 'petId' is set
@ -1013,7 +1013,7 @@ namespace IO.Swagger.Api
/// <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 UploadFileAsync (long? petId, string additionalMetadata, Stream file)
public async System.Threading.Tasks.Task UploadFileAsync (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");

View File

@ -40,7 +40,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
Order PlaceOrder (Order body);
Order PlaceOrder (Order body = null);
/// <summary>
/// Place an order for a pet
@ -50,7 +50,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body);
System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null);
/// <summary>
/// Find purchase order by ID
@ -245,7 +245,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
public Order PlaceOrder (Order body)
public Order PlaceOrder (Order body = null)
{
@ -295,7 +295,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">order placed for purchasing the pet</param>
/// <returns>Order</returns>
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body)
public async System.Threading.Tasks.Task<Order> PlaceOrderAsync (Order body = null)
{

View File

@ -22,7 +22,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Created user object</param>
/// <returns></returns>
void CreateUser (User body);
void CreateUser (User body = null);
/// <summary>
/// Create user
@ -32,7 +32,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">Created user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUserAsync (User body);
System.Threading.Tasks.Task CreateUserAsync (User body = null);
/// <summary>
/// Creates list of users with given input array
@ -42,7 +42,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
void CreateUsersWithArrayInput (List<User> body);
void CreateUsersWithArrayInput (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
@ -52,7 +52,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body);
System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
@ -62,7 +62,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
void CreateUsersWithListInput (List<User> body);
void CreateUsersWithListInput (List<User> body = null);
/// <summary>
/// Creates list of users with given input array
@ -72,7 +72,7 @@ namespace IO.Swagger.Api
/// </remarks>
/// <param name="body">List of user object</param>
/// <returns></returns>
System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body);
System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null);
/// <summary>
/// Logs user into the system
@ -83,7 +83,7 @@ namespace IO.Swagger.Api
/// <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);
string LoginUser (string username = null, string password = null);
/// <summary>
/// Logs user into the system
@ -94,7 +94,7 @@ namespace IO.Swagger.Api
/// <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);
System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null);
/// <summary>
/// Logs out current logged in user session
@ -143,7 +143,7 @@ namespace IO.Swagger.Api
/// <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);
void UpdateUser (string username, User body = null);
/// <summary>
/// Updated user
@ -154,7 +154,7 @@ namespace IO.Swagger.Api
/// <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);
System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null);
/// <summary>
/// Delete user
@ -236,7 +236,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">Created user object</param>
/// <returns></returns>
public void CreateUser (User body)
public void CreateUser (User body = null)
{
@ -286,7 +286,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">Created user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUserAsync (User body)
public async System.Threading.Tasks.Task CreateUserAsync (User body = null)
{
@ -334,7 +334,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public void CreateUsersWithArrayInput (List<User> body)
public void CreateUsersWithArrayInput (List<User> body = null)
{
@ -384,7 +384,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body)
public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List<User> body = null)
{
@ -432,7 +432,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public void CreateUsersWithListInput (List<User> body)
public void CreateUsersWithListInput (List<User> body = null)
{
@ -482,7 +482,7 @@ namespace IO.Swagger.Api
/// </summary>
/// <param name="body">List of user object</param>
/// <returns></returns>
public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body)
public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List<User> body = null)
{
@ -531,7 +531,7 @@ namespace IO.Swagger.Api
/// <param name="username">The user name for login</param>
/// <param name="password">The password for login in clear text</param>
/// <returns>string</returns>
public string LoginUser (string username, string password)
public string LoginUser (string username = null, string password = null)
{
@ -583,7 +583,7 @@ namespace IO.Swagger.Api
/// <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<string> LoginUserAsync (string username, string password)
public async System.Threading.Tasks.Task<string> LoginUserAsync (string username = null, string password = null)
{
@ -828,7 +828,7 @@ namespace IO.Swagger.Api
/// <param name="username">name that need to be deleted</param>
/// <param name="body">Updated user object</param>
/// <returns></returns>
public void UpdateUser (string username, User body)
public void UpdateUser (string username, User body = null)
{
// verify the required parameter 'username' is set
@ -883,7 +883,7 @@ namespace IO.Swagger.Api
/// <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 UpdateUserAsync (string username, User body)
public async System.Threading.Tasks.Task UpdateUserAsync (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");

View File

@ -2,7 +2,7 @@
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
<MonoDevelop.Ide.Workbench ActiveDocument="TestPet.cs">
<Files>
<File FileName="TestPet.cs" Line="8" Column="25" />
<File FileName="TestPet.cs" Line="15" Column="3" />
</Files>
</MonoDevelop.Ide.Workbench>
<MonoDevelop.Ide.DebuggingService.Breakpoints>

View File

@ -121,6 +121,11 @@ namespace SwaggerClient.TestPet
Assert.AreEqual (petId, response.Tags [0].Id);
Assert.AreEqual (56, response.Category.Id);
// test optional parameter
petApi.UpdatePetWithForm (petId.ToString(), "new form name2");
Pet response2 = petApi.GetPetById (petId);
Assert.AreEqual ("new form name2", response2.Name);
}
/// <summary>
@ -136,7 +141,8 @@ namespace SwaggerClient.TestPet
petApi.UploadFile(petId, "new form name", fileStream);
// test file upload without any form parameters
petApi.UploadFile(petId, null, fileStream);
// using optional parameter syntax introduced at .net 4.0
petApi.UploadFile(petId: petId, file: fileStream);
}