Skip to content

task: Node JSON Schema [PM-6402]#869

Draft
m2ux wants to merge 2 commits intomainfrom
task/PM-6402-node-json-schema
Draft

task: Node JSON Schema [PM-6402]#869
m2ux wants to merge 2 commits intomainfrom
task/PM-6402-node-json-schema

Conversation

@m2ux
Copy link
Contributor

@m2ux m2ux commented Mar 5, 2026

Summary

Add a rpc.discover endpoint 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.discover endpoint (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 use serde_json::Value.


Changes

Implementation (coming next):

  • Add doc comments to MidnightApi trait (0% → 100% coverage)
  • Add schemars = "0.8" dependency and derive JsonSchema on all RPC request/response types
  • Create node/src/openrpc.rs — OpenRPC document builder with method metadata, type schemas, and error definitions
  • Register rpc.discover endpoint in create_full() using module.method_names() for drift-free method enumeration
  • Add CI validation comparing OpenRPC method inventory against actual registered methods
  • Commit static openrpc.json for offline access

📌 Submission Checklist

  • Changes are backward-compatible (or flagged if breaking)
  • Pull request description explains why the change is needed
  • Self-reviewed the diff
  • I have included a change file, or skipped for this reason: [reason]
  • If the changes introduce a new feature, I have bumped the node minor version
  • Update documentation (if relevant)
  • No new todos introduced

🔱 Fork Strategy

  • Node Runtime Update
  • Node Client Update
  • Other
  • N/A

🗹 TODO before merging

  • Ready for review

PM-6402: Create JSON schema for the Midnight node's RPC API
Made-with: Cursor
@m2ux m2ux self-assigned this Mar 5, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 5, 2026

kics-logo

KICS version: v2.1.19

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 47
LOW LOW 3
INFO INFO 59
TRACE TRACE 0
TOTAL TOTAL 109
Metric Values
Files scanned placeholder 26
Files parsed placeholder 26
Files failed to scan placeholder 0
Total executed queries placeholder 73
Queries failed to execute placeholder 0
Execution time placeholder 11

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