mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-12 05:48:57 +00:00
Support non primitive examples in OpenAPI block (#2775)
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@gitbook/react-openapi': patch
|
||||
---
|
||||
|
||||
Support non primitive examples in OpenAPI block
|
||||
@@ -176,7 +176,7 @@
|
||||
|
||||
.openapi-schema-example,
|
||||
.openapi-schema-pattern {
|
||||
@apply prose-sm mt-2 text-tint-strong;
|
||||
@apply prose-sm mt-1 text-tint-strong;
|
||||
}
|
||||
|
||||
/** Authentication */
|
||||
|
||||
@@ -51,7 +51,9 @@ export function OpenAPISchemaProperty(
|
||||
return (
|
||||
typeof schema.example === 'string' ||
|
||||
typeof schema.example === 'number' ||
|
||||
typeof schema.example === 'boolean'
|
||||
typeof schema.example === 'boolean' ||
|
||||
(Array.isArray(schema.example) && schema.example.length > 0) ||
|
||||
(typeof schema.example === 'object' && Object.keys(schema.example).length > 0)
|
||||
);
|
||||
};
|
||||
return (
|
||||
@@ -100,9 +102,9 @@ export function OpenAPISchemaProperty(
|
||||
/>
|
||||
) : null}
|
||||
{shouldDisplayExample(schema) ? (
|
||||
<span className="openapi-schema-example">
|
||||
<div className="openapi-schema-example">
|
||||
Example: <code>{stringifyOpenAPI(schema.example)}</code>
|
||||
</span>
|
||||
</div>
|
||||
) : null}
|
||||
{schema.pattern ? (
|
||||
<div className="openapi-schema-pattern">
|
||||
|
||||
Reference in New Issue
Block a user