Skip to content

Commit 00c6a27

Browse files
committed
fix(tests): use ReferenceHandler.Preserve for STJ snapshot with $dynamicRef
The Serialize_DoesNotMutateDom tests use System.Text.Json to snapshot the DOM before and after native serialization. Bare $dynamicRef schemas now deserialize as OpenApiSchemaReference whose computed getters expose the resolved target's properties, creating reflection cycles for recursive dynamic refs. ReferenceHandler.Preserve lets STJ handle cycles via $id/$ref metadata while still detecting DOM mutations.
1 parent 4922341 commit 00c6a27

2 files changed

Lines changed: 2 additions & 0 deletions

File tree

test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiDocumentSerializationTests .cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public async Task Serialize_DoesNotMutateDom(OpenApiSpecVersion version)
2727
// Act: Serialize using System.Text.Json
2828
var options = new JsonSerializerOptions
2929
{
30+
ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve,
3031
Converters =
3132
{
3233
new HttpMethodOperationDictionaryConverter()

test/Microsoft.OpenApi.Readers.Tests/V32Tests/OpenApiDocumentSerializationTests .cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public async Task Serialize_DoesNotMutateDom(OpenApiSpecVersion version)
2828
// Act: Serialize using System.Text.Json
2929
var options = new JsonSerializerOptions
3030
{
31+
ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.Preserve,
3132
Converters =
3233
{
3334
new HttpMethodOperationDictionaryConverter()

0 commit comments

Comments
 (0)