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

next
ts 34 lines 1.25 KB
Raw
1 import { z } from 'zod';
2
3 /**
4 * The `endpoints={[...]}` prop of `<ApiEndpointsTable />`.
5 *
6 * `scripts/generate-api-index.ts` serializes this array into MDX as a JSON
7 * string, so every reader — the React component, the `.md` converter in
8 * `lib/source.ts`, and the route guard in
9 * `tests/static/api-reference-routes.test.ts` — is reading external data and
10 * parses it here once, with `z.infer` flowing downstream.
11 *
12 * Deliberately non-strict: unknown keys are stripped rather than rejected, so
13 * adding a field to the generator does not break rendering on pages generated
14 * before the field existed.
15 */
16 export const apiEndpointSchema = z.object({
17 method: z.string(),
18 /** Path under the current prefix, e.g. `/api/v3.1/tools/{tool_slug}`. */
19 pathV31: z.string(),
20 /** Same operation under the previous prefix, e.g. `/api/v3/tools/{tool_slug}`. */
21 pathV3: z.string(),
22 summary: z.string(),
23 href: z.string(),
24 /**
25 * Set by the generator for operations flagged `deprecated` in the OpenAPI
26 * spec. Surfaced with the existing "Legacy" tag (see
27 * `components/legacy-badge.tsx`).
28 */
29 legacy: z.boolean().optional(),
30 });
31
32 export const apiEndpointsSchema = z.array(apiEndpointSchema);
33
34 export type ApiEndpoint = z.infer<typeof apiEndpointSchema>;