OpenRPC Support
Generating OpenRPC specs
php bin/generate-docs.php --config=./config.php --format=openrpc --output=docs/openrpc.json
Produces an OpenRPC 1.3.2 compliant specification from your handlers.
Validation approach
The OpenRPC output is validated using:
- Formal schema validation: PHP tests validate generated output with a JSON Schema validator against the OpenRPC 1.3.2 fixture
- Pinned schema fixture: The official OpenRPC 1.3.2 JSON Schema is bundled in
tests/Fixtures/openrpc-schema-1.3.2.json - Property coverage tests: Verify required fields on method objects, content descriptors, error objects, and tag objects
Honest scope
The generator is validated against the bundled OpenRPC schema fixture in tests. It uses PHP-derived type information, descriptor metadata, and runtime request schemas from RpcSchemaProviderInterface when available, but it still does not attempt a full JSON Schema to OpenRPC translation layer.
- Top-level required fields (
openrpc,info,methods) - Info block structure
- Server entries
- Method object required fields (
name,params,result) - Content descriptor required fields (
name,schema) - Error object required fields (
code,message) - Schema-backed parameter constraints and the
x-jsonrpc-requestSchemaextension when runtime schemas are present - Extension fields (
x-requiresAuth)
The JSON Schema validator is a development dependency used in tests only. It is not required at runtime.
PHP type to JSON Schema mapping
| PHP Type | JSON Schema |
|---|---|
int | {"type":"integer"} |
float | {"type":"number"} |
bool | {"type":"boolean"} |
string | {"type":"string"} |
array | {"type":"array"} |
array<T> | {"type":"array","items":...} |
object | {"type":"object"} |
?T | {"oneOf":[{"type":"T"},{"type":"null"}]} |
mixed | {"description":"Any value"} |
void | {"type":"null"} |