Skip to content

Commit f0146c3

Browse files
committed
chore: clean up code and add test
1 parent 74d20ed commit f0146c3

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ static JsonNode LoadJsonNodesFromYamlDocument(TextReader input)
126126
yamlStream.Load(input);
127127
if (yamlStream.Documents.Any())
128128
{
129-
var yamlDocument = yamlStream.Documents[0];
130-
return yamlDocument.ToJsonNode();
129+
return yamlStream.Documents[0].ToJsonNode();
131130
}
132131

133132
throw new InvalidOperationException("No documents found in the YAML stream.");

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
using Microsoft.OpenApi.Writers;
1212
using Xunit;
1313
using VerifyXunit;
14-
using VerifyTests;
1514
using Microsoft.OpenApi.Models.Interfaces;
15+
using System;
1616

1717
namespace Microsoft.OpenApi.Readers.Tests.V31Tests
1818
{
@@ -539,5 +539,11 @@ public async Task ParseDocumentWith31PropertiesWorks()
539539
// Assert
540540
await Verifier.Verify(actual);
541541
}
542+
543+
[Fact]
544+
public void ParseEmptyMemoryStreamThrowsAnArgumentException()
545+
{
546+
Assert.Throws<ArgumentException>(() => OpenApiDocument.Load(new MemoryStream()));
547+
}
542548
}
543549
}

0 commit comments

Comments
 (0)