mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-16 15:45:13 +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-example,
|
||||||
.openapi-schema-pattern {
|
.openapi-schema-pattern {
|
||||||
@apply prose-sm mt-2 text-tint-strong;
|
@apply prose-sm mt-1 text-tint-strong;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Authentication */
|
/** Authentication */
|
||||||
|
|||||||
@@ -51,7 +51,9 @@ export function OpenAPISchemaProperty(
|
|||||||
return (
|
return (
|
||||||
typeof schema.example === 'string' ||
|
typeof schema.example === 'string' ||
|
||||||
typeof schema.example === 'number' ||
|
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 (
|
return (
|
||||||
@@ -100,9 +102,9 @@ export function OpenAPISchemaProperty(
|
|||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
{shouldDisplayExample(schema) ? (
|
{shouldDisplayExample(schema) ? (
|
||||||
<span className="openapi-schema-example">
|
<div className="openapi-schema-example">
|
||||||
Example: <code>{stringifyOpenAPI(schema.example)}</code>
|
Example: <code>{stringifyOpenAPI(schema.example)}</code>
|
||||||
</span>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
{schema.pattern ? (
|
{schema.pattern ? (
|
||||||
<div className="openapi-schema-pattern">
|
<div className="openapi-schema-pattern">
|
||||||
|
|||||||
Reference in New Issue
Block a user