@devries-cameron20 / composio Mirror · read-only / commits / c5bc2dde4
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 22, 10:45 UTC

docs: polish API reference schema rendering

- Hide "Required" label on response fields (matches Stripe behavior) - Hide redundant content type labels (application/json) on accordions - Skip empty default values ({}, []) in info tags - Lighter styling for Default/Format info tags - Smaller expand/collapse buttons for child attributes - Reduce indentation for nested schemas - Fix anyOf primitive unions showing useless expandable sections - Handle nullable array types (e.g. nullable boolean) - Add enum values as compact inline badges - Remove unused useMemo import Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

Sushmithamallesh committed Feb 3, 2026 at 14:56 UTC c5bc2dde46654a8deb77871801c3301715fea14d
4 files changed +64 -32
docs/app/global.css
+5
@@ -488,6 +488,11 @@ div.flex.items-center:has(> span.font-mono.text-fd-primary > span.text-red-400)
488 color: #f87171;
489 }
490
491 +/* Hide redundant "application/json" content type labels */
492 +p.text-fd-muted-foreground.not-prose:has(> code.text-xs) {
493 + display: none;
494 +}
495 +
496 /* ==========================================================================
497 Table of Contents (Right Sidebar)
498 ========================================================================== */
docs/components/api-page.tsx
+2
@@ -19,12 +19,14 @@ export const APIPage = createAPIPage(openapi, {
19 schema: { getRawRef: ctx.schema.getRawRef },
20 }
21 );
22 + const isResponse = options.readOnly === true && !options.writeOnly;
23 return (
24 <CustomSchemaUI
25 name={options.client.name}
26 required={options.client.required}
27 as={options.client.as}
28 generated={generated}
29 + isResponse={isResponse}
30 />
31 );
32 },
docs/components/custom-schema-ui.tsx
+45 -22
@@ -4,7 +4,6 @@ import {
4 createContext,
5 Fragment,
6 use,
7 - useMemo,
7 useState,
8 type ReactNode,
9 } from 'react';
@@ -48,9 +47,11 @@ interface SchemaUIProps {
47 required?: boolean;
48 as?: 'property' | 'body';
49 generated: SchemaUIGeneratedData;
50 + isResponse?: boolean;
51 }
52
53 const DataContext = createContext<SchemaUIGeneratedData | null>(null);
54 +const ResponseContext = createContext(false);
55
56 function useData() {
57 const ctx = use(DataContext);
@@ -58,27 +59,34 @@ function useData() {
59 return ctx;
60 }
61
62 +function useIsResponse() {
63 + return use(ResponseContext);
64 +}
65 +
66 export function CustomSchemaUI({
67 name,
68 required = false,
69 as = 'property',
70 generated,
71 + isResponse = false,
72 }: SchemaUIProps) {
73 const schema = generated.refs[generated.$root];
68 - const isProperty = as === 'property' || !isExpandable(schema);
74 + const isProperty = as === 'property' || !isExpandable(schema, generated.refs);
75
76 return (
77 <DataContext value={generated}>
72 - {isProperty ? (
73 - <SchemaProperty
74 - name={name}
75 - $type={generated.$root}
76 - required={required}
77 - isRoot
78 - />
79 - ) : (
80 - <SchemaContent $type={generated.$root} />
81 - )}
78 + <ResponseContext value={isResponse}>
79 + {isProperty ? (
80 + <SchemaProperty
81 + name={name}
82 + $type={generated.$root}
83 + required={required}
84 + isRoot
85 + />
86 + ) : (
87 + <SchemaContent $type={generated.$root} />
88 + )}
89 + </ResponseContext>
90 </DataContext>
91 );
92 }
@@ -120,7 +128,7 @@ function SchemaContent({
128 {schema.items.map((item, i) => (
129 <div key={item.$type} className="pl-3 border-l-2 border-fd-border">
130 <span className="text-sm font-medium">{item.name}</span>
123 - {isExpandable(refs[item.$type]) && (
131 + {isExpandable(refs[item.$type], refs) && (
132 <ExpandableContent $type={item.$type} parentPath={parentPath} />
133 )}
134 </div>
@@ -146,10 +154,11 @@ function SchemaProperty({
154 isRoot?: boolean;
155 }) {
156 const { refs } = useData();
157 + const isResponse = useIsResponse();
158 const schema = refs[$type];
159 const fullPath = parentPath ? `${parentPath}.${name}` : name;
160
152 - const hasChildren = isExpandable(schema);
161 + const hasChildren = isExpandable(schema, refs);
162 const typeDisplay = getTypeDisplay(schema);
163
164 return (
@@ -162,7 +171,7 @@ function SchemaProperty({
171 <span className="text-sm font-mono text-fd-muted-foreground">
172 {typeDisplay}
173 </span>
165 - {required && (
174 + {required && !isResponse && (
175 <span className="text-xs text-red-400 font-medium">Required</span>
176 )}
177 {schema.deprecated && (
@@ -235,21 +244,21 @@ function ExpandableContent({
244
245 return (
246 <Collapsible open={isOpen} onOpenChange={setIsOpen} className="mt-3">
238 - <CollapsibleTrigger className="group flex items-center gap-2 px-3 py-2 text-sm font-medium rounded-lg border border-fd-border bg-fd-card hover:bg-fd-accent/50 transition-colors">
247 + <CollapsibleTrigger className="group flex items-center gap-1 px-2 py-1 text-xs text-fd-muted-foreground hover:text-fd-foreground font-medium rounded border border-fd-border hover:bg-fd-accent/30 transition-colors">
248 {isOpen ? (
249 <>
241 - <X className="h-4 w-4" />
250 + <X className="h-3 w-3" />
251 Hide {label}
252 </>
253 ) : (
254 <>
246 - <Plus className="h-4 w-4" />
255 + <Plus className="h-3 w-3" />
256 Show {childCount > 0 ? `${childCount} ` : ''}{label}
257 </>
258 )}
259 </CollapsibleTrigger>
260 <CollapsibleContent>
252 - <div className="mt-2 pl-4 border-l-2 border-fd-border">
261 + <div className="mt-2 pl-3 border-l border-fd-border">
262 <SchemaContent $type={$type} parentPath={parentPath} />
263 </div>
264 </CollapsibleContent>
@@ -257,10 +266,24 @@ function ExpandableContent({
266 );
267 }
268
260 -function isExpandable(schema: SchemaData): boolean {
269 +function isExpandable(schema: SchemaData, refs?: Record<string, SchemaData>): boolean {
270 if (schema.type === 'object' && schema.props.length > 0) return true;
262 - if (schema.type === 'array') return true;
263 - if ((schema.type === 'or' || schema.type === 'and') && schema.items.length > 0) return true;
271 + if (schema.type === 'array') {
272 + // Only expandable if items have structure (object/nested)
273 + if (!refs) return true;
274 + const itemSchema = refs[schema.item.$type];
275 + if (!itemSchema) return true;
276 + return itemSchema.type !== 'primitive';
277 + }
278 + if ((schema.type === 'or' || schema.type === 'and') && schema.items.length > 0) {
279 + // Only expandable if at least one variant has nested structure
280 + if (!refs) return true;
281 + return schema.items.some((item) => {
282 + const itemSchema = refs[item.$type];
283 + if (!itemSchema) return false;
284 + return isExpandable(itemSchema, refs);
285 + });
286 + }
287 return false;
288 }
289
docs/components/schema-generator.tsx
+12 -10
@@ -207,20 +207,22 @@ export function generateSchemaData(
207 const tags: ReactNode[] = [];
208
209 if (schema.default !== undefined) {
210 - tags.push(
211 - <div key="default" className="bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md">
212 - <span className="font-medium me-2">Default</span>
213 - <code className="text-fd-muted-foreground">{JSON.stringify(schema.default)}</code>
214 - </div>
215 - );
210 + const defaultStr = JSON.stringify(schema.default);
211 + // Skip empty objects/arrays as defaults - they're noise
212 + if (defaultStr !== '{}' && defaultStr !== '[]') {
213 + tags.push(
214 + <span key="default" className="text-xs text-fd-muted-foreground">
215 + Default: <code className="rounded border border-fd-border px-1 py-0.5 font-mono">{defaultStr}</code>
216 + </span>
217 + );
218 + }
219 }
220
221 if (schema.format) {
222 tags.push(
220 - <div key="format" className="bg-fd-secondary border rounded-lg text-xs p-1.5 shadow-md">
221 - <span className="font-medium me-2">Format</span>
222 - <code className="text-fd-muted-foreground">{schema.format}</code>
223 - </div>
223 + <span key="format" className="text-xs text-fd-muted-foreground">
224 + Format: <code className="rounded border border-fd-border px-1 py-0.5 font-mono">{schema.format}</code>
225 + </span>
226 );
227 }
228