Functions
kizlo_translate_spec_schema
Translate one WordPress-style schema into the Kizlo contract vocabulary.
kizlo_translate_spec_schema converts one schema when a property map is the wrong input shape. Use it for a
response body, an array item, or a nested schema obtained on its own.
Parameters
kizlo_translate_spec_schema(mixed $schema): ?array| Parameter | Type | Description |
|---|---|---|
$schema | mixed | One WordPress-style schema. |
It applies the same type normalization and cleanup as
kizlo_translate_spec_properties.
Returns
The translated schema, or null when the input cannot be expressed honestly in the contract.
Example
kizlo_register_route_spec(function () use ($controller): array {
$body = kizlo_translate_spec_schema([
'type' => 'array',
'items' => $controller->get_item_schema(),
]);
if ($body === null) {
throw new UnexpectedValueException('The reports schema could not be translated.');
}
return [
'id' => 'acme.reports',
'operation' => 'list',
'namespace' => 'acme/v1',
'route' => '/reports',
'method' => 'GET',
'responses' => ['200' => ['body' => $body]],
];
});