Skip to content

Commit 422275b

Browse files
committed
chore: reduce allocations during serialization
Signed-off-by: Vincent Biret <vibiret@microsoft.com>
1 parent 87c5877 commit 422275b

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

src/Microsoft.OpenApi/Converters/OpenApiSchemaJsonConverter.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) Microsoft Corporation. All rights reserved.
1+
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT license.
33

44
using System;
@@ -73,9 +73,7 @@ public override void Write(Utf8JsonWriter writer, OpenApiSchema value, JsonSeria
7373
textWriter.Flush();
7474
}
7575

76-
stream.Position = 0;
77-
using var document = JsonDocument.Parse(stream);
78-
document.RootElement.WriteTo(writer);
76+
writer.WriteRawValue(stream.ToArray(), skipInputValidation: true);
7977
}
8078

8179
private void SerializeSchema(OpenApiSchema schema, OpenApiJsonWriter writer)

0 commit comments

Comments
 (0)