Skip to content
Sign upPro
CodeSchema displayMenu

Schema display

An API endpoint or a tool's input, readable: method and path, then parameters and bodies as a folding typed tree.

A create invoice endpoint: path and header parameters, a request body with nested lines, and the response.

Installation

$ pnpm dlx shadcn@latest add https://chatcn.dev/r/schema-display.json

Usage

tsx
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

PropTypeNotes
method, pathHttpMethod, stringPath parameters in braces are marked
titleReactNodeA tool name, when there is no method and path
descriptionReactNode
parametersSchemaParameter[]{ name, in, required?, schema?, description? }
requestBody, responseBodySchemaNodeJSON Schema
defaultDepthnumberLevels open on mount. Default 1
labelsPartial<SchemaDisplayLabels>Every string, for translation

Keyboard

KeyAction
Enter or Space on a folded fieldOpen 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.