OpenRPC Support#2367
Open
stephenberry wants to merge 2 commits intomainfrom
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 descriptionregistry::open_rpc_spec()— generate the fullglz::open_rpcdocumentregistry::register_open_rpc()— register a/open_rpcendpoint 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_schemainfrastructure.Bug fix:
to_json_schemastack overflow on function pointersThe
to_json_schemanullable specialization inschema.hppused thenullable_tconcept, which matches raw function pointers (bool(t)and*tboth work). Dereferencing a function pointer yields a function reference,std::decayconverts it back to a function pointer, causing infinite template recursion. Fixed by using the existingnullable_likeconcept 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_metadatastructsinclude/glaze/rpc/registry.hpp— metadata capture duringon(),open_rpc_spec(),register_open_rpc()include/glaze/json/schema.hpp—nullable_t→nullable_likeinto_json_schemaspecializationdocs/rpc/openrpc.md(new) — documentationmkdocs.yml— added OpenRPC to navtests/networking_tests/openrpc_test/(new) — 8 test cases, 59 assertions