@appport/schema
v1.0.1
Published
Schema adapters and JSON Schema generation for AppPort capabilities.
Readme
@appport/schema
Schema adapters and JSON Schema generation for AppPort capabilities.
AppPort publishes JSON Schema on the wire so the manifest is consumable from TypeScript, Rust, Go, Python or Swift. In TypeScript you may author schemas three ways, and all three publish the same thing.
import { s, fromJSONSchema, fromStandardSchema, toSchema } from "@appport/schema";
// 1. the built-in builder: validation and JSON Schema from one definition
const input = s.object({ documentId: s.string(), title: s.optional(s.string()) });
// 2. any Standard Schema library (Zod, Valibot, ArkType)
const zodInput = fromStandardSchema(zodSchema, { jsonSchema: z.toJSONSchema(zodSchema) });
// 3. a raw JSON Schema document, validated at runtime
const published = fromJSONSchema({ type: "object", required: ["documentId"] });fromJSONSchema is what lets a generated client validate against a published
manifest without access to the original definitions — the same capability a
third-party implementation has.
The builder covers strings, numbers, integers, booleans, null, literals, enums, arrays, objects, records, unions, optionals, nullables, timestamps and binary references, with full type inference:
type Input = Infer<typeof input>; // { documentId: string; title?: string }