From 7d0b422200f154c6d095326b94093e538c8409e6 Mon Sep 17 00:00:00 2001 From: "Nolann B." <100787331+nolannbiron@users.noreply.github.com> Date: Tue, 1 Apr 2025 17:24:43 +0200 Subject: [PATCH] Handle grouped OpenAPISchemas (#3071) --- .changeset/fuzzy-buckets-talk.md | 6 ++++++ .../DocumentView/OpenAPI/OpenAPISchemas.tsx | 1 + .../react-openapi/src/schemas/OpenAPISchemas.tsx | 15 ++++++++++----- 3 files changed, 17 insertions(+), 5 deletions(-) create mode 100644 .changeset/fuzzy-buckets-talk.md diff --git a/.changeset/fuzzy-buckets-talk.md b/.changeset/fuzzy-buckets-talk.md new file mode 100644 index 000000000..39a0cf45c --- /dev/null +++ b/.changeset/fuzzy-buckets-talk.md @@ -0,0 +1,6 @@ +--- +'@gitbook/react-openapi': patch +'gitbook': patch +--- + +Handle grouped OpenAPISchemas diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx index e288e9047..b2a8415e1 100644 --- a/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx +++ b/packages/gitbook/src/components/DocumentView/OpenAPI/OpenAPISchemas.tsx @@ -50,6 +50,7 @@ async function OpenAPISchemasBody(props: BlockProps) { return ( - + ); } @@ -44,11 +48,12 @@ export function OpenAPISchemas(props: { function OpenAPIRootSchemasSchema(props: { schemas: OpenAPISchemasData['schemas']; context: OpenAPIClientContext; + grouped?: boolean; }) { - const { schemas, context } = props; + const { schemas, context, grouped } = props; - // If there is only one model, we show it directly. - if (schemas.length === 1) { + // If there is only one model and we are not grouping, we show it directly. + if (schemas.length === 1 && !grouped) { const schema = schemas?.[0]?.schema; if (!schema) {