Skip to content

Commit a33a315

Browse files
committed
Clean up tests and add a null check
1 parent b307c49 commit a33a315

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

src/Microsoft.OpenApi/Writers/OpenApiWriterAnyExtensions.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@ public static void WriteExtensions(this IOpenApiWriter writer, IDictionary<strin
3232
foreach (var item in extensions)
3333
{
3434
writer.WritePropertyName(item.Key);
35-
item.Value.Write(writer, specVersion);
35+
36+
if (item.Value == null)
37+
{
38+
writer.WriteNull();
39+
}
40+
else
41+
{
42+
item.Value.Write(writer, specVersion);
43+
}
3644
}
3745
}
3846
}

test/Microsoft.OpenApi.Tests/Models/OpenApiTagTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ public void SerializeAdvancedTagAsV3YamlWithoutReferenceWorks()
168168
externalDocs:
169169
description: Find more info here
170170
url: https://example.com
171-
x-tag-extension:";
171+
x-tag-extension: ";
172172

173173
// Act
174174
AdvancedTag.SerializeAsV3WithoutReference(writer);
@@ -193,7 +193,7 @@ public void SerializeAdvancedTagAsV2YamlWithoutReferenceWorks()
193193
externalDocs:
194194
description: Find more info here
195195
url: https://example.com
196-
x-tag-extension:";
196+
x-tag-extension: ";
197197

198198
// Act
199199
AdvancedTag.SerializeAsV2WithoutReference(writer);

0 commit comments

Comments
 (0)