Fix an issue where a missing OpenAPI example would crash the page. (#2806)

This commit is contained in:
Steven H
2025-02-04 11:48:38 +00:00
committed by GitHub
parent e721f17f7e
commit fe8acc986e
2 changed files with 8 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@gitbook/react-openapi': minor
---
Fix an issue where a missing OpenAPI example would crash the page.
+3 -1
View File
@@ -53,7 +53,9 @@ export function OpenAPISchemaProperty(
typeof schema.example === 'number' ||
typeof schema.example === 'boolean' ||
(Array.isArray(schema.example) && schema.example.length > 0) ||
(typeof schema.example === 'object' && Object.keys(schema.example).length > 0)
(typeof schema.example === 'object' &&
schema.example !== null &&
Object.keys(schema.example).length > 0)
);
};
return (