Commit 0e636a3 1 parent b3d9005 commit 0e636a3 Copy full SHA for 0e636a3
File tree 2 files changed +8
-4
lines changed
2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
- import { AsyncAPIDocumentV2 , AsyncAPIDocumentV3 } from './models' ;
1
+ import { AsyncAPIDocumentV2 , AsyncAPIDocumentV3 , ParserAPIVersion } from './models' ;
2
2
import { unstringify } from './stringify' ;
3
3
import { createDetailedAsyncAPI } from './utils' ;
4
4
@@ -43,7 +43,7 @@ export function isAsyncAPIDocument(maybeDoc: unknown): maybeDoc is AsyncAPIDocum
43
43
}
44
44
if ( maybeDoc && typeof ( maybeDoc as AsyncAPIDocumentInterface ) . json === 'function' ) {
45
45
const versionOfParserAPI = ( maybeDoc as AsyncAPIDocumentInterface ) . json ( ) [ xParserApiVersion ] ;
46
- return versionOfParserAPI === 2 ;
46
+ return versionOfParserAPI === ParserAPIVersion ;
47
47
}
48
48
return false ;
49
49
}
Original file line number Diff line number Diff line change @@ -114,8 +114,12 @@ describe('utils', function() {
114
114
expect ( isAsyncAPIDocument ( createAsyncAPIDocument ( detailed ) ) ) . toEqual ( true ) ;
115
115
} ) ;
116
116
117
- it ( 'document with the x-parser-api-version extension set to 2 should be AsyncAPI document' , async function ( ) {
118
- expect ( isAsyncAPIDocument ( { json ( ) { return { [ xParserApiVersion ] : 2 } ; } } ) ) . toEqual ( true ) ;
117
+ it ( 'document with the x-parser-api-version extension set to 3 should be AsyncAPI document' , async function ( ) {
118
+ expect ( isAsyncAPIDocument ( { json ( ) { return { [ xParserApiVersion ] : 3 } ; } } ) ) . toEqual ( true ) ;
119
+ } ) ;
120
+
121
+ it ( 'document with the x-parser-api-version extension set to 2 should not be AsyncAPI document' , async function ( ) {
122
+ expect ( isAsyncAPIDocument ( { json ( ) { return { [ xParserApiVersion ] : 2 } ; } } ) ) . toEqual ( false ) ;
119
123
} ) ;
120
124
121
125
it ( 'document with the x-parser-api-version extension set to 1 should not be AsyncAPI document' , async function ( ) {
You can’t perform that action at this time.
0 commit comments