Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 08:15 UTC
docs: add OpenAPI API reference pages to search index
Switch search indexes from sync array to async function so OpenAPI-generated API reference pages can be loaded via openapiSource(). Fix readonly type error from `as const` on structuredData empty arrays. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sushmithamallesh committed
Feb 18, 2026 at 18:21 UTC
af340f0969ac47904a2f627271620b03514d8c75
1 file changed
+39
-28
docs/app/api/search/route.ts
+39
-28
@@ -1,8 +1,10 @@
1
// Use direct imports from collections to avoid top-level await in lib/source.ts
2
import { docs, reference, cookbooks, toolkits, changelog } from 'fumadocs-mdx:collections/server';
3
import { createSearchAPI } from 'fumadocs-core/search/server';
4
-import { loader } from 'fumadocs-core/source';
4
+import { loader, multiple } from 'fumadocs-core/source';
5
import { lucideIconsPlugin } from 'fumadocs-core/source/lucide-icons';
6
+import { openapiSource, openapiPlugin } from 'fumadocs-openapi/server';
7
+import { openapi } from '@/lib/openapi';
8
import { getAllToolkitsSync } from '@/lib/toolkit-data';
9
10
// Create loaders directly here to avoid the problematic lib/source.ts import
@@ -24,30 +26,7 @@ const toolkitsSource = loader({
26
plugins: [lucideIconsPlugin()],
27
});
28
27
-// Sync reference source (MDX pages only — SDK reference, errors, rate-limits, etc.)
28
-// OpenAPI-generated API reference pages require async loading and can't be indexed here
29
-const referenceSource = loader({
30
- baseUrl: '/reference',
31
- source: reference.toFumadocsSource(),
32
- plugins: [lucideIconsPlugin()],
33
-});
34
-
35
-// MDX pages from Fumadocs sources
36
-const mdxIndexes = [
37
- ...docsSource.getPages(),
38
- ...cookbooksSource.getPages(),
39
- ...toolkitsSource.getPages(),
40
- ...referenceSource.getPages(),
41
-].map((page) => ({
42
- id: page.url,
43
- title: page.data.title ?? 'Untitled',
44
- description: page.data.description,
45
- url: page.url,
46
- structuredData: page.data.structuredData,
47
- keywords: 'keywords' in page.data ? page.data.keywords : undefined,
48
-}));
49
-
50
-// Dynamic toolkit pages from toolkits.json
29
+// Dynamic toolkit entries from toolkits.json
30
const mdxToolkitSlugs = new Set(
31
toolkitsSource.getPages().map((page) => page.slugs.join('/')),
32
);
@@ -59,7 +38,7 @@ const dynamicToolkitIndexes = getAllToolkitsSync()
38
title: toolkit.name,
39
description: toolkit.description,
40
url: `/toolkits/${toolkit.slug}`,
62
- structuredData: { headings: [], contents: [] },
41
+ structuredData: { headings: [] as never[], contents: [] as never[] },
42
keywords: [toolkit.slug, toolkit.category].filter(Boolean) as string[],
43
}));
44
@@ -69,10 +48,42 @@ const changelogIndexes = changelog.map((entry) => ({
48
title: entry.title,
49
description: entry.description ?? '',
50
url: `/docs/changelog/${entry.date.replace(/-/g, '/')}`,
72
- structuredData: { headings: [], contents: [] },
51
+ structuredData: { headings: [] as never[], contents: [] as never[] },
52
keywords: ['changelog'],
53
}));
54
55
+// Use dynamic indexes to support async OpenAPI page loading
56
export const { GET } = createSearchAPI('advanced', {
77
- indexes: [...mdxIndexes, ...dynamicToolkitIndexes, ...changelogIndexes],
57
+ indexes: async () => {
58
+ // Load OpenAPI pages and build full reference source
59
+ const openapiPages = await openapiSource(openapi, {
60
+ groupBy: 'tag',
61
+ baseDir: 'api-reference',
62
+ });
63
+
64
+ const fullReferenceSource = loader({
65
+ baseUrl: '/reference',
66
+ source: multiple({
67
+ mdx: reference.toFumadocsSource(),
68
+ openapi: openapiPages,
69
+ }),
70
+ plugins: [lucideIconsPlugin(), openapiPlugin()],
71
+ });
72
+
73
+ const mdxIndexes = [
74
+ ...docsSource.getPages(),
75
+ ...cookbooksSource.getPages(),
76
+ ...toolkitsSource.getPages(),
77
+ ...fullReferenceSource.getPages(),
78
+ ].map((page) => ({
79
+ id: page.url,
80
+ title: page.data.title ?? 'Untitled',
81
+ description: page.data.description,
82
+ url: page.url,
83
+ structuredData: page.data.structuredData,
84
+ keywords: 'keywords' in page.data ? (page.data.keywords as string[]) : undefined,
85
+ }));
86
+
87
+ return [...mdxIndexes, ...dynamicToolkitIndexes, ...changelogIndexes];
88
+ },
89
});