Skip to content

Commit

Permalink
chore: clean up code and add test
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Feb 6, 2025
1 parent 74d20ed commit f0146c3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/Microsoft.OpenApi.Readers/OpenApiYamlReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@ static JsonNode LoadJsonNodesFromYamlDocument(TextReader input)
yamlStream.Load(input);
if (yamlStream.Documents.Any())
{
var yamlDocument = yamlStream.Documents[0];
return yamlDocument.ToJsonNode();
return yamlStream.Documents[0].ToJsonNode();
}

throw new InvalidOperationException("No documents found in the YAML stream.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
using Microsoft.OpenApi.Writers;
using Xunit;
using VerifyXunit;
using VerifyTests;
using Microsoft.OpenApi.Models.Interfaces;
using System;

namespace Microsoft.OpenApi.Readers.Tests.V31Tests
{
Expand Down Expand Up @@ -539,5 +539,11 @@ public async Task ParseDocumentWith31PropertiesWorks()
// Assert
await Verifier.Verify(actual);
}

[Fact]
public void ParseEmptyMemoryStreamThrowsAnArgumentException()
{
Assert.Throws<ArgumentException>(() => OpenApiDocument.Load(new MemoryStream()));
}
}
}

0 comments on commit f0146c3

Please sign in to comment.