import { Table, Tag } from 'antd'; import type { ColumnsType } from 'antd/es/table'; import { methodColors, safeInlineHtml } from './endpoints.js'; import CodeBlock from './CodeBlock'; import './EndpointRow.css'; interface Param { name: string; in?: string; type?: string; desc?: string; } export interface Endpoint { method: string; path: string; summary?: string; params?: Param[]; body?: string; response?: string; errorResponse?: string; } const paramColumns: ColumnsType = [ { title: 'Name', dataIndex: 'name', key: 'name', width: 180 }, { title: 'In', dataIndex: 'in', key: 'in', width: 100 }, { title: 'Type', dataIndex: 'type', key: 'type', width: 120 }, { title: 'Description', dataIndex: 'desc', key: 'desc' }, ]; export default function EndpointRow({ endpoint }: { endpoint: Endpoint }) { const tagColor = (methodColors as Record)[endpoint.method] || 'default'; const hasParams = Array.isArray(endpoint.params) && endpoint.params.length > 0; return ( {endpoint.method} {endpoint.path} {endpoint.summary && ( )} {hasParams && ( Parameters )} {endpoint.body && ( Request body )} {endpoint.response && ( Response )} {endpoint.errorResponse && ( Error response )} ); }
{endpoint.path}