-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
8 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import { isObject } from 'lodash'; | ||
import { bearsAStringPropertyNamed } from './bearsAStringPropertyNamed'; | ||
|
||
type MaybeAsyncApi2 = Partial<{ asyncapi: unknown }>; | ||
|
||
export const isAsyncApiv2 = (document: unknown) => | ||
isObject(document) && | ||
'asyncapi' in document && | ||
typeof document.asyncapi === 'string' && | ||
parseFloat(String((document as MaybeAsyncApi2).asyncapi)) === 2; | ||
bearsAStringPropertyNamed(document, 'asyncapi') && parseFloat(String((document as MaybeAsyncApi2).asyncapi)) === 2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { isObject } from 'lodash'; | ||
|
||
export const bearsAStringPropertyNamed = (document: unknown, propertyName: string) => { | ||
return isObject(document) && propertyName in document && typeof document[propertyName] === 'string'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters