Skip to content

OpenApiStreamReader.Read/ReadAsync doesn't honour "leaveOpen"Setting #1579

@baywet

Description

@baywet

https://github.com/microsoft/OpenAPI.NET/blob/e65b484b512a84351054979bf2901b2462984582/src/Microsoft.OpenApi.Readers/OpenApiStreamReader.cs#L76C36-L76C48

The value from the leave open setting should be passed to the StreamReaderConstructor so it doesn't dispose the stream when asked to keep it open.

Repro:

var stream = new MemoryStream();
// copy the value from a file stream, string etc.. in the stream
var settings = new OpenApiReaderSettings
{
    LeaveStreamOpen = true,
};
var reader = new OpenApiStreamReader(settings);
var result = await reader.ReadAsync(input, cancellationToken)
stream.Seek(0, SeekOrigin.Begin); // results in a object disposed exception when it shouldn't

When this is fixed, we can clean WorskpaceManagementService.MigrateFromLockFileAsync in kiota.

Metadata

Metadata

Assignees

Labels

priority:p1High priority but not blocking. Causes major but not critical loss of functionality SLA <=7daystype:bugA broken experience

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions