Catch OpenAPI validation errors (#3602)

This commit is contained in:
Nolann B.
2025-08-27 12:29:50 +02:00
committed by GitHub
parent 729921f338
commit 7fefe4919c
2 changed files with 13 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/openapi-parser': patch
---
Catch OpenAPI validation errors
+8 -1
View File
@@ -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) {