kizlo_register_route_schema
Lazily register a reusable schema for described WordPress routes.
kizlo_register_route_schema adds a named schema to Kizlo's introspection document. Reference it from route
inputs and responses to define a shared shape once.
Parameters
kizlo_register_route_schema(string $id, callable $derive): void| Parameter | Type | Description |
|---|---|---|
$id | string | Globally unique, vendor-qualified ID such as acme.order. |
$derive | callable | Factory that returns a schema written in Kizlo's contract vocabulary. |
Kizlo calls the factory when introspection builds the document. It can also call the factory when a registered runtime route references the schema from its input, because WordPress needs that shape for request validation.
The kizlo.*, post-types.*, and taxonomies.* prefixes are reserved for Kizlo core. A third-party plugin
must use its own vendor or domain prefix.
Write '$ref' and '$extends' with single quotes. PHP interpolates these keys inside double-quoted strings.
Returns
void. The schema appears under schemas in GET /kizlo/v1/introspect after validation.
Example
kizlo_register_route_schema('acme.order', fn(): array => [
'type' => 'object',
'properties' => [
'id' => ['type' => 'integer', 'required' => true],
'status' => [
'type' => 'string',
'required' => true,
'enum' => ['pending', 'complete'],
],
],
]);Use ['$ref' => 'acme.order'] in a
kizlo_register_route_spec response.