mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +00:00
Fix OpenAPI example not showing (#3930)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -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 { stateKey, items, selectIcon, context } = props;
|
||||||
const state = useMediaTypesState(stateKey, items[0]?.key);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user