From 327a1695d455628462171072f50524f90a12df51 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Tue, 31 Dec 2024 07:25:16 -0500 Subject: [PATCH] fix: adds missing versions 3.0.4 and 3.1.1 to the supported versions --- lib/index.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/index.js b/lib/index.js index 2943535b..69841fc3 100644 --- a/lib/index.js +++ b/lib/index.js @@ -11,6 +11,10 @@ const { ono } = require("@jsdevtools/ono"); const { $RefParser } = require("@apidevtools/json-schema-ref-parser"); const { dereferenceInternal: dereference } = require("@apidevtools/json-schema-ref-parser"); +const supported31Versions = ["3.1.0", "3.1.1"]; +const supported30Versions = ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.0.4"]; +const supportedVersions = [...supported31Versions, ...supported30Versions]; + /** * This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values, * and provides methods for traversing, dereferencing, and validating the API. @@ -56,14 +60,12 @@ class SwaggerParser extends $RefParser { } } else { - let supportedVersions = ["3.0.0", "3.0.1", "3.0.2", "3.0.3", "3.1.0"]; - // Verify that the parsed object is a Openapi API if (schema.openapi === undefined || schema.info === undefined) { throw ono.syntax(`${args.path || args.schema} is not a valid Openapi API definition`); } else if (schema.paths === undefined) { - if (schema.openapi === "3.1.0") { + if (supported31Versions.indexOf(schema.openapi) !== -1) { if (schema.webhooks === undefined) { throw ono.syntax(`${args.path || args.schema} is not a valid Openapi API definition`); }