Skip to content

Commit

Permalink
Pass cancellation token
Browse files Browse the repository at this point in the history
  • Loading branch information
MaggieKimani1 committed Dec 20, 2024
1 parent 7270a89 commit b033b76
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Microsoft.OpenApi/Reader/OpenApiModelFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public static async Task<ReadResult> LoadAsync(string url, OpenApiReaderSettings
public static async Task<T> LoadAsync<T>(string url, OpenApiSpecVersion version, OpenApiReaderSettings settings = null, CancellationToken token = default) where T : IOpenApiElement
{
var (stream, format) = await RetrieveStreamAndFormatAsync(url, token).ConfigureAwait(false);
return await LoadAsync<T>(stream, version, format, settings);
return await LoadAsync<T>(stream, version, format, settings, token);
}

/// <summary>
Expand Down Expand Up @@ -143,11 +143,13 @@ public static async Task<ReadResult> LoadAsync(Stream input, string format = nul
/// <param name="version"></param>
/// <param name="format"></param>
/// <param name="settings"></param>
/// <param name="token"></param>
/// <returns></returns>
public static async Task<T> LoadAsync<T>(Stream input,
OpenApiSpecVersion version,
string format = null,
OpenApiReaderSettings settings = null) where T : IOpenApiElement
OpenApiReaderSettings settings = null,
CancellationToken token = default) where T : IOpenApiElement
{
if (input is null) throw new ArgumentNullException(nameof(input));
if (input is MemoryStream memoryStream)
Expand All @@ -157,7 +159,7 @@ public static async Task<T> LoadAsync<T>(Stream input,
else
{
memoryStream = new MemoryStream();
await input.CopyToAsync(memoryStream).ConfigureAwait(false);
await input.CopyToAsync(memoryStream, 81920, token).ConfigureAwait(false);
memoryStream.Position = 0;
return Load<T>(memoryStream, version, format, out var _, settings);
}
Expand Down

0 comments on commit b033b76

Please sign in to comment.