mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-07-08 00:20:51 +00:00
Add a unit test for the datetime serialization
This commit is contained in:
parent
23fa84bff8
commit
74d80289dd
@ -156,7 +156,10 @@ namespace IO.Swagger.Client
|
||||
public string ParameterToString(object obj)
|
||||
{
|
||||
if (obj is DateTime)
|
||||
return ((DateTime)obj).ToString ("u");
|
||||
// Return an ISO 8601 formatted string, also known as a Round-trip date/time pattern
|
||||
// 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");
|
||||
else if (obj is IList)
|
||||
{
|
||||
string flattenString = "";
|
||||
|
@ -19,6 +19,11 @@ namespace SwaggerClient.TestApiClient
|
||||
// test array of int
|
||||
List<int> numList = new List<int>(new int[] {1, 37});
|
||||
Assert.AreEqual("1,37", api.ParameterToString (numList));
|
||||
|
||||
// test datetime
|
||||
DateTime date = DateTime.Parse("2008-04-10T13:30:00.0000000Z", null, System.Globalization.DateTimeStyles.RoundtripKind);
|
||||
Assert.AreEqual("2008-04-10T13:30:00.0000000Z", api.ParameterToString (date));
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user