@@ -7,6 +7,7 @@ import { OpenAPISpec } from './OpenAPISpec';
7
7
import type { OpenAPIClientContext , OpenAPIContextProps , OpenAPIOperationData } from './types' ;
8
8
import { OpenAPIPath } from './OpenAPIPath' ;
9
9
import { resolveDescription } from './utils' ;
10
+ import { OpenAPICustomOperationProperties , OpenAPIV3 } from '@gitbook/openapi-parser' ;
10
11
11
12
/**
12
13
* Display an interactive OpenAPI operation.
@@ -25,8 +26,6 @@ export function OpenAPIOperation(props: {
25
26
blockKey : context . blockKey ,
26
27
} ;
27
28
28
- const description = resolveDescription ( operation ) ;
29
-
30
29
return (
31
30
< div className = { clsx ( 'openapi-operation' , className ) } >
32
31
< div className = "openapi-summary" id = { operation . summary ? undefined : context . id } >
@@ -49,11 +48,7 @@ export function OpenAPIOperation(props: {
49
48
{ `.` }
50
49
</ div >
51
50
) : null }
52
- { description ? (
53
- < div className = "openapi-intro" >
54
- < Markdown className = "openapi-description" source = { description } />
55
- </ div >
56
- ) : null }
51
+ < OpenAPIOperationDescription operation = { operation } context = { context } />
57
52
< OpenAPIPath data = { data } context = { context } />
58
53
< OpenAPISpec data = { data } context = { clientContext } />
59
54
</ div >
@@ -67,3 +62,30 @@ export function OpenAPIOperation(props: {
67
62
</ div >
68
63
) ;
69
64
}
65
+
66
+ function OpenAPIOperationDescription ( props : {
67
+ operation : OpenAPIV3 . OperationObject < OpenAPICustomOperationProperties > ;
68
+ context : OpenAPIContextProps ;
69
+ } ) {
70
+ const { operation } = props ;
71
+ if ( operation [ 'x-gitbook-description-document' ] ) {
72
+ return (
73
+ < div className = "openapi-intro" >
74
+ { props . context . renderDocument ( {
75
+ document : operation [ 'x-gitbook-description-document' ] ,
76
+ } ) }
77
+ </ div >
78
+ ) ;
79
+ }
80
+
81
+ const description = resolveDescription ( operation ) ;
82
+ if ( ! description ) {
83
+ return null ;
84
+ }
85
+
86
+ return (
87
+ < div className = "openapi-intro" >
88
+ < Markdown className = "openapi-description" source = { description } />
89
+ </ div >
90
+ ) ;
91
+ }
0 commit comments