@@ -11,6 +11,10 @@ const { ono } = require("@jsdevtools/ono");
11
11
const { $RefParser } = require ( "@apidevtools/json-schema-ref-parser" ) ;
12
12
const { dereferenceInternal : dereference } = require ( "@apidevtools/json-schema-ref-parser" ) ;
13
13
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
+
14
18
/**
15
19
* This class parses a Swagger 2.0 or 3.0 API, resolves its JSON references and their resolved values,
16
20
* and provides methods for traversing, dereferencing, and validating the API.
@@ -56,14 +60,12 @@ class SwaggerParser extends $RefParser {
56
60
}
57
61
}
58
62
else {
59
- let supportedVersions = [ "3.0.0" , "3.0.1" , "3.0.2" , "3.0.3" , "3.1.0" ] ;
60
-
61
63
// Verify that the parsed object is a Openapi API
62
64
if ( schema . openapi === undefined || schema . info === undefined ) {
63
65
throw ono . syntax ( `${ args . path || args . schema } is not a valid Openapi API definition` ) ;
64
66
}
65
67
else if ( schema . paths === undefined ) {
66
- if ( schema . openapi === "3.1.0" ) {
68
+ if ( supported31Versions . indexOf ( schema . openapi ) !== - 1 ) {
67
69
if ( schema . webhooks === undefined ) {
68
70
throw ono . syntax ( `${ args . path || args . schema } is not a valid Openapi API definition` ) ;
69
71
}
0 commit comments