@@ -2011,6 +2011,61 @@ describe('INTERFACE FUNCTION TESTS ', function () {
2011
2011
} ) ;
2012
2012
} ) ;
2013
2013
} ) ;
2014
+
2015
+ describe ( 'The converter must identify valid OA3 & 3.1 specifications' , function ( ) {
2016
+ var pathPrefix = VALID_OPENAPI_PATH ,
2017
+ sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ;
2018
+
2019
+ sampleSpecs . map ( ( sample ) => {
2020
+ var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2021
+
2022
+ it ( specPath + ' is valid ' , function ( done ) {
2023
+ var openapi = fs . readFileSync ( specPath , 'utf8' ) ,
2024
+ validationResult = Converter . validate ( { type : 'string' , data : openapi } ) ;
2025
+
2026
+ expect ( validationResult . result ) . to . equal ( true ) ;
2027
+ expect ( validationResult . specificationVersion ) . to . be . oneOf ( [ '3.0.x' , '3.1.x' ] ) ;
2028
+ done ( ) ;
2029
+ } ) ;
2030
+ } ) ;
2031
+ } ) ;
2032
+
2033
+ describe ( 'The converter must identify valid OA2 specifications - JSON' , function ( ) {
2034
+ var pathPrefix = SWAGGER_20_FOLDER_JSON ,
2035
+ sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ;
2036
+
2037
+ sampleSpecs . map ( ( sample ) => {
2038
+ var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2039
+
2040
+ it ( specPath + ' is valid ' , function ( done ) {
2041
+ var openapi = fs . readFileSync ( specPath , 'utf8' ) ,
2042
+ validationResult = Converter . validate ( { type : 'string' , data : openapi } ) ;
2043
+
2044
+ expect ( validationResult . result ) . to . equal ( true ) ;
2045
+ expect ( validationResult . specificationVersion ) . to . equal ( '2.0' ) ;
2046
+ done ( ) ;
2047
+ } ) ;
2048
+ } ) ;
2049
+ } ) ;
2050
+
2051
+ describe ( 'The converter must identify valid OA2 specifications - YAML' , function ( ) {
2052
+ var pathPrefix = SWAGGER_20_FOLDER_YAML ,
2053
+ sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ;
2054
+
2055
+ sampleSpecs . map ( ( sample ) => {
2056
+ var specPath = path . join ( __dirname , pathPrefix , sample ) ;
2057
+
2058
+ it ( specPath + ' is valid ' , function ( done ) {
2059
+ var openapi = fs . readFileSync ( specPath , 'utf8' ) ,
2060
+ validationResult = Converter . validate ( { type : 'string' , data : openapi } ) ;
2061
+
2062
+ expect ( validationResult . result ) . to . equal ( true ) ;
2063
+ expect ( validationResult . specificationVersion ) . to . equal ( '2.0' ) ;
2064
+ done ( ) ;
2065
+ } ) ;
2066
+ } ) ;
2067
+ } ) ;
2068
+
2014
2069
describe ( 'The converter must identify invalid specifications' , function ( ) {
2015
2070
var pathPrefix = INVALID_OPENAPI_PATH ,
2016
2071
sampleSpecs = fs . readdirSync ( path . join ( __dirname , pathPrefix ) ) ;
0 commit comments