-
Notifications
You must be signed in to change notification settings - Fork 283
Description
The Reader code makes a "best effort" to deserialize the document as the latest spec version, V3 as of writing this issue, when the version number is not recognized. Instead, I would like the Reader to thrown an unsupported spec version exception.
Context of code
----------------
Class: https://github.com/Microsoft/OpenAPI.NET/blob/master/src/Microsoft.OpenApi.Readers/ParsingContext.cs
Method: Parse()
// If version number is not recognizable,
// our best effort will try to deserialize the document to V3.
this.VersionService = new OpenApiV3VersionService();
doc = this.VersionService.LoadDocument(this.RootNode);
diagnostic.SpecificationVersion = OpenApiSpecVersion.OpenApi3_0;
As a consumer of the Reader, I do not trust the Reader to parse a document it does not offer support for yet. For example, in the future, I could be passing a document of version 4, and this document may or may not be read correctly. Instead of potentially passing silently with issues, I'd rather know the library isn't updated to support V4 yet.
If this "best effort" default read case is in the library for a particular reason, perhaps there should be a "force" option that callers can specify to read unrecognized documents.