import type { ReactNode } from "react"; export function openApiDocumentUrl(apiBase: string, origin: string): string { return new URL(`${apiBase.replace(/\/+$/, "")}/external/openapi.json`, origin).href; } export function openApiTypesCommand(documentUrl: string): string { return `curl -fsS -H "Authorization: Bearer $LOOPABLE_API_KEY" ${documentUrl} | npx openapi-typescript -o loopable.d.ts`; } type Props = { documentUrl: string; renderCode: (value: string, name: string, content?: ReactNode) => ReactNode; }; export function KeyOpenApiRow({ documentUrl, renderCode }: Props) { return (
OpenAPI
Document {renderCode(documentUrl, "document", {documentUrl})}
Generate types {renderCode(openApiTypesCommand(documentUrl), "command")}
); }