Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Throw exception when document's spec version is not recognized by Reader #177

Copy link
Copy link
@scott-lin

Description

@scott-lin
Issue body actions

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.

Reactions are currently unavailable

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.