Skip to content

Commit

Permalink
fix: do not emit a type array in 3.1 when unnecessary
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Biret <[email protected]>
  • Loading branch information
baywet committed Jan 31, 2025
1 parent 920a51a commit 3b3d0e6
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Microsoft.OpenApi/Models/OpenApiSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -706,7 +706,14 @@ private void UpCastSchemaTypeToV31(JsonSchemaType type, IOpenApiWriter writer)
var list = (from JsonSchemaType? flag in jsonSchemaTypeValues// Check if the flag is set in 'type' using a bitwise AND operation
where temporaryType.HasFlag(flag)
select flag.ToIdentifier()).ToList();
writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => w.WriteValue(s));
if (list.Count > 1)
{
writer.WriteOptionalCollection(OpenApiConstants.Type, list, (w, s) => w.WriteValue(s));
}
else
{
writer.WriteProperty(OpenApiConstants.Type, list[0]);
}
}

#if NET5_0_OR_GREATER
Expand Down

0 comments on commit 3b3d0e6

Please sign in to comment.