OpenRPC Support
Generating OpenRPC specs
php bin/generate-docs.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:
- Structural validation: PHP tests verify required fields, correct types, and valid structure against the OpenRPC 1.3.2 schema definitions
- 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 validation is structural, not formal. It checks:
- 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) - Extension fields (
x-requiresAuth)
It does not validate against the full JSON Schema meta-schema using a machine validator. Full formal validation against the official JSON Schema would require a complete JSON Schema validator library, which this project intentionally avoids as a runtime dependency.
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"} |