-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handle invalid schema data (#106)
* fix: handle invalid schema data * fix: lint
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
30 changes: 30 additions & 0 deletions
30
src/oas2/transformers/__tests__/getExamplesFromSchema.test.ts
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,30 @@ | ||
import { getExamplesFromSchema } from '../getExamplesFromSchema'; | ||
|
||
describe('getExamplesFromSchema', () => { | ||
it('should ignore invalid data', () => { | ||
// @ts-ignore | ||
expect(getExamplesFromSchema(null)).toEqual({}); | ||
}); | ||
|
||
it('should work with x-examples', () => { | ||
expect( | ||
getExamplesFromSchema({ | ||
'x-examples': { | ||
'my-example': {}, | ||
}, | ||
}), | ||
).toEqual({ | ||
'my-example': {}, | ||
}); | ||
}); | ||
|
||
it('should work with example', () => { | ||
expect( | ||
getExamplesFromSchema({ | ||
example: 'my-example', | ||
}), | ||
).toEqual({ | ||
default: 'my-example', | ||
}); | ||
}); | ||
}); |
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