Composition
Compose provides static methods for deriving new schemas from existing ones. All methods return new schema objects - input schemas are never mutated. The TypeScript types are inferred at compile time; the output is valid JSON Schema at runtime.
Methods
| Method | Description |
|---|---|
extend | Add properties to a base schema |
pick / omit | Keep or remove specific properties |
partial / required | Make all properties optional or required |
intersection | Combine schemas with allOf |
equivalent | Declare two schemas as semantically equivalent (equivalentClass / equivalentProperty) |
discriminatedUnion / narrow | oneOf with type discriminator |
getDefaults | Extract declared default values |
All examples use the bookstore domain. Composed schemas build on each other - see Getting Started for the basics.
Related
register- register composed schemas before useinstantiate- coerce values through composed schemasmaterialize- fill defaults through composed schemas
See also
- Bookstore domain - base schemas used throughout composition examples
- Argument conventions - how composed schemas work as
SchemaRef - Graph-native authoring - when to extract vs compose