From a4c33997fe071d0cde5c0a0cfaf342954c22546c Mon Sep 17 00:00:00 2001
From: "Nolann B." <100787331+nolannbiron@users.noreply.github.com>
Date: Fri, 3 Oct 2025 13:06:10 +0200
Subject: [PATCH] Fix OpenAPI alternatives not showing (#3699)
---
.changeset/unlucky-pumpkins-yawn.md | 6 ++++++
.../components/DocumentView/OpenAPI/style.css | 2 +-
packages/react-openapi/src/OpenAPISchema.tsx | 20 +++++++++----------
3 files changed, 17 insertions(+), 11 deletions(-)
create mode 100644 .changeset/unlucky-pumpkins-yawn.md
diff --git a/.changeset/unlucky-pumpkins-yawn.md b/.changeset/unlucky-pumpkins-yawn.md
new file mode 100644
index 000000000..8432e572a
--- /dev/null
+++ b/.changeset/unlucky-pumpkins-yawn.md
@@ -0,0 +1,6 @@
+---
+"@gitbook/react-openapi": patch
+"gitbook": patch
+---
+
+Fix OpenAPI alternatives not showing
diff --git a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css
index 2642f2fb1..1d26b0386 100644
--- a/packages/gitbook/src/components/DocumentView/OpenAPI/style.css
+++ b/packages/gitbook/src/components/DocumentView/OpenAPI/style.css
@@ -840,7 +840,7 @@ body:has(.openapi-select-popover) {
}
.openapi-disclosure-trigger-label {
- @apply absolute right-3 px-2 h-5 justify-end shrink-0 ring-tint-subtle truncate text-tint duration-300 transition-all rounded straight-corners:rounded-none circular-corners:rounded-xl flex flex-row gap-1 items-center text-xs;
+ @apply absolute right-3 mr-px px-2 h-5 justify-end shrink-0 ring-tint-subtle truncate text-tint duration-300 transition-all rounded straight-corners:rounded-none circular-corners:rounded-xl flex flex-row gap-1 items-center text-xs;
}
.openapi-disclosure-trigger-label span {
diff --git a/packages/react-openapi/src/OpenAPISchema.tsx b/packages/react-openapi/src/OpenAPISchema.tsx
index 56f55d236..eaa5fe7ad 100644
--- a/packages/react-openapi/src/OpenAPISchema.tsx
+++ b/packages/react-openapi/src/OpenAPISchema.tsx
@@ -60,16 +60,6 @@ function OpenAPISchemaProperty(
const header = ;
const content = (() => {
- if (properties?.length) {
- return (
-
- );
- }
-
if (alternatives?.schemas) {
const { schemas, discriminator } = alternatives;
return (
@@ -94,6 +84,16 @@ function OpenAPISchemaProperty(
);
}
+ if (properties?.length) {
+ return (
+
+ );
+ }
+
return null;
})();