diff --git a/packages/openapi-parser/src/v3.ts b/packages/openapi-parser/src/v3.ts index 557c2350c4..4d0ada9358 100644 --- a/packages/openapi-parser/src/v3.ts +++ b/packages/openapi-parser/src/v3.ts @@ -19,24 +19,30 @@ export async function parseOpenAPIV3(input: { rootURL: string | null; }): Promise> { const { value, rootURL } = input; - const result = await validate(value); - // Spec is invalid, we stop here. - if (!result.specification) { - throw new OpenAPIParseError('Invalid OpenAPI document', { - code: 'invalid', - rootURL, - }); - } + try { + const result = await validate(value); + // Spec is invalid, we stop here. + if (!result.specification) { + throw new OpenAPIParseError('Invalid OpenAPI document', { + code: 'invalid', + rootURL, + }); + } - if (result.version === '2.0') { - throw new OpenAPIParseError('Only OpenAPI v3 is supported', { - code: 'parse-v2-in-v3', - rootURL, - }); - } + if (result.version === '2.0') { + throw new OpenAPIParseError('Only OpenAPI v3 is supported', { + code: 'parse-v2-in-v3', + rootURL, + }); + } - const filesystem = await createFileSystem({ value: result.specification, rootURL }); + const filesystem = await createFileSystem({ value: result.specification, rootURL }); - return filesystem; + return filesystem; + } catch (err) { + console.error(err); + console.trace(); + throw err; + } }