@@ -7,6 +7,7 @@ import { OpenAPISpec } from './OpenAPISpec';
77import type { OpenAPIClientContext , OpenAPIContextProps , OpenAPIOperationData } from './types' ;
88import { OpenAPIPath } from './OpenAPIPath' ;
99import { resolveDescription } from './utils' ;
10+ import { OpenAPICustomOperationProperties , OpenAPIV3 } from '@gitbook/openapi-parser' ;
1011
1112/**
1213 * Display an interactive OpenAPI operation.
@@ -25,8 +26,6 @@ export function OpenAPIOperation(props: {
2526 blockKey : context . blockKey ,
2627 } ;
2728
28- const description = resolveDescription ( operation ) ;
29-
3029 return (
3130 < div className = { clsx ( 'openapi-operation' , className ) } >
3231 < div className = "openapi-summary" id = { operation . summary ? undefined : context . id } >
@@ -49,11 +48,7 @@ export function OpenAPIOperation(props: {
4948 { `.` }
5049 </ div >
5150 ) : 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 } />
5752 < OpenAPIPath data = { data } context = { context } />
5853 < OpenAPISpec data = { data } context = { clientContext } />
5954 </ div >
@@ -67,3 +62,30 @@ export function OpenAPIOperation(props: {
6762 </ div >
6863 ) ;
6964}
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