File tree 3 files changed +9
-4
lines changed
packages/react-openapi/src 3 files changed +9
-4
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @gitbook/react-openapi ' : patch
3
+ ---
4
+
5
+ Fix OpenAPI example display error
Original file line number Diff line number Diff line change @@ -217,7 +217,7 @@ function OpenAPISchemaPresentation(props: { property: OpenAPISchemaPropertyEntry
217
217
propertyName = { propertyName }
218
218
required = { required }
219
219
/>
220
- { schema [ 'x-deprecated-sunset' ] ? (
220
+ { typeof schema [ 'x-deprecated-sunset' ] === 'string' ? (
221
221
< div className = "openapi-deprecated-sunset openapi-schema-description openapi-markdown" >
222
222
Sunset date:{ ' ' }
223
223
< span className = "openapi-deprecated-sunset-date" >
@@ -228,7 +228,7 @@ function OpenAPISchemaPresentation(props: { property: OpenAPISchemaPropertyEntry
228
228
{ description ? (
229
229
< Markdown source = { description } className = "openapi-schema-description" />
230
230
) : null }
231
- { example ? (
231
+ { typeof example === 'string' ? (
232
232
< div className = "openapi-schema-example" >
233
233
Example: < code > { example } </ code >
234
234
</ div >
Original file line number Diff line number Diff line change @@ -51,12 +51,12 @@ export function extractDescriptions(object: AnyObject) {
51
51
/**
52
52
* Resolve the first example from an object.
53
53
*/
54
- export function resolveFirstExample ( object : AnyObject ) {
54
+ export function resolveFirstExample ( object : AnyObject ) : string | undefined {
55
55
if ( 'examples' in object && typeof object . examples === 'object' && object . examples ) {
56
56
const keys = Object . keys ( object . examples ) ;
57
57
const firstKey = keys [ 0 ] ;
58
58
if ( firstKey && object . examples [ firstKey ] ) {
59
- return object . examples [ firstKey ] ;
59
+ return formatExample ( object . examples [ firstKey ] ) ;
60
60
}
61
61
}
62
62
You can’t perform that action at this time.
0 commit comments