forked from loafle/openapi-generator-original
Add tests for array of string serialization (#8913)
* add tests for array of string serialization * update test file SHA
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
# csharp-netcore test files and image for upload
|
||||
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/Api/PetApiTests.cs"
|
||||
sha256: aceebba316148a2a803a15ef4e13bbd0b0a1b8d15006cd88adb9b39a620ee451
|
||||
sha256: dae985015ba461297927d544a78267f2def35e07c3f14ca66468fd61e1fd1c26
|
||||
- filename: "samples/client/petstore/csharp-netcore/OpenAPIClient/src/Org.OpenAPITools.Test/linux-logo.png"
|
||||
sha256: 0a67c32728197e942b13bdda064b73793f12f5c795f1e5cf35a3adf69c973230
|
||||
|
||||
@@ -16,6 +16,8 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using RestSharp;
|
||||
using Xunit;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Serialization;
|
||||
|
||||
using Org.OpenAPITools.Client;
|
||||
using Org.OpenAPITools.Api;
|
||||
@@ -341,6 +343,30 @@ namespace Org.OpenAPITools.Test
|
||||
//petApi.Configuration.AddDefaultHeader("header_key2", "header_value2");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestArrayOfString()
|
||||
{
|
||||
ArrayTest at = new ArrayTest();
|
||||
JsonSerializerSettings _serializerSettings = new JsonSerializerSettings
|
||||
{
|
||||
// OpenAPI generated types generally hide default constructors.
|
||||
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor,
|
||||
ContractResolver = new DefaultContractResolver
|
||||
{
|
||||
NamingStrategy = new CamelCaseNamingStrategy
|
||||
{
|
||||
OverrideSpecifiedNames = false
|
||||
}
|
||||
}
|
||||
};
|
||||
Assert.Equal("{}", JsonConvert.SerializeObject(at, _serializerSettings));
|
||||
|
||||
at.ArrayOfString = new List<string> { "Something here ..." };
|
||||
|
||||
Assert.Equal("{\"array_of_string\":[\"Something here ...\"]}", JsonConvert.SerializeObject(at, _serializerSettings));
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// remove the pet after testing
|
||||
|
||||
Reference in New Issue
Block a user