From e9871087513cf981a6c66a799e2f150a7ddcb6da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Berg=C3=A9?= Date: Tue, 25 Mar 2025 15:12:26 +0100 Subject: [PATCH 1/4] Fix OpenAPI spec rendering --- .changeset/stupid-peaches-work.md | 6 + .../src/components/DocumentView/Blocks.tsx | 4 +- .../src/components/DocumentView/Inlines.tsx | 8 +- .../react-openapi/src/InteractiveSection.tsx | 8 +- .../react-openapi/src/OpenAPICodeSample.tsx | 6 +- packages/react-openapi/src/OpenAPIPath.tsx | 4 +- .../react-openapi/src/OpenAPIResponse.tsx | 6 +- .../react-openapi/src/OpenAPIResponses.tsx | 6 +- packages/react-openapi/src/OpenAPISchema.tsx | 113 +++++++++++------- packages/react-openapi/src/OpenAPISpec.tsx | 22 ++-- packages/react-openapi/src/OpenAPITabs.tsx | 16 +-- 11 files changed, 110 insertions(+), 89 deletions(-) create mode 100644 .changeset/stupid-peaches-work.md diff --git a/.changeset/stupid-peaches-work.md b/.changeset/stupid-peaches-work.md new file mode 100644 index 0000000000..c02e5af9a7 --- /dev/null +++ b/.changeset/stupid-peaches-work.md @@ -0,0 +1,6 @@ +--- +"@gitbook/react-openapi": patch +"gitbook": patch +--- + +Fix spec properties rendering and missing keys diff --git a/packages/gitbook/src/components/DocumentView/Blocks.tsx b/packages/gitbook/src/components/DocumentView/Blocks.tsx index 844e8238af..903acd2955 100644 --- a/packages/gitbook/src/components/DocumentView/Blocks.tsx +++ b/packages/gitbook/src/components/DocumentView/Blocks.tsx @@ -54,7 +54,7 @@ export function UnwrappedBlocks(props: UnwrappedBl const { nodes, blockStyle, isOffscreen: defaultIsOffscreen = false, ...contextProps } = props; let isOffscreen = defaultIsOffscreen; - return nodes.map((node) => { + return nodes.map((node, index) => { isOffscreen = isOffscreen || isBlockOffscreen({ @@ -65,7 +65,7 @@ export function UnwrappedBlocks(props: UnwrappedBl return ( ( ) { const { nodes, document, ancestorInlines, ...contextProps } = props; - return nodes.map((node) => { + return nodes.map((node, index) => { + const key = node.key || `key-${index}`; + if (node.object === 'text') { - return ; + return ; } return ( - {(children || selectedTab?.body) && toggeable ? ( + {selectedTab?.body && toggeable ? (