@@ -7,7 +7,9 @@ var expect = require('chai').expect,
7
7
VALID_OPENAPI_PATH = '../data/valid_openapi' ,
8
8
INVALID_OPENAPI_PATH = '../data/invalid_openapi' ,
9
9
SWAGGER_20_FOLDER_YAML = '../data/valid_swagger/yaml/' ,
10
- SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/' ;
10
+ SWAGGER_20_FOLDER_JSON = '../data/valid_swagger/json/' ,
11
+ VALID_OPENAPI_3_1_FOLDER_JSON = '../data/valid_openapi31X/json' ,
12
+ VALID_OPENAPI_3_1_FOLDER_YAML = '../data/valid_openapi31X/yaml' ;
11
13
12
14
describe ( 'CONVERT FUNCTION TESTS ' , function ( ) {
13
15
// these two covers remaining part of util.js
@@ -2015,10 +2017,10 @@ describe('INTERFACE FUNCTION TESTS ', function () {
2015
2017
describe ( 'The converter must identify valid OA3 specification' , function ( ) {
2016
2018
var pathPrefix = VALID_OPENAPI_PATH ,
2017
2019
sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ,
2018
- oa3_1_files = [ 'issue#479_2.yaml' , 'issue#10229.json' , 'query_param_with_enum_resolve_as_example.json' ] ;
2020
+ oa31Files = [ 'issue#479_2.yaml' , 'issue#10229.json' , 'query_param_with_enum_resolve_as_example.json' ] ;
2019
2021
2020
2022
sampleSpecs . map ( ( sample ) => {
2021
- if ( ! oa3_1_files . includes ( sample ) ) {
2023
+ if ( ! oa31Files . includes ( sample ) ) {
2022
2024
var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2023
2025
2024
2026
it ( specPath + ' is valid ' , function ( done ) {
@@ -2051,6 +2053,51 @@ describe('INTERFACE FUNCTION TESTS ', function () {
2051
2053
} ) ;
2052
2054
} ) ;
2053
2055
2056
+ describe ( 'The converter must identify valid OA3.1 specifications - JSON' , function ( ) {
2057
+ var pathPrefix = VALID_OPENAPI_3_1_FOLDER_JSON ,
2058
+ sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ,
2059
+ oa30Files = [ 'deprecated_property.json' ] ,
2060
+ incorrectOA31Files = [ 'webhooks.json' ] ,
2061
+ filesToIgnore = oa30Files + incorrectOA31Files ;
2062
+
2063
+
2064
+ sampleSpecs . map ( ( sample ) => {
2065
+ if ( ! filesToIgnore . includes ( sample ) ) {
2066
+ var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2067
+
2068
+ it ( specPath + ' is valid ' , function ( done ) {
2069
+ var openapi = fs . readFileSync ( specPath , 'utf8' ) ,
2070
+ validationResult = Converter . validate ( { type : 'string' , data : openapi } ) ;
2071
+
2072
+ expect ( validationResult . result ) . to . equal ( true ) ;
2073
+ expect ( validationResult . specificationVersion ) . to . equal ( '3.1.x' ) ;
2074
+ done ( ) ;
2075
+ } ) ;
2076
+ }
2077
+ } ) ;
2078
+ } ) ;
2079
+
2080
+ describe ( 'The converter must identify valid OA3.1 specifications - YAML' , function ( ) {
2081
+ var pathPrefix = VALID_OPENAPI_3_1_FOLDER_YAML ,
2082
+ sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ,
2083
+ invalidOA31Files = [ 'marketPayNotificationService4.yaml' ] ;
2084
+
2085
+ sampleSpecs . map ( ( sample ) => {
2086
+ if ( ! invalidOA31Files . includes ( sample ) ) {
2087
+ var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2088
+
2089
+ it ( specPath + ' is valid ' , function ( done ) {
2090
+ var openapi = fs . readFileSync ( specPath , 'utf8' ) ,
2091
+ validationResult = Converter . validate ( { type : 'string' , data : openapi } ) ;
2092
+
2093
+ expect ( validationResult . result ) . to . equal ( true ) ;
2094
+ expect ( validationResult . specificationVersion ) . to . equal ( '3.1.x' ) ;
2095
+ done ( ) ;
2096
+ } ) ;
2097
+ }
2098
+ } ) ;
2099
+ } ) ;
2100
+
2054
2101
describe ( 'The converter must identify valid OA2 specifications - YAML' , function ( ) {
2055
2102
var pathPrefix = SWAGGER_20_FOLDER_YAML ,
2056
2103
sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ;
0 commit comments