Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
feat(docs): add full markdown support for API reference pages
Sushmithamallesh9e1d021eb47e
diff --git a/docs/app/(home)/reference/[[...slug]]/page.tsx b/docs/app/(home)/reference/[[...slug]]/page.tsxindex a5cda0948..f031d503c 100644--- a/docs/app/(home)/reference/[[...slug]]/page.tsx+++ b/docs/app/(home)/reference/[[...slug]]/page.tsx@@ -34,6 +34,7 @@ export default async function Page({return (<DocsPage full tableOfContentPopover={{ enabled: false }}><h1 className="text-2xl font-semibold mb-4">{pageData.title}</h1>+ <PageActions path={page.url} /><DocsBody><APIPage {...pageData.getAPIPageProps()} /></DocsBody>diff --git a/docs/app/llms.mdx/[[...slug]]/route.ts b/docs/app/llms.mdx/[[...slug]]/route.tsindex c34bc7452..ddcff29d5 100644--- a/docs/app/llms.mdx/[[...slug]]/route.ts+++ b/docs/app/llms.mdx/[[...slug]]/route.ts@@ -13,6 +13,127 @@ import type { Toolkit } from '@/types/toolkit';export const revalidate = false;+// OpenAPI spec cache+let openapiSpecCache: Record<string, unknown> | null = null;++async function getOpenAPISpec(): Promise<Record<string, unknown>> {+ if (openapiSpecCache) return openapiSpecCache;+ const filePath = join(process.cwd(), 'public/openapi.json');+ const data = await readFile(filePath, 'utf-8');+ const spec = JSON.parse(data) as Record<string, unknown>;+ openapiSpecCache = spec;+ return spec;+}++interface OpenAPIOperation {+ method: string;+ path: string;+ tags?: string[];+}++interface OpenAPIPageData {+ title: string;+ description?: string;+ getAPIPageProps: () => {+ document: string;+ operations?: OpenAPIOperation[];+ webhooks?: { name: string; method: string }[];+ };+}++// Convert OpenAPI page to markdown+async function openapiPageToMarkdown(+ page: { url: string; data: OpenAPIPageData }+): Promise<string> {+ const { title, description } = page.data;+ const props = page.data.getAPIPageProps();+ const spec = await getOpenAPISpec();+ const paths = spec.paths as Record<string, Record<string, unknown>> | undefined;++ const lines: string[] = [`# ${title} (${page.url})`, ''];++ if (description) {+ lines.push(description, '');+ }++ // Process operations+ if (props.operations && paths) {+ for (const op of props.operations) {+ const pathData = paths[op.path];+ if (!pathData) continue;++ const methodData = pathData[op.method] as Record<string, unknown> | undefined;+ if (!methodData) continue;++ lines.push(`## ${(op.method as string).toUpperCase()} ${op.path}`, '');++ if (methodData.summary) {+ lines.push(`${methodData.summary}`, '');+ }++ if (methodData.description) {+ lines.push(`${methodData.description}`, '');+ }++ // Parameters+ const parameters = methodData.parameters as Array<{+ name: string;+ in: string;+ description?: string;+ required?: boolean;+ schema?: { type?: string };+ }> | undefined;++ if (parameters && parameters.length > 0) {+ lines.push('### Parameters', '');+ lines.push('| Name | In | Required | Type | Description |');+ lines.push('|------|-----|----------|------|-------------|');+ for (const param of parameters) {+ const type = param.schema?.type || 'string';+ const required = param.required ? 'Yes' : 'No';+ const desc = (param.description || '').replace(/\|/g, '\\|').replace(/\n/g, ' ');+ lines.push(`| ${param.name} | ${param.in} | ${required} | ${type} | ${desc} |`);+ }+ lines.push('');+ }++ // Request body+ const requestBody = methodData.requestBody as {+ description?: string;+ required?: boolean;+ content?: Record<string, { schema?: unknown }>;+ } | undefined;++ if (requestBody?.content) {+ lines.push('### Request Body', '');+ if (requestBody.description) {+ lines.push(requestBody.description, '');+ }+ const contentTypes = Object.keys(requestBody.content);+ lines.push(`Content types: ${contentTypes.join(', ')}`, '');+ }++ // Responses+ const responses = methodData.responses as Record<string, {+ description?: string;+ }> | undefined;++ if (responses) {+ lines.push('### Responses', '');+ lines.push('| Status | Description |');+ lines.push('|--------|-------------|');+ for (const [status, response] of Object.entries(responses)) {+ const desc = (response.description || '').replace(/\|/g, '\\|').replace(/\n/g, ' ');+ lines.push(`| ${status} | ${desc} |`);+ }+ lines.push('');+ }+ }+ }++ return lines.join('\n').trim();+}+// Map URL prefixes to their sourcesconst sources = [{ prefix: 'docs', source },@@ -78,6 +199,19 @@ export async function GET(const page = match.source.getPage(rest.length > 0 ? rest : undefined);if (page) {+ // Check if this is an OpenAPI page+ if ('getAPIPageProps' in page.data) {+ const markdown = await openapiPageToMarkdown(+ page as { url: string; data: OpenAPIPageData }+ );+ return new Response(markdown, {+ headers: {+ 'Content-Type': 'text/markdown; charset=utf-8',+ },+ });+ }++ // Regular MDX pagetry {// eslint-disable-next-line @typescript-eslint/no-explicit-anyreturn new Response(await getLLMText(page as any), {