From d763e535092e21656f827d591c7d5ec6c826326c Mon Sep 17 00:00:00 2001 From: Maggiekimani1 Date: Wed, 6 Mar 2024 14:20:47 +0300 Subject: [PATCH] Update the Read and ReadFragment method to be consistent with the change --- src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs index ae01833fb..c9431de98 100644 --- a/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs +++ b/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs @@ -41,14 +41,8 @@ public OpenApiStreamReader(OpenApiReaderSettings settings = null) /// Instance of newly created OpenApiDocument. 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); } /// @@ -86,7 +80,7 @@ public async Task ReadAsync(Stream input, CancellationToken cancella /// Instance of newly created OpenApiDocument public T ReadFragment(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(reader, version, out diagnostic); } }