You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Throw exception when document's spec version is not recognized by Reader #177
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.
Also, if this default "best effort" case is not implemented for a particular reason, I plan on removing it and throwing an exception with no "option to force" the current behavior. If you feel otherwise, please let me know and why.
My initial reaction was that we should do best effort on 3.x but fail on 4.x but after thinking some more, I agree that we should just fail on a version that is higher than 3.0.x. I don't think we can fail on a higher patch version.
Activity
PerthCharern commentedon Jan 13, 2018
scott-lin commentedon Jan 13, 2018
Yeah, I'm happy to (not sure how issues get triaged and approved in this work stream yet. I'll sync with you on Tuesday regarding that).
scott-lin commentedon Jan 13, 2018
Also, if this default "best effort" case is not implemented for a particular reason, I plan on removing it and throwing an exception with no "option to force" the current behavior. If you feel otherwise, please let me know and why.
darrelmiller commentedon Jan 13, 2018
My initial reaction was that we should do best effort on 3.x but fail on 4.x but after thinking some more, I agree that we should just fail on a version that is higher than 3.0.x. I don't think we can fail on a higher patch version.