diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx index 1fe281a75..539bbba2c 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPIOperation.tsx @@ -23,7 +23,7 @@ export async function OpenAPIOperation(props: BlockProps) { - const { block, context } = props; + const { block, context, style } = props; if (!context.contentContext) { return null; @@ -36,11 +36,9 @@ async function OpenAPIOperationBody(props: BlockProps if (error) { return ( -
-

- Error with {specUrl}: {error.message} -

-
+

+ Error while loading OpenAPI operation — {error.message} +

); } diff --git a/packages/gitbook/src/lib/openapi/resolveOpenAPIOperationBlock.ts b/packages/gitbook/src/lib/openapi/resolveOpenAPIOperationBlock.ts index fa980bd53..fb0ef3283 100644 --- a/packages/gitbook/src/lib/openapi/resolveOpenAPIOperationBlock.ts +++ b/packages/gitbook/src/lib/openapi/resolveOpenAPIOperationBlock.ts @@ -1,5 +1,5 @@ import { fetchOpenAPIFilesystem } from '@/lib/openapi/fetch'; -import { OpenAPIParseError } from '@gitbook/openapi-parser'; +import type { OpenAPIParseError } from '@gitbook/openapi-parser'; import { type OpenAPIOperationData, resolveOpenAPIOperation } from '@gitbook/react-openapi'; import type { AnyOpenAPIOperationsBlock, @@ -55,8 +55,8 @@ async function baseResolveOpenAPIOperationBlock( return { data, specUrl }; } catch (error) { - if (error instanceof OpenAPIParseError) { - return { error }; + if (error instanceof Error && error.name === 'OpenAPIParseError') { + return { error: error as OpenAPIParseError }; } throw error;