@devries-cameron20 / composio-1 / commits / 9e1d021eb
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

feat(docs): add full markdown support for API reference pages

- OpenAPI pages now return full operation details via .md endpoint (method, path, parameters, request body, responses) - Added PageActions (Copy, View markdown, Feedback) to API reference pages Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Jan 19, 2026 at 17:04 UTC 9e1d021eb47ea97252c6b9fe711d21732ad009d1
2 files changed +135
docs/app/(home)/reference/[[...slug]]/page.tsx
+1
@@ -34,6 +34,7 @@ export default async function Page({
34 return (
35 <DocsPage full tableOfContentPopover={{ enabled: false }}>
36 <h1 className="text-2xl font-semibold mb-4">{pageData.title}</h1>
37 + <PageActions path={page.url} />
38 <DocsBody>
39 <APIPage {...pageData.getAPIPageProps()} />
40 </DocsBody>
docs/app/llms.mdx/[[...slug]]/route.ts
+134
@@ -13,6 +13,127 @@ import type { Toolkit } from '@/types/toolkit';
13
14 export const revalidate = false;
15
16 +// OpenAPI spec cache
17 +let openapiSpecCache: Record<string, unknown> | null = null;
18 +
19 +async function getOpenAPISpec(): Promise<Record<string, unknown>> {
20 + if (openapiSpecCache) return openapiSpecCache;
21 + const filePath = join(process.cwd(), 'public/openapi.json');
22 + const data = await readFile(filePath, 'utf-8');
23 + const spec = JSON.parse(data) as Record<string, unknown>;
24 + openapiSpecCache = spec;
25 + return spec;
26 +}
27 +
28 +interface OpenAPIOperation {
29 + method: string;
30 + path: string;
31 + tags?: string[];
32 +}
33 +
34 +interface OpenAPIPageData {
35 + title: string;
36 + description?: string;
37 + getAPIPageProps: () => {
38 + document: string;
39 + operations?: OpenAPIOperation[];
40 + webhooks?: { name: string; method: string }[];
41 + };
42 +}
43 +
44 +// Convert OpenAPI page to markdown
45 +async function openapiPageToMarkdown(
46 + page: { url: string; data: OpenAPIPageData }
47 +): Promise<string> {
48 + const { title, description } = page.data;
49 + const props = page.data.getAPIPageProps();
50 + const spec = await getOpenAPISpec();
51 + const paths = spec.paths as Record<string, Record<string, unknown>> | undefined;
52 +
53 + const lines: string[] = [`# ${title} (${page.url})`, ''];
54 +
55 + if (description) {
56 + lines.push(description, '');
57 + }
58 +
59 + // Process operations
60 + if (props.operations && paths) {
61 + for (const op of props.operations) {
62 + const pathData = paths[op.path];
63 + if (!pathData) continue;
64 +
65 + const methodData = pathData[op.method] as Record<string, unknown> | undefined;
66 + if (!methodData) continue;
67 +
68 + lines.push(`## ${(op.method as string).toUpperCase()} ${op.path}`, '');
69 +
70 + if (methodData.summary) {
71 + lines.push(`${methodData.summary}`, '');
72 + }
73 +
74 + if (methodData.description) {
75 + lines.push(`${methodData.description}`, '');
76 + }
77 +
78 + // Parameters
79 + const parameters = methodData.parameters as Array<{
80 + name: string;
81 + in: string;
82 + description?: string;
83 + required?: boolean;
84 + schema?: { type?: string };
85 + }> | undefined;
86 +
87 + if (parameters && parameters.length > 0) {
88 + lines.push('### Parameters', '');
89 + lines.push('| Name | In | Required | Type | Description |');
90 + lines.push('|------|-----|----------|------|-------------|');
91 + for (const param of parameters) {
92 + const type = param.schema?.type || 'string';
93 + const required = param.required ? 'Yes' : 'No';
94 + const desc = (param.description || '').replace(/\|/g, '\\|').replace(/\n/g, ' ');
95 + lines.push(`| ${param.name} | ${param.in} | ${required} | ${type} | ${desc} |`);
96 + }
97 + lines.push('');
98 + }
99 +
100 + // Request body
101 + const requestBody = methodData.requestBody as {
102 + description?: string;
103 + required?: boolean;
104 + content?: Record<string, { schema?: unknown }>;
105 + } | undefined;
106 +
107 + if (requestBody?.content) {
108 + lines.push('### Request Body', '');
109 + if (requestBody.description) {
110 + lines.push(requestBody.description, '');
111 + }
112 + const contentTypes = Object.keys(requestBody.content);
113 + lines.push(`Content types: ${contentTypes.join(', ')}`, '');
114 + }
115 +
116 + // Responses
117 + const responses = methodData.responses as Record<string, {
118 + description?: string;
119 + }> | undefined;
120 +
121 + if (responses) {
122 + lines.push('### Responses', '');
123 + lines.push('| Status | Description |');
124 + lines.push('|--------|-------------|');
125 + for (const [status, response] of Object.entries(responses)) {
126 + const desc = (response.description || '').replace(/\|/g, '\\|').replace(/\n/g, ' ');
127 + lines.push(`| ${status} | ${desc} |`);
128 + }
129 + lines.push('');
130 + }
131 + }
132 + }
133 +
134 + return lines.join('\n').trim();
135 +}
136 +
137 // Map URL prefixes to their sources
138 const sources = [
139 { prefix: 'docs', source },
@@ -78,6 +199,19 @@ export async function GET(
199 const page = match.source.getPage(rest.length > 0 ? rest : undefined);
200
201 if (page) {
202 + // Check if this is an OpenAPI page
203 + if ('getAPIPageProps' in page.data) {
204 + const markdown = await openapiPageToMarkdown(
205 + page as { url: string; data: OpenAPIPageData }
206 + );
207 + return new Response(markdown, {
208 + headers: {
209 + 'Content-Type': 'text/markdown; charset=utf-8',
210 + },
211 + });
212 + }
213 +
214 + // Regular MDX page
215 try {
216 // eslint-disable-next-line @typescript-eslint/no-explicit-any
217 return new Response(await getLLMText(page as any), {