diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java index a5bb97e5a93..74464397120 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/CodegenConstants.java @@ -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"; } diff --git a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java index 3ab152cf66d..e95f9c71c4c 100644 --- a/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java +++ b/modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/CSharpClientCodegen.java @@ -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; } diff --git a/modules/swagger-codegen/src/main/resources/csharp/api.mustache b/modules/swagger-codegen/src/main/resources/csharp/api.mustache index 6708fa1e16d..11d2ffe81bb 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/api.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/api.mustache @@ -23,7 +23,7 @@ namespace {{packageName}}.Api /// {{#allParams}}/// {{description}} {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} - {{#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}} @@ -33,7 +33,7 @@ namespace {{packageName}}.Api /// {{#allParams}}/// {{description}} {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} - {{#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 /// {{#allParams}}/// {{description}} {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} - 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 /// {{#allParams}}/// {{description}} {{/allParams}}/// {{#returnType}}{{^returnContainer}}{{{returnType}}}{{/returnContainer}}{{/returnType}} - {{#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}} diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java index 4c0d5f366a1..ec5246f7723 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/csharp/CSharpClientOptionsTest.java @@ -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; }}; diff --git a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java index 442465dfcf9..94440db97c0 100644 --- a/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java +++ b/modules/swagger-codegen/src/test/java/io/swagger/codegen/options/CSharpClientOptionsProvider.java @@ -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(); } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs index 00bd7a5e9f2..8344304ee79 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/PetApi.cs @@ -22,7 +22,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - void UpdatePet (Pet body); + void UpdatePet (Pet body = null); /// /// Update an existing pet @@ -32,7 +32,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - System.Threading.Tasks.Task UpdatePetAsync (Pet body); + System.Threading.Tasks.Task UpdatePetAsync (Pet body = null); /// /// Add a new pet to the store @@ -42,7 +42,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - void AddPet (Pet body); + void AddPet (Pet body = null); /// /// Add a new pet to the store @@ -52,7 +52,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - System.Threading.Tasks.Task AddPetAsync (Pet body); + System.Threading.Tasks.Task AddPetAsync (Pet body = null); /// /// Finds Pets by status @@ -62,7 +62,7 @@ namespace IO.Swagger.Api /// /// Status values that need to be considered for filter /// - List FindPetsByStatus (List status); + List FindPetsByStatus (List status = null); /// /// Finds Pets by status @@ -72,7 +72,7 @@ namespace IO.Swagger.Api /// /// Status values that need to be considered for filter /// - System.Threading.Tasks.Task> FindPetsByStatusAsync (List status); + System.Threading.Tasks.Task> FindPetsByStatusAsync (List status = null); /// /// Finds Pets by tags @@ -82,7 +82,7 @@ namespace IO.Swagger.Api /// /// Tags to filter by /// - List FindPetsByTags (List tags); + List FindPetsByTags (List tags = null); /// /// Finds Pets by tags @@ -92,7 +92,7 @@ namespace IO.Swagger.Api /// /// Tags to filter by /// - System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags); + System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags = null); /// /// Find pet by ID @@ -124,7 +124,7 @@ namespace IO.Swagger.Api /// Updated name of the pet /// Updated status of the pet /// - void UpdatePetWithForm (string petId, string name, string status); + void UpdatePetWithForm (string petId, string name = null, string status = null); /// /// Updates a pet in the store with form data @@ -136,7 +136,7 @@ namespace IO.Swagger.Api /// Updated name of the pet /// Updated status of the pet /// - System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name, string status); + System.Threading.Tasks.Task UpdatePetWithFormAsync (string petId, string name = null, string status = null); /// /// Deletes a pet @@ -147,7 +147,7 @@ namespace IO.Swagger.Api /// Pet id to delete /// /// - void DeletePet (long? petId, string apiKey); + void DeletePet (long? petId, string apiKey = null); /// /// Deletes a pet @@ -158,7 +158,7 @@ namespace IO.Swagger.Api /// Pet id to delete /// /// - System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey); + System.Threading.Tasks.Task DeletePetAsync (long? petId, string apiKey = null); /// /// uploads an image @@ -170,7 +170,7 @@ namespace IO.Swagger.Api /// Additional data to pass to server /// file to upload /// - void UploadFile (long? petId, string additionalMetadata, Stream file); + void UploadFile (long? petId, string additionalMetadata = null, Stream file = null); /// /// uploads an image @@ -182,7 +182,7 @@ namespace IO.Swagger.Api /// Additional data to pass to server /// file to upload /// - 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 /// /// Pet object that needs to be added to the store /// - public void UpdatePet (Pet body) + public void UpdatePet (Pet body = null) { @@ -294,7 +294,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - 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 /// /// Pet object that needs to be added to the store /// - public void AddPet (Pet body) + public void AddPet (Pet body = null) { @@ -392,7 +392,7 @@ namespace IO.Swagger.Api /// /// Pet object that needs to be added to the store /// - 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 /// /// Status values that need to be considered for filter /// - public List FindPetsByStatus (List status) + public List FindPetsByStatus (List status = null) { @@ -490,7 +490,7 @@ namespace IO.Swagger.Api /// /// Status values that need to be considered for filter /// - public async System.Threading.Tasks.Task> FindPetsByStatusAsync (List status) + public async System.Threading.Tasks.Task> FindPetsByStatusAsync (List status = null) { @@ -537,7 +537,7 @@ namespace IO.Swagger.Api /// /// Tags to filter by /// - public List FindPetsByTags (List tags) + public List FindPetsByTags (List tags = null) { @@ -587,7 +587,7 @@ namespace IO.Swagger.Api /// /// Tags to filter by /// - public async System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags) + public async System.Threading.Tasks.Task> FindPetsByTagsAsync (List tags = null) { @@ -738,7 +738,7 @@ namespace IO.Swagger.Api /// Updated name of the pet /// Updated status of the pet /// - 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 /// Updated name of the pet /// Updated status of the pet /// - 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 /// Pet id to delete /// /// - 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 /// Pet id to delete /// /// - 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 /// Additional data to pass to server /// file to upload /// - 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 /// Additional data to pass to server /// file to upload /// - 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"); diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs index b0a439ddf1a..952987dfad4 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/StoreApi.cs @@ -40,7 +40,7 @@ namespace IO.Swagger.Api /// /// order placed for purchasing the pet /// Order - Order PlaceOrder (Order body); + Order PlaceOrder (Order body = null); /// /// Place an order for a pet @@ -50,7 +50,7 @@ namespace IO.Swagger.Api /// /// order placed for purchasing the pet /// Order - System.Threading.Tasks.Task PlaceOrderAsync (Order body); + System.Threading.Tasks.Task PlaceOrderAsync (Order body = null); /// /// Find purchase order by ID @@ -245,7 +245,7 @@ namespace IO.Swagger.Api /// /// order placed for purchasing the pet /// Order - public Order PlaceOrder (Order body) + public Order PlaceOrder (Order body = null) { @@ -295,7 +295,7 @@ namespace IO.Swagger.Api /// /// order placed for purchasing the pet /// Order - public async System.Threading.Tasks.Task PlaceOrderAsync (Order body) + public async System.Threading.Tasks.Task PlaceOrderAsync (Order body = null) { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs index b4c8d93c28c..3890e98b17f 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Api/UserApi.cs @@ -22,7 +22,7 @@ namespace IO.Swagger.Api /// /// Created user object /// - void CreateUser (User body); + void CreateUser (User body = null); /// /// Create user @@ -32,7 +32,7 @@ namespace IO.Swagger.Api /// /// Created user object /// - System.Threading.Tasks.Task CreateUserAsync (User body); + System.Threading.Tasks.Task CreateUserAsync (User body = null); /// /// Creates list of users with given input array @@ -42,7 +42,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - void CreateUsersWithArrayInput (List body); + void CreateUsersWithArrayInput (List body = null); /// /// Creates list of users with given input array @@ -52,7 +52,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body); + System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body = null); /// /// Creates list of users with given input array @@ -62,7 +62,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - void CreateUsersWithListInput (List body); + void CreateUsersWithListInput (List body = null); /// /// Creates list of users with given input array @@ -72,7 +72,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body); + System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body = null); /// /// Logs user into the system @@ -83,7 +83,7 @@ namespace IO.Swagger.Api /// The user name for login /// The password for login in clear text /// string - string LoginUser (string username, string password); + string LoginUser (string username = null, string password = null); /// /// Logs user into the system @@ -94,7 +94,7 @@ namespace IO.Swagger.Api /// The user name for login /// The password for login in clear text /// string - System.Threading.Tasks.Task LoginUserAsync (string username, string password); + System.Threading.Tasks.Task LoginUserAsync (string username = null, string password = null); /// /// Logs out current logged in user session @@ -143,7 +143,7 @@ namespace IO.Swagger.Api /// name that need to be deleted /// Updated user object /// - void UpdateUser (string username, User body); + void UpdateUser (string username, User body = null); /// /// Updated user @@ -154,7 +154,7 @@ namespace IO.Swagger.Api /// name that need to be deleted /// Updated user object /// - System.Threading.Tasks.Task UpdateUserAsync (string username, User body); + System.Threading.Tasks.Task UpdateUserAsync (string username, User body = null); /// /// Delete user @@ -236,7 +236,7 @@ namespace IO.Swagger.Api /// /// Created user object /// - public void CreateUser (User body) + public void CreateUser (User body = null) { @@ -286,7 +286,7 @@ namespace IO.Swagger.Api /// /// Created user object /// - 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 /// /// List of user object /// - public void CreateUsersWithArrayInput (List body) + public void CreateUsersWithArrayInput (List body = null) { @@ -384,7 +384,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body) + public async System.Threading.Tasks.Task CreateUsersWithArrayInputAsync (List body = null) { @@ -432,7 +432,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - public void CreateUsersWithListInput (List body) + public void CreateUsersWithListInput (List body = null) { @@ -482,7 +482,7 @@ namespace IO.Swagger.Api /// /// List of user object /// - public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body) + public async System.Threading.Tasks.Task CreateUsersWithListInputAsync (List body = null) { @@ -531,7 +531,7 @@ namespace IO.Swagger.Api /// The user name for login /// The password for login in clear text /// string - public string LoginUser (string username, string password) + public string LoginUser (string username = null, string password = null) { @@ -583,7 +583,7 @@ namespace IO.Swagger.Api /// The user name for login /// The password for login in clear text /// string - public async System.Threading.Tasks.Task LoginUserAsync (string username, string password) + public async System.Threading.Tasks.Task LoginUserAsync (string username = null, string password = null) { @@ -828,7 +828,7 @@ namespace IO.Swagger.Api /// name that need to be deleted /// Updated user object /// - 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 /// name that need to be deleted /// Updated user object /// - 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"); diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs index 0a2248522b9..cd6170dd2e8 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.userprefs @@ -2,7 +2,7 @@ - + diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index 19a14c592f4..e9169da9832 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -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); } /// @@ -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); } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll index cb328f9bb07..3e3230fe96b 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb index 638f1d93d46..fba3366dbbd 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/bin/Debug/SwaggerClientTest.dll.mdb differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll index cb328f9bb07..3e3230fe96b 100755 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll differ diff --git a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb index 638f1d93d46..fba3366dbbd 100644 Binary files a/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb and b/samples/client/petstore/csharp/SwaggerClientTest/obj/Debug/SwaggerClientTest.dll.mdb differ