Skip to content

Commit 4c4d257

Browse files
committed
fix: a bug where empty collections would not be serialized for default values
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 7d7856d commit 4c4d257

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/Microsoft.OpenApi/Writers/OpenApiWriterExtensions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ public static void WriteOptionalObject<T>(
141141
{
142142
if (value != null)
143143
{
144-
if (value is IEnumerable values && !values.GetEnumerator().MoveNext())
144+
if (value is IEnumerable values && value is not JsonArray && !values.GetEnumerator().MoveNext())
145145
{
146-
return; // Don't render optional empty collections
146+
return; // Don't render optional empty collections except for the Default properties which are JsonArray
147147
}
148148

149149
writer.WriteRequiredObject(name, value, action);

0 commit comments

Comments
 (0)