Fix OpenAPI example not showing (#3930)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Greg Bergé
2026-01-22 12:11:55 +01:00
committed by GitHub
parent f647af2003
commit 4e2d86318e
2 changed files with 13 additions and 2 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@gitbook/react-openapi": patch
---
Fix OpenAPI example not showing
@@ -31,9 +31,15 @@ export function OpenAPIMediaTypeContent(props: {
const { stateKey, items, selectIcon, context } = props;
const state = useMediaTypesState(stateKey, items[0]?.key);
const examples = items.find((item) => item.key === state.key)?.examples ?? [];
const item = items.find((item) => item.key === state.key) ?? items[0];
if (!items.length && !examples.length) {
if (!item) {
return null;
}
const examples = item.examples;
if (!examples || !examples.length) {
return null;
}