Draft
Conversation
PM-6402: Create JSON schema for the Midnight node's RPC API Made-with: Cursor
Contributor
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.








Summary
Add a
rpc.discoverendpoint to the Midnight node that returns a complete, machine-readable OpenRPC document describing the entire JSON-RPC API — enabling automated client generation, API documentation, and compatibility testing.🎫 Ticket 📐 Engineering
Motivation
The Midnight node exposes 16 custom JSON-RPC methods and ~42 standard Substrate methods, but there is no machine-readable specification of the API. Developers must read Rust source code to understand available methods, parameter types, return types, and error codes. This blocks automated client library generation, makes API documentation manual and error-prone, and prevents compatibility testing between node versions.
Adding a standards-compliant
rpc.discoverendpoint (following OpenRPC v1.4.x / EIP-1901) makes the node self-describing. The node builds the OpenRPC document once at startup using runtime introspection of registered methods,schemars-generated JSON Schema for Rust types, and manually maintained metadata for partner-chains types that useserde_json::Value.Changes
Implementation (coming next):
MidnightApitrait (0% → 100% coverage)schemars = "0.8"dependency and deriveJsonSchemaon all RPC request/response typesnode/src/openrpc.rs— OpenRPC document builder with method metadata, type schemas, and error definitionsrpc.discoverendpoint increate_full()usingmodule.method_names()for drift-free method enumerationopenrpc.jsonfor offline access📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging