Skip to content

Commit 327a169

Browse files
committed
fix: adds missing versions 3.0.4 and 3.1.1 to the supported versions
1 parent 3ebf612 commit 327a169

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

lib/index.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const { ono } = require("@jsdevtools/ono");
1111
const { $RefParser } = require("@apidevtools/json-schema-ref-parser");
1212
const { dereferenceInternal: dereference } = require("@apidevtools/json-schema-ref-parser");
1313

14+
const supported31Versions = ["3.1.0", "3.1.1"];
15+
const supported30Versions = ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4"];
16+
const supportedVersions = [...supported31Versions, ...supported30Versions];
17+
1418
/**
1519
* This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values,
1620
* and provides methods for traversing, dereferencing, and validating the API.
@@ -56,14 +60,12 @@ class SwaggerParser extends $RefParser {
5660
}
5761
}
5862
else {
59-
let supportedVersions = ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0"];
60-
6163
// Verify that the parsed object is a Openapi API
6264
if (schema.openapi === undefined || schema.info === undefined) {
6365
throw ono.syntax(`${args.path || args.schema} is not a valid Openapi API definition`);
6466
}
6567
else if (schema.paths === undefined) {
66-
if (schema.openapi === "3.1.0") {
68+
if (supported31Versions.indexOf(schema.openapi) !== -1) {
6769
if (schema.webhooks === undefined) {
6870
throw ono.syntax(`${args.path || args.schema} is not a valid Openapi API definition`);
6971
}

0 commit comments

Comments
 (0)