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. Named route captures must have required properties with matching names. |
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. |
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' => [
'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({ id: 42 }). Register referenced
schemas with kizlo_register_route_schema.