Skip to content

OpenRPC Support#2367

Open
stephenberry wants to merge 2 commits intomainfrom
OpenRPC
Open

OpenRPC Support#2367
stephenberry wants to merge 2 commits intomainfrom
OpenRPC

Conversation

@stephenberry
Copy link
Copy Markdown
Owner

@stephenberry stephenberry commented Mar 13, 2026

Add OpenRPC specification support for the registry

Adds the ability to generate OpenRPC 1.3.2 specification documents from a glz::registry, enabling machine-readable API discovery for REPE and JSON-RPC services.

New API

  • registry::open_rpc_info — set API title, version, and description
  • registry::open_rpc_spec() — generate the full glz::open_rpc document
  • registry::register_open_rpc() — register a /open_rpc endpoint that serves the spec (works with both REPE and JSON-RPC protocols)

All registered endpoints (variables, functions, member functions, objects, root) are included as methods with JSON Schema descriptions for their parameters and return types, generated via the existing write_json_schema infrastructure.

Bug fix: to_json_schema stack overflow on function pointers

The to_json_schema nullable specialization in schema.hpp used the nullable_t concept, which matches raw function pointers (bool(t) and *t both work). Dereferencing a function pointer yields a function reference, std::decay converts it back to a function pointer, causing infinite template recursion. Fixed by using the existing nullable_like concept which already excludes function pointers via !is_function_ptr_or_ref<T>.

Files changed

  • include/glaze/rpc/openrpc.hpp (new) — open_rpc, openrpc_info, openrpc_method, openrpc_content_descriptor, method_metadata structs
  • include/glaze/rpc/registry.hpp — metadata capture during on(), open_rpc_spec(), register_open_rpc()
  • include/glaze/json/schema.hppnullable_tnullable_like in to_json_schema specialization
  • docs/rpc/openrpc.md (new) — documentation
  • mkdocs.yml — added OpenRPC to nav
  • tests/networking_tests/openrpc_test/ (new) — 8 test cases, 59 assertions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant