@@ -43,15 +43,11 @@ class SwaggerParser extends $RefParser {
4343 let schema = await super . parse ( args . path , args . schema , args . options ) ;
4444
4545 if ( schema . swagger ) {
46- // Verify that the parsed object is a Swagger API
47- if ( schema . swagger === undefined || schema . info === undefined || schema . paths === undefined ) {
48- throw ono . syntax ( `${ args . path || args . schema } is not a valid Swagger API definition` ) ;
49- }
50- else if ( typeof schema . swagger === "number" ) {
46+ if ( typeof schema . swagger === "number" ) {
5147 // This is a very common mistake, so give a helpful error message
5248 throw ono . syntax ( 'Swagger version number must be a string (e.g. "2.0") not a number.' ) ;
5349 }
54- else if ( typeof schema . info . version === "number" ) {
50+ else if ( schema . info && typeof schema . info . version === "number" ) {
5551 // This is a very common mistake, so give a helpful error message
5652 throw ono . syntax ( 'API version number must be a string (e.g. "1.0.0") not a number.' ) ;
5753 }
@@ -60,11 +56,7 @@ class SwaggerParser extends $RefParser {
6056 }
6157 }
6258 else {
63- // Verify that the parsed object is a Openapi API
64- if ( schema . openapi === undefined || schema . info === undefined ) {
65- throw ono . syntax ( `${ args . path || args . schema } is not a valid Openapi API definition` ) ;
66- }
67- else if ( schema . paths === undefined ) {
59+ if ( schema . paths === undefined ) {
6860 if ( supported31Versions . indexOf ( schema . openapi ) !== - 1 ) {
6961 if ( schema . webhooks === undefined ) {
7062 throw ono . syntax ( `${ args . path || args . schema } is not a valid Openapi API definition` ) ;
@@ -78,7 +70,7 @@ class SwaggerParser extends $RefParser {
7870 // This is a very common mistake, so give a helpful error message
7971 throw ono . syntax ( 'Openapi version number must be a string (e.g. "3.0.0") not a number.' ) ;
8072 }
81- else if ( typeof schema . info . version === "number" ) {
73+ else if ( schema . info && typeof schema . info . version === "number" ) {
8274 // This is a very common mistake, so give a helpful error message
8375 throw ono . syntax ( 'API version number must be a string (e.g. "1.0.0") not a number.' ) ;
8476 }
0 commit comments