kizlo_register_route_spec
Lazily describe an existing WordPress route without registering or calling it.
kizlo_register_route_spec adds a core or third-party route to Kizlo's introspection document. Use it when
another plugin owns the endpoint and your generated introspection still needs its input, result, and errors.
Pass a factory so deriving the upstream controller and its schemas only happens when introspection builds the document. The function registers no route, makes no request, and does not verify that the endpoint exists.
Parameters
kizlo_register_route_spec(callable $derive): void| Parameter | Type | Description |
|---|---|---|
$derive | callable | Factory that returns one flat route declaration. |
Factory result
| Key | Type | Description |
|---|---|---|
id | string | API ID whose dot-separated segments become the client path. |
operation | string | Lowercase snake_case name, such as list, retrieve, or bulk_delete. The generated method is camelized. |
namespace | string | Route namespace, such as wc/v3. |
route | string | Route path inside the namespace. |
method | string | One HTTP method. Arrays and the plural methods key are rejected. |
input | array | Request schema, in the parts below. |
errors | string[] | Handler-specific WordPress error codes. |
responses | array | Status-keyed response contracts. |
summary | string | Optional short operation summary. |
description | string | Optional operation description. |
deprecated | bool | Optional deprecation marker. |
Input parts
input describes the request in the three parts it is made of. Declare only the parts the route has.
| Key | Type | Description |
|---|---|---|
params | array | Object schema for the route's path captures. Every named capture needs a required property with a matching name. |
query | array | Object schema for the query string. A body method may declare one too. |
body | array | Schema for the request payload, on POST, PUT, and PATCH. Any supported schema, including an array. Carries its own content_type, defaulting to application/json. |
A flat object schema is still accepted, and is read as the parts it was always describing: the path captures
become params, and the rest becomes the body on a body method and the query otherwise. Routes registered
that way keep working unchanged. Use the parts when you need something the flat shape cannot say, such as a
body that is not an object.
Runtime keys such as callback, permission_callback, args, sanitize_callback, and
validate_callback are rejected because this function describes an endpoint rather than serving it. Keep the
declaration aligned with the plugin version your integration supports.
Returns
void. The operation appears in GET /kizlo/v1/introspect and in the generated introspection after the
factory result passes contract validation.
Example
kizlo_register_route_spec(fn(): array => [
'id' => 'acme.orders',
'operation' => 'retrieve',
'namespace' => 'acme/v1',
'route' => '/orders/(?P<id>\\d+)',
'method' => 'GET',
'input' => [
'params' => [
'type' => 'object',
'properties' => [
'id' => ['type' => 'integer', 'required' => true],
],
],
],
'errors' => ['acme_order_not_found'],
'responses' => [
'200' => ['body' => ['$ref' => 'acme.order']],
'404' => ['body' => ['$ref' => 'kizlo.error']],
],
]);After kizlo generate, call it as context.wordpress.acme.orders.retrieve({ params: { id: 42 } }). Register referenced
schemas with kizlo_register_route_schema.