diff --git a/dotnet/src/Functions/Functions.OpenApi/Serialization/OpenApiTypeConverter.cs b/dotnet/src/Functions/Functions.OpenApi/Serialization/OpenApiTypeConverter.cs index 5b7422950d15..dbed711cd3c1 100644 --- a/dotnet/src/Functions/Functions.OpenApi/Serialization/OpenApiTypeConverter.cs +++ b/dotnet/src/Functions/Functions.OpenApi/Serialization/OpenApiTypeConverter.cs @@ -30,7 +30,12 @@ public static JsonNode Convert(string name, string type, object argument) "string" => JsonValue.Create(argument), "array" => argument switch { - string s => JsonArray.Parse(s) as JsonArray, +#if NETSTANDARD2_1_OR_GREATER + string s when s.Trim().StartsWith('[') => JsonArray.Parse(s) as JsonArray, +#else + string s when s.Trim().StartsWith("[", StringComparison.OrdinalIgnoreCase) => JsonArray.Parse(s) as JsonArray, +#endif + string s => [JsonValue.Create(s)], _ => JsonSerializer.SerializeToNode(argument) as JsonArray }, "integer" => argument switch diff --git a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs index 9331bb0b55a2..9ec1ee5f3a39 100644 --- a/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs +++ b/dotnet/src/Functions/Functions.UnitTests/OpenApi/Serialization/OpenApiTypeConverterTests.cs @@ -111,5 +111,7 @@ public void ItShouldConvertCollections() Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", new Collection() { 1, 2, 3 }).ToJsonString()); Assert.Equal("[1,2,3]", OpenApiTypeConverter.Convert("id", "array", "[1, 2, 3]").ToJsonString()); + + Assert.Equal("[\"createdDate desc\"]", OpenApiTypeConverter.Convert("id", "array", "createdDate desc").ToJsonString()); } }