[Bug][OpenAPI] Operation page crashes when a response Example Object has no `value`
To Reproduce
{
"openapi": "3.0.0",
"info": { "title": "Repro", "version": "1.0.0" },
"paths": {
"/items": {
"get": {
"operationId": "listItems",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": { "type": "object" },
"examples": {
"Default": {},
"Populated": { "value": { "id": "1" } }
}
}
}
}
}
}
}
}
}Open the listItems page.
Current vs. Expected behavior
Current: The page crashes with TypeError: Cannot read properties of undefined (reading 'split'). React reports it from the <Placeholder> component in fumadocs-ui/dist/components/dynamic-codeblock.core.js.
Expected: The page renders. Every field on an Example Object is optional in OpenAPI 3.0 and 3.1, so {} is valid (an example can also use externalValue instead). The example could be skipped or shown as empty.
Framework
Tanstack Start
Provide environment information
Framework: TanStack Start 1.168.50 (@tanstack/react-router 1.170.33), Vite 8.2.2
Operating System:
Platform: win32
Binaries:
Node: 24.12.0
Relevant Packages:
fumadocs-core: 16.15.15
fumadocs-ui: 16.15.15
fumadocs-mdx: 15.4.0
fumadocs-openapi: 11.4.1
react: 19.2.8
react-dom: 19.2.8Which area(s) are affected? (Select all that apply)
Integrations (e.g OpenAPI, Typescript DocsGen), UI
Additional context
Observed on the versions above. The same code is in fumadocs-openapi 12.0.4 and on dev as of 1bc5374; source paths are relative to packages/ on that commit.
useResponseExamples(openapi/src/operation.tsx:451) pushessample: getRaw(example.value), which isundefinedwhen there's novalue.ResponseTabs(openapi/src/ui/operation/response-tabs.tsx:34) renders<ClientCodeBlock lang="json" code={JSON.stringify(example.sample, null, 2)} />.JSON.stringify(undefined)returnsundefined, not a string.- The default
CodeBlock(shared-api/src/components/defaults.tsx) isDynamicCodeBlock. While Shiki loads, it rendersPlaceholder(base-ui/src/components/dynamic-codeblock.core.tsx:81, same inradix-ui), which callscode.split('\n')and throws.
A guard at any of these points fixes it, for example skipping examples whose value is undefined in step 1. DynamicCodeBlock could also tolerate a non-string code. For now we work around it with a custom components.CodeBlock that returns null when code is undefined.
Source: fuma-nama/fumadocs