File tree Expand file tree Collapse file tree 3 files changed +9
-4
lines changed
packages/react-openapi/src Expand file tree Collapse file tree 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
217217 propertyName = { propertyName }
218218 required = { required }
219219 />
220- { schema [ 'x-deprecated-sunset' ] ? (
220+ { typeof schema [ 'x-deprecated-sunset' ] === 'string' ? (
221221 < div className = "openapi-deprecated-sunset openapi-schema-description openapi-markdown" >
222222 Sunset date:{ ' ' }
223223 < span className = "openapi-deprecated-sunset-date" >
@@ -228,7 +228,7 @@ function OpenAPISchemaPresentation(props: { property: OpenAPISchemaPropertyEntry
228228 { description ? (
229229 < Markdown source = { description } className = "openapi-schema-description" />
230230 ) : null }
231- { example ? (
231+ { typeof example === 'string' ? (
232232 < div className = "openapi-schema-example" >
233233 Example: < code > { example } </ code >
234234 </ div >
Original file line number Diff line number Diff line change @@ -51,12 +51,12 @@ export function extractDescriptions(object: AnyObject) {
5151/**
5252 * Resolve the first example from an object.
5353 */
54- export function resolveFirstExample ( object : AnyObject ) {
54+ export function resolveFirstExample ( object : AnyObject ) : string | undefined {
5555 if ( 'examples' in object && typeof object . examples === 'object' && object . examples ) {
5656 const keys = Object . keys ( object . examples ) ;
5757 const firstKey = keys [ 0 ] ;
5858 if ( firstKey && object . examples [ firstKey ] ) {
59- return object . examples [ firstKey ] ;
59+ return formatExample ( object . examples [ firstKey ] ) ;
6060 }
6161 }
6262
You can’t perform that action at this time.
0 commit comments