Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the OpenApiStreamReader's Read and ReadFragment method to be consistent with ReadAsync #1582

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading