-
-
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
21 changed files
with
2,523 additions
and
47 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
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
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
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
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
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
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
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
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
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
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,28 @@ | ||
import { isAsyncApiv2 } from '../asyncapi'; | ||
|
||
describe('AsyncApi format', () => { | ||
describe('AsyncApi 2.0', () => { | ||
it.each(['2.0.0'])('recognizes %s version correctly', version => { | ||
expect(isAsyncApiv2({ asyncapi: version })).toBe(true); | ||
}); | ||
|
||
const testCases = [ | ||
{ asyncapi: '3.0' }, | ||
{ asyncapi: '2' }, | ||
{ asyncapi: '2.0' }, | ||
{ asyncapi: '1.0' }, | ||
{ asyncapi: 2 }, | ||
{ openapi: '4.0' }, | ||
{ openapi: '2.0' }, | ||
{ openapi: null }, | ||
{ swagger: null }, | ||
{ swagger: '3.0' }, | ||
{}, | ||
null, | ||
]; | ||
|
||
it.each(testCases)('does not recognize invalid document %o', document => { | ||
expect(isAsyncApiv2(document)).toBe(false); | ||
}); | ||
}); | ||
}); |
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,10 @@ | ||
import { isObject } from 'lodash'; | ||
|
||
type MaybeAsyncApi2 = Partial<{ asyncapi: unknown }>; | ||
|
||
export const bearsAStringPropertyNamed = (document: unknown, propertyName: string) => { | ||
return isObject(document) && propertyName in document && typeof document[propertyName] === 'string'; | ||
}; | ||
|
||
export const isAsyncApiv2 = (document: unknown) => | ||
bearsAStringPropertyNamed(document, 'asyncapi') && String((document as MaybeAsyncApi2).asyncapi) === '2.0.0'; |
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,2 +1,3 @@ | ||
export * from './openapi'; | ||
export * from './asyncapi'; | ||
export * from './json-schema'; |
Oops, something went wrong.