Skip to content

Commit 3b3d0e6

Browse files
committed
fix: do not emit a type array in 3.1 when unnecessary
Signed-off-by: Vincent Biret <[email protected]>
1 parent 920a51a commit 3b3d0e6

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/Microsoft.OpenApi/Models/OpenApiSchema.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,14 @@ private void UpCastSchemaTypeToV31(JsonSchemaType type, IOpenApiWriter writer)
706706
var list = (from JsonSchemaType? flag in jsonSchemaTypeValues// Check if the flag is set in 'type' using a bitwise AND operation
707707
where temporaryType.HasFlag(flag)
708708
select flag.ToIdentifier()).ToList();
709-
writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => w.WriteValue(s));
709+
if (list.Count > 1)
710+
{
711+
writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => w.WriteValue(s));
712+
}
713+
else
714+
{
715+
writer.WriteProperty(OpenApiConstants.Type, list[0]);
716+
}
710717
}
711718

712719
#if NET5_0_OR_GREATER

0 commit comments

Comments
 (0)