Docs
Functions

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
ParameterTypeDescription
$derivecallableFactory that returns one flat route declaration.

Factory result

KeyTypeDescription
idstringAPI ID whose dot-separated segments become the client path.
operationstringLowercase snake_case name, such as list, retrieve, or bulk_delete. The generated method is camelized.
namespacestringRoute namespace, such as wc/v3.
routestringRoute path inside the namespace.
methodstringOne HTTP method. Arrays and the plural methods key are rejected.
inputarrayRequest schema. Named route captures must have required properties with matching names.
errorsstring[]Handler-specific WordPress error codes.
responsesarrayStatus-keyed response contracts.
summarystringOptional short operation summary.
descriptionstringOptional operation description.
deprecatedboolOptional 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

wp-content/plugins/acme-orders/routes.php
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.

On this page