Schema display
An API endpoint or a tool's input, readable: method and path, then parameters and bodies as a folding typed tree.
On this page
A create invoice endpoint: path and header parameters, a request body with nested lines, and the response.
Installation
Usage
import { SchemaDisplay } from "@/components/ui/chatcn/schema-display"
<SchemaDisplay
method="POST"
path="/v1/customers/{customer_id}/invoices"
parameters={parameters}
requestBody={jsonSchema}
responseBody={responseSchema}
/>Takes the JSON Schema subset that tool and API schemas use (type, properties, required, items, enum, format, default, nullable). Every field shows its type, format, whether it is required, the values it allows and its default; nested objects and arrays of objects fold, and defaultDepth sets how much opens on mount. Leave out method and path and pass title for a tool's input. Long paths wrap at slashes. Replaces AI Elements' SchemaDisplay.
Examples
States
A tool's input with no method, every level open, and an endpoint that returns nothing.
Props
| Prop | Type | Notes |
|---|---|---|
method, path | HttpMethod, string | Path parameters in braces are marked |
title | ReactNode | A tool name, when there is no method and path |
description | ReactNode | |
parameters | SchemaParameter[] | { name, in, required?, schema?, description? } |
requestBody, responseBody | SchemaNode | JSON Schema |
defaultDepth | number | Levels open on mount. Default 1 |
labels | Partial<SchemaDisplayLabels> | Every string, for translation |
Keyboard
| Key | Action |
|---|---|
| Enter or Space on a folded field | Open or close its fields |
Accessibility
- Folded fields are buttons that report whether they are open and point at their children.
- Required is a word, not only a color.
- The method color has the method's name beside it.