| 55 | }; |
| 56 | |
| 57 | export const SchemaDisplay = ({ |
| 58 | method, |
| 59 | path, |
| 60 | description, |
| 61 | parameters, |
| 62 | requestBody, |
| 63 | responseBody, |
| 64 | className, |
| 65 | children, |
| 66 | ...props |
| 67 | }: SchemaDisplayProps) => { |
| 68 | const contextValue = useMemo( |
| 69 | () => ({ |
| 70 | description, |
| 71 | method, |
| 72 | parameters, |
| 73 | path, |
| 74 | requestBody, |
| 75 | responseBody, |
| 76 | }), |
| 77 | [description, method, parameters, path, requestBody, responseBody] |
| 78 | ); |
| 79 | |
| 80 | return ( |
| 81 | <SchemaDisplayContext.Provider value={contextValue}> |
| 82 | <div |
| 83 | className={cn( |
| 84 | "overflow-hidden rounded-lg border bg-background", |
| 85 | className |
| 86 | )} |
| 87 | {...props} |
| 88 | > |
| 89 | {children ?? ( |
| 90 | <> |
| 91 | <SchemaDisplayHeader> |
| 92 | <div className="flex items-center gap-3"> |
| 93 | <SchemaDisplayMethod /> |
| 94 | <SchemaDisplayPath /> |
| 95 | </div> |
| 96 | </SchemaDisplayHeader> |
| 97 | {description && <SchemaDisplayDescription />} |
| 98 | <SchemaDisplayContent> |
| 99 | {parameters && parameters.length > 0 && ( |
| 100 | <SchemaDisplayParameters /> |
| 101 | )} |
| 102 | {requestBody && requestBody.length > 0 && ( |
| 103 | <SchemaDisplayRequest /> |
| 104 | )} |
| 105 | {responseBody && responseBody.length > 0 && ( |
| 106 | <SchemaDisplayResponse /> |
| 107 | )} |
| 108 | </SchemaDisplayContent> |
| 109 | </> |
| 110 | )} |
| 111 | </div> |
| 112 | </SchemaDisplayContext.Provider> |
| 113 | ); |
| 114 | }; |