@@ -128,9 +128,12 @@ export async function Operation({
128128
129129 < Accordions type = "multiple" >
130130 { statuses . map ( ( status ) => (
131- < AccordionItem key = { status } value = { status } >
132- < ResponseAccordion status = { status } operation = { method } ctx = { ctx } />
133- </ AccordionItem >
131+ < ResponseAccordion
132+ key = { status }
133+ status = { status }
134+ operation = { method }
135+ ctx = { ctx }
136+ />
134137 ) ) }
135138 </ Accordions >
136139 </ >
@@ -329,29 +332,28 @@ async function ResponseAccordion({
329332 const response = operation . responses ! [ status ] ;
330333 const { generateTypeScriptSchema } = ctx ;
331334 const contentTypes = response . content ? Object . entries ( response . content ) : [ ] ;
335+ let wrapper = ( children : ReactNode ) => children ;
336+ let selectorNode : ReactNode = null ;
332337
333- if ( contentTypes . length === 0 ) {
334- return (
335- response . description && (
336- < div className = "prose-no-margin" >
337- { ctx . renderMarkdown ( response . description ) }
338- </ div >
339- )
338+ if ( contentTypes . length > 0 ) {
339+ const [ defaultValue ] = contentTypes [ 0 ] ;
340+ selectorNode =
341+ contentTypes . length === 1 ? (
342+ < p className = "text-sm text-fd-muted-foreground" > { defaultValue } </ p >
343+ ) : (
344+ < SelectTabTrigger items = { contentTypes . map ( ( [ key ] ) => key ) } />
345+ ) ;
346+ wrapper = ( children ) => (
347+ < SelectTabs defaultValue = { defaultValue } > { children } </ SelectTabs >
340348 ) ;
341349 }
342350
343- const [ defaultValue ] = contentTypes [ 0 ] ;
344- return (
345- < SelectTabs defaultValue = { defaultValue } >
351+ return wrapper (
352+ < AccordionItem value = { status } >
346353 < AccordionHeader >
347354 < AccordionTrigger className = "font-mono" > { status } </ AccordionTrigger >
348- { contentTypes . length > 1 ? (
349- < SelectTabTrigger items = { contentTypes . map ( ( [ key ] ) => key ) } />
350- ) : (
351- < p className = "text-sm text-fd-muted-foreground" > { defaultValue } </ p >
352- ) }
355+ { selectorNode }
353356 </ AccordionHeader >
354-
355357 < AccordionContent className = "ps-4.5" >
356358 { response . description && (
357359 < div className = "prose-no-margin" >
@@ -386,7 +388,7 @@ async function ResponseAccordion({
386388 ) ;
387389 } ) }
388390 </ AccordionContent >
389- </ SelectTabs >
391+ </ AccordionItem > ,
390392 ) ;
391393}
392394
0 commit comments