diff --git a/.gitignore b/.gitignore index d55a8014a34..db34c76636c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ generated-sources/* generated-code/* *.swp *.swo +*.csproj.user /target /generated-files @@ -36,6 +37,9 @@ samples/client/petstore/objc/SwaggerClientTests/Pods samples/client/petstore/objc/SwaggerClientTests/SwaggerClient.xcworkspace samples/client/petstore/objc/SwaggerClientTests/Podfile.lock samples/server/petstore/nodejs/node_modules +samples/client/petstore/csharp/SwaggerClientTest/.vs +samples/client/petstore/csharp/SwaggerClientTest/obj +samples/client/petstore/csharp/SwaggerClientTest/bin target .idea .lib @@ -60,4 +64,4 @@ samples/client/petstore/python/.venv/ *.java~ *.pm~ *.xml~ -*.t~ \ No newline at end of file +*.t~ diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/ApiClient.mustache index 6d5e45c186e..a428cdc3630 100644 --- a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/ApiClient.mustache @@ -134,7 +134,7 @@ namespace {{packageName}}.Client } /// - /// If parameter is DateTime, output in ISO8601 format. + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. /// If parameter is a list of string, join the list with ",". /// Otherwise just return the string. /// @@ -143,10 +143,11 @@ namespace {{packageName}}.Client public string ParameterToString(object obj) { if (obj is DateTime) - // Return an ISO 8601 formatted string, also known as a Round-trip date/time pattern + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 // For example: 2009-06-15T13:45:30.0000000 - return ((DateTime)obj).ToString ("o"); + return ((DateTime)obj).ToString (Configuration.DateTimeFormat); else if (obj is List) return String.Join(",", (obj as List).ToArray()); else diff --git a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/Configuration.mustache b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/Configuration.mustache index 67b07069e2f..56f4e617556 100644 --- a/modules/swagger-codegen/src/main/resources/CsharpDotNet2/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/CsharpDotNet2/Configuration.mustache @@ -78,7 +78,40 @@ namespace {{packageName}}.Client _tempFolderPath = value + Path.DirectorySeparatorChar; } } - + + private const string ISO8601_DATETIME_FORMAT = "o"; + + private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT; + + /// + /// Gets or sets the the date time format used when serializing in the ApiClient + /// By default, it's set to ISO 8601 - "o", for others see: + /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx + /// No validation is done to ensure that the string you're providing is valid + /// + /// The DateTimeFormat string + public static String DateTimeFormat + { + get + { + return _dateTimeFormat; + } + set + { + if (string.IsNullOrEmpty(value)) + { + // Never allow a blank or null string, go back to the default + _dateTimeFormat = ISO8601_DATETIME_FORMAT; + return; + } + + // Caution, no validation when you choose date time format other than ISO 8601 + // Take a look at the above links + _dateTimeFormat = value; + } + } + /// /// Returns a string with essential information for debugging. /// diff --git a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache index 172e6bc627a..707ce9eb560 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/ApiClient.mustache @@ -147,7 +147,7 @@ namespace {{packageName}}.Client } /// - /// If parameter is DateTime, output in ISO8601 format. + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. /// If parameter is a list, join the list with ",". /// Otherwise just return the string. /// @@ -156,10 +156,11 @@ namespace {{packageName}}.Client public string ParameterToString(object obj) { if (obj is DateTime) - // Return an ISO 8601 formatted string, also known as a Round-trip date/time pattern + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 // For example: 2009-06-15T13:45:30.0000000 - return ((DateTime)obj).ToString ("o"); + return ((DateTime)obj).ToString (Configuration.DateTimeFormat); else if (obj is IList) { string flattenString = ""; diff --git a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache index 46dde35d8d3..44459e54440 100644 --- a/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache +++ b/modules/swagger-codegen/src/main/resources/csharp/Configuration.mustache @@ -138,7 +138,40 @@ namespace {{packageName}}.Client _tempFolderPath = value + Path.DirectorySeparatorChar; } } - + + private const string ISO8601_DATETIME_FORMAT = "o"; + + private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT; + + /// + /// Gets or sets the the date time format used when serializing in the ApiClient + /// By default, it's set to ISO 8601 - "o", for others see: + /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx + /// No validation is done to ensure that the string you're providing is valid + /// + /// The DateTimeFormat string + public static String DateTimeFormat + { + get + { + return _dateTimeFormat; + } + set + { + if (string.IsNullOrEmpty(value)) + { + // Never allow a blank or null string, go back to the default + _dateTimeFormat = ISO8601_DATETIME_FORMAT; + return; + } + + // Caution, no validation when you choose date time format other than ISO 8601 + // Take a look at the above links + _dateTimeFormat = value; + } + } + /// /// Returns a string with essential information for debugging. /// 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 ba58eeac9e0..9ab779c9f4b 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 @@ -6,6 +6,7 @@ using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; + namespace IO.Swagger.Api { 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 a9e9d6e9b74..db82bf8e644 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 @@ -6,6 +6,7 @@ using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; + namespace IO.Swagger.Api { 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 5502fe15da1..ac4f138c568 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 @@ -6,6 +6,7 @@ using RestSharp; using IO.Swagger.Client; using IO.Swagger.Model; + namespace IO.Swagger.Api { diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs index 1dc978443a3..faf688b5585 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/ApiClient.cs @@ -147,7 +147,7 @@ namespace IO.Swagger.Client } /// - /// If parameter is DateTime, output in ISO8601 format. + /// If parameter is DateTime, output in a formatted string (default ISO 8601), customizable with Configuration.DateTime. /// If parameter is a list, join the list with ",". /// Otherwise just return the string. /// @@ -156,10 +156,11 @@ namespace IO.Swagger.Client public string ParameterToString(object obj) { if (obj is DateTime) - // Return an ISO 8601 formatted string, also known as a Round-trip date/time pattern + // Return a formatted date string - Can be customized with Configuration.DateTimeFormat + // Defaults to an ISO 8601, using the known as a Round-trip date/time pattern ("o") // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 // For example: 2009-06-15T13:45:30.0000000 - return ((DateTime)obj).ToString ("o"); + return ((DateTime)obj).ToString (Configuration.DateTimeFormat); else if (obj is IList) { string flattenString = ""; diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs index 151e4e42248..fcdc16f44db 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Client/Configuration.cs @@ -138,7 +138,40 @@ namespace IO.Swagger.Client _tempFolderPath = value + Path.DirectorySeparatorChar; } } - + + private const string ISO8601_DATETIME_FORMAT = "o"; + + private static string _dateTimeFormat = ISO8601_DATETIME_FORMAT; + + /// + /// Gets or sets the the date time format used when serializing in the ApiClient + /// By default, it's set to ISO 8601 - "o", for others see: + /// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx + /// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx + /// No validation is done to ensure that the string you're providing is valid + /// + /// The DateTimeFormat string + public static String DateTimeFormat + { + get + { + return _dateTimeFormat; + } + set + { + if (string.IsNullOrEmpty(value)) + { + // Never allow a blank or null string, go back to the default + _dateTimeFormat = ISO8601_DATETIME_FORMAT; + return; + } + + // Caution, no validation when you choose date time format other than ISO 8601 + // Take a look at the above links + _dateTimeFormat = value; + } + } + /// /// Returns a string with essential information for debugging. /// diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs index d9cb6b21005..03551f9492b 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Category.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; + + namespace IO.Swagger.Model { @@ -122,4 +124,6 @@ namespace IO.Swagger.Model } } + + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs index 2191707bd09..1d214430ec8 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Order.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; + + namespace IO.Swagger.Model { @@ -187,4 +189,6 @@ namespace IO.Swagger.Model } } + + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs index 10c44fb46a7..ab60577e85a 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Pet.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; + + namespace IO.Swagger.Model { @@ -187,4 +189,6 @@ namespace IO.Swagger.Model } } + + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs index 93210505bf0..cf77c2470b2 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/Tag.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; + + namespace IO.Swagger.Model { @@ -122,4 +124,6 @@ namespace IO.Swagger.Model } } + + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs index 1fbd17da993..eca977c3b18 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/Lib/SwaggerClient/src/main/csharp/IO/Swagger/Model/User.cs @@ -7,6 +7,8 @@ using System.Collections.Generic; using System.Runtime.Serialization; using Newtonsoft.Json; + + namespace IO.Swagger.Model { @@ -219,4 +221,6 @@ namespace IO.Swagger.Model } } + + } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj index c1dc6a31e19..5556641ea1f 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj +++ b/samples/client/petstore/csharp/SwaggerClientTest/SwaggerClientTest.csproj @@ -1,4 +1,4 @@ - + Debug @@ -69,5 +69,9 @@ + + + + \ No newline at end of file diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs index 5b9b27ce656..adf59e0ae0c 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestApiClient.cs @@ -3,11 +3,18 @@ using System; using System.Collections.Generic; using IO.Swagger.Client; -namespace SwaggerClient.TestApiClient +namespace SwaggerClientTest.TestApiClient { public class TestApiClient { - [Test ()] + [TearDown()] + public void TearDown() + { + // Reset to default, just in case + Configuration.DateTimeFormat = "o"; + } + + [Test ()] public void TestParameterToString () { ApiClient api = new ApiClient (); @@ -19,20 +26,49 @@ namespace SwaggerClient.TestApiClient // test array of int List numList = new List(new int[] {1, 37}); Assert.AreEqual("1,37", api.ParameterToString (numList)); - - // test datetime - DateTime dateUtc = DateTime.Parse("2008-04-10T13:30:00.0000000z", null, System.Globalization.DateTimeStyles.RoundtripKind); - Assert.AreEqual("2008-04-10T13:30:00.0000000Z", api.ParameterToString (dateUtc)); - - // test datetime with no timezone - DateTime dateWithNoTz = DateTime.Parse("2008-04-10T13:30:00.000", null, System.Globalization.DateTimeStyles.RoundtripKind); - Assert.AreEqual("2008-04-10T13:30:00.0000000", api.ParameterToString (dateWithNoTz)); - - // test datetime with a time zone - DateTime dateWithTz = DateTime.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind); - Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString (dateWithTz)); - } - } + + [Test ()] + public void TestParameterToString_DateTime () + { + ApiClient api = new ApiClient(); + + // test datetime + DateTime dateUtc = DateTime.Parse("2008-04-10T13:30:00.0000000z", null, System.Globalization.DateTimeStyles.RoundtripKind); + Assert.AreEqual("2008-04-10T13:30:00.0000000Z", api.ParameterToString(dateUtc)); + + // test datetime with no timezone + DateTime dateWithNoTz = DateTime.Parse("2008-04-10T13:30:00.000", null, System.Globalization.DateTimeStyles.RoundtripKind); + Assert.AreEqual("2008-04-10T13:30:00.0000000", api.ParameterToString(dateWithNoTz)); + + // test datetime with a time zone + DateTime dateWithTz = DateTime.Parse("2008-04-10T13:30:00.0000000-04:00", null, System.Globalization.DateTimeStyles.RoundtripKind); + Assert.AreEqual("2008-04-10T13:30:00.0000000-04:00", api.ParameterToString(dateWithTz)); + } + + [Test ()] + public void TestParameterToString_DateTime_WithUFormat () + { + // Setup the DateTimeFormat across all of the calls + Configuration.DateTimeFormat = "u"; + ApiClient api = new ApiClient(); + + // test datetime + DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind); + Assert.AreEqual("2009-06-15 20:45:30Z", api.ParameterToString(dateUtc)); + } + + [Test ()] + public void TestParameterToString_DateTime_WithCustomFormat () + { + // Setup the DateTimeFormat across all of the calls + Configuration.DateTimeFormat = "dd/MM/yy HH:mm:ss"; + ApiClient api = new ApiClient(); + + // test datetime + DateTime dateUtc = DateTime.Parse("2009-06-15 20:45:30Z", null, System.Globalization.DateTimeStyles.RoundtripKind); + Assert.AreEqual("15/06/09 20:45:30", api.ParameterToString(dateUtc)); + } + } } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs index c508917e7d5..c72a0006691 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestConfiguration.cs @@ -5,10 +5,17 @@ using IO.Swagger.Client; using IO.Swagger.Api; using IO.Swagger.Model; -namespace SwaggerClient.TestConfiguration +namespace SwaggerClientTest.TestConfiguration { public class TestConfiguration { + [TearDown ()] + public void TearDown () + { + // Reset to default, just in case + Configuration.DateTimeFormat = "o"; + } + [Test ()] public void TestAuthentication () { @@ -32,7 +39,23 @@ namespace SwaggerClient.TestConfiguration Assert.AreNotSame (p.Configuration, Configuration.Default); } - [Test ()] + [Test ()] + public void TestDateTimeFormat_Default () + { + // Should default to the Round-trip Format Specifier - "o" + // https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 + Assert.AreEqual("o", Configuration.DateTimeFormat); + } + + [Test ()] + public void TestDateTimeFormat_UType() + { + Configuration.DateTimeFormat = "u"; + + Assert.AreEqual("u", Configuration.DateTimeFormat); + } + + [Test ()] public void TestDefautlConfiguration () { PetApi p1 = new PetApi (); diff --git a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs index 55d081f9bb1..7c21f8efeaf 100644 --- a/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs +++ b/samples/client/petstore/csharp/SwaggerClientTest/TestPet.cs @@ -6,9 +6,9 @@ using System.Collections.Generic; using IO.Swagger.Api; using IO.Swagger.Model; using IO.Swagger.Client; +using System.Reflection; - -namespace SwaggerClient.TestPet +namespace SwaggerClientTest.TestPet { [TestFixture ()] public class TestPet @@ -166,15 +166,15 @@ namespace SwaggerClient.TestPet [Test ()] public void TestUploadFile () { - PetApi petApi = new PetApi (); - //NOTE: please provide a valid file (full path) - FileStream fileStream = new FileStream("/var/tmp/small.gif", FileMode.Open); + Assembly _assembly = Assembly.GetExecutingAssembly(); + Stream _imageStream = _assembly.GetManifestResourceStream("SwaggerClientTest.swagger-logo.png"); + PetApi petApi = new PetApi (); // test file upload with form parameters - petApi.UploadFile(petId, "new form name", fileStream); + petApi.UploadFile(petId, "new form name", _imageStream); // test file upload without any form parameters // using optional parameter syntax introduced at .net 4.0 - petApi.UploadFile(petId: petId, file: fileStream); + petApi.UploadFile(petId: petId, file: _imageStream); } diff --git a/samples/client/petstore/csharp/SwaggerClientTest/swagger-logo.png b/samples/client/petstore/csharp/SwaggerClientTest/swagger-logo.png new file mode 100644 index 00000000000..7671d64c7da Binary files /dev/null and b/samples/client/petstore/csharp/SwaggerClientTest/swagger-logo.png differ