-
Notifications
You must be signed in to change notification settings - Fork 265
Description
Hi, I have been using this library without issue, but when I upgraded to the latest version it crashes on Read...
Simple Example
- Create a new C# ConsoleApp (.Net Framework 4.8)
- Add Microsoft.OpenApi.Readers Nuget 1.6.15
- Change Main to...
`
static async Task Main(string[] args)
{
var httpClient = new HttpClient
{
BaseAddress = new Uri("https://raw.githubusercontent.com/OAI/OpenAPI-Specification/")
};
var stream = await httpClient.GetStreamAsync("master/examples/v3.0/petstore.yaml");
// Read V3 as YAML
var openApiDocument = new OpenApiStreamReader().Read(stream, out var diagnostic);
}
`
The issue seems to be that default (null) is passed as the encoding param in OpenApiStreamReader.Read:
public OpenApiDocument Read(Stream input, out OpenApiDiagnostic diagnostic) { using var reader = new StreamReader(input, default, true, -1, _settings.LeaveStreamOpen); return new OpenApiTextReaderReader(_settings).Read(reader, out diagnostic); }
This then throws in StreamReader:
public StreamReader(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int bufferSize, bool leaveOpen) { if (stream == null || encoding == null) { throw new ArgumentNullException((stream == null) ? "stream" : "encoding"); }
I can't see how this can be passing any of the Reading tests?