Skip to content

Commit

Permalink
fix: adds missing versions 3.0.4 and 3.1.1 to the supported versions (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
baywet authored Jan 7, 2025
1 parent 3ebf612 commit 3c907d7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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`);
}
Expand Down

0 comments on commit 3c907d7

Please sign in to comment.