diff --git a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs index d3029193e..0b0fee38b 100644 --- a/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs +++ b/src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs @@ -76,7 +76,10 @@ public static async Task LoadAsync(string url, OpenApiReaderSettings { settings ??= DefaultReaderSettings.Value; var (stream, format) = await RetrieveStreamAndFormatAsync(url, settings, token).ConfigureAwait(false); - return await LoadAsync(stream, format, settings, token).ConfigureAwait(false); + using (stream) + { + return await LoadAsync(stream, format, settings, token).ConfigureAwait(false); + } } /// @@ -94,7 +97,10 @@ public static async Task LoadAsync(string url, OpenApiReaderSettings { settings ??= DefaultReaderSettings.Value; var (stream, format) = await RetrieveStreamAndFormatAsync(url, settings, token).ConfigureAwait(false); - return await LoadAsync(stream, version, openApiDocument, format, settings, token); + using (stream) + { + return await LoadAsync(stream, version, openApiDocument, format, settings, token); + } } ///