mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Catch OpenAPI validation errors (#3602)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@gitbook/openapi-parser': patch
|
||||
---
|
||||
|
||||
Catch OpenAPI validation errors
|
||||
@@ -10,7 +10,14 @@ import type { ParseOpenAPIInput, ParseOpenAPIResult } from './parse';
|
||||
*/
|
||||
export async function parseOpenAPIV3(input: ParseOpenAPIInput): Promise<ParseOpenAPIResult> {
|
||||
const { value, rootURL, options = {} } = input;
|
||||
const result = await validate(value);
|
||||
|
||||
const result = await validate(value).catch((error) => {
|
||||
throw new OpenAPIParseError('Invalid OpenAPI document', {
|
||||
code: 'invalid',
|
||||
rootURL,
|
||||
cause: error,
|
||||
});
|
||||
});
|
||||
|
||||
// If there is no version, we consider it invalid instantely.
|
||||
if (!result.version) {
|
||||
|
||||
Reference in New Issue
Block a user