Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adds missing version 3.0.4 and 3.1.1 #264

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 { $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 All @@ -27,7 +31,7 @@
*
* @param {string} [path] - The file path or URL of the JSON schema
* @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
* @param {ParserOptions} [options] - Options that determine how the API is parsed

Check warning on line 34 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on ubuntu-latest

The type 'ParserOptions' is undefined

Check warning on line 34 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on macos-latest

The type 'ParserOptions' is undefined

Check warning on line 34 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on windows-latest

The type 'ParserOptions' is undefined
* @param {Function} [callback] - An error-first callback. The second parameter is the parsed API object.
* @returns {Promise} - The returned promise resolves with the parsed API object.
*/
Expand Down Expand Up @@ -56,14 +60,12 @@
}
}
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 Expand Up @@ -106,7 +108,7 @@
*
* @param {string} [path] - The file path or URL of the JSON schema
* @param {object} [api] - The Swagger API object. This object will be used instead of reading from `path`.
* @param {ParserOptions} [options] - Options that determine how the API is parsed, dereferenced, and validated

Check warning on line 111 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on ubuntu-latest

The type 'ParserOptions' is undefined

Check warning on line 111 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on macos-latest

The type 'ParserOptions' is undefined

Check warning on line 111 in lib/index.js

View workflow job for this annotation

GitHub Actions / Node 20 on windows-latest

The type 'ParserOptions' is undefined
* @param {Function} [callback] - An error-first callback. The second parameter is the parsed API object.
* @returns {Promise} - The returned promise resolves with the parsed API object.
*/
Expand Down
Loading