Skip to content

Commit

Permalink
Update the Read and ReadFragment method to be consistent with the change
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Mar 6, 2024
1 parent 9036a21 commit d763e53
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,8 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null)
/// <returns>Instance of newly created OpenApiDocument.</returns>
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic)
{
var reader = new StreamReader(input);
var result = new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
if (!_settings.LeaveStreamOpen)
{
reader.Dispose();
}

return result;
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic);
}

/// <summary>
Expand Down Expand Up @@ -86,7 +80,7 @@ public async Task<ReadResult> ReadAsync(Stream input, CancellationToken cancella
/// <returns>Instance of newly created OpenApiDocument</returns>
public T ReadFragment<T>(Stream input, OpenApiSpecVersion version, out OpenApiDiagnostic diagnostic) where T : IOpenApiReferenceable
{
using var reader = new StreamReader(input);
using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen);
return new OpenApiTextReaderReader(_settings).ReadFragment<T>(reader, version, out diagnostic);
}
}
Expand Down

0 comments on commit d763e53

Please sign in to comment.