defineSchema utility provides type-safe schema definition for CallApi clients. It helps you create strongly-typed API schemas with routes and configuration that enable end-to-end type safety across your application.
Import
Signature
Parameters
Returns
Returns aBaseCallApiSchemaAndConfig object containing:
routes: The defined routes with deep writeable typesconfig: The schema configuration with deep writeable types
Usage
Basic Schema Definition
Schema with Configuration
Complete API Schema
Related Utilities
defineSchemaRoutes- Define only routes without configurationdefineSchemaConfig- Define only schema configurationdefineMainSchema- Define a complete schema with routes and config
defineSchemaRoutes
Defines only the routes portion of a schema:defineSchemaConfig
Defines only the schema configuration:defineMainSchema
Defines a complete schema with both routes and config already combined:defineBaseConfig
Helper for defining base configuration with type safety.Import
Usage
defineInstanceConfig
Helper for defining instance-level configuration with type safety.Import
Usage
Type Safety
ThedefineSchema utility provides deep type safety:
- Route keys are validated against your schema
- Request bodies are type-checked against body schemas
- Response data is automatically typed from response schemas
- URL parameters are inferred from route patterns
See Also
- Schema Validation - Learn about schema validation
- Configuration - Understanding CallApi’s configuration