'use client'; import React from 'react'; import { MarkdownMessage } from '../../../../code/MarkdownMessage'; import type { ApiEndpoint, OpenApiInfo, OpenApiSchema } from '../../types'; import { SchemaCopyMenu } from './SchemaCopyMenu'; interface ApiIntroSectionProps { info: OpenApiInfo; schema: OpenApiSchema | null; endpoints: ApiEndpoint[]; resolvedBaseUrl?: string; } interface BaseUrlRow { url: string; description?: string; } export function ApiIntroSection({ info, schema, endpoints, resolvedBaseUrl }: ApiIntroSectionProps) { // Prefer the *resolved* base URL whenever we have one — that's the // URL actual requests target, not the raw ``servers[0].url`` from // the spec (which can be a bare path like ``/api/v3``). Fall back // to the spec's ``servers`` list so specs that document multiple // servers keep showing all of them. const baseUrlRows: BaseUrlRow[] = resolvedBaseUrl ? [{ url: resolvedBaseUrl, description: info.servers?.[0]?.description }] : (info.servers ?? []).map((s) => ({ url: s.url, description: s.description })); return (

{info.title}

v{info.version}
{info.description && (
)} {baseUrlRows.length > 0 && (

Base URL

{baseUrlRows.map((row, i) => (
{row.url} {row.description && ( {row.description} )}
))}
)}
); }