JSON-RPC schema specification?
Asked Answered
F

2

6

I'm thinking about trying to implementing a client for a particular json-rpc 2.0 service that could give a user some static typing guarantees. The API in question is very large, so actually writing a full-featured client by hand with all the necessary type information too big of a task for me to be bothered. However I've found via an undocumented http endpoint a large json based schema that seems to describe the entire json-rpc service fully. I'm certain I could write some sort of code generator using this specification. It is too big to paste here.

My question is, is there a standard specification for describing a json-rpc service? I've had a search around and I find a lot of dead links and the official spec[1] for json-rpc makes no mention of a standard schema definition for such a service. The schema I've found seems to be at least partially based off of the json-schema specification[2].

json-rpc

Json Schema

Frasco answered 12/1, 2019 at 21:32 Comment(0)
T
4

JSON Schema is great for defining payloads formats (you can even use it for REST APIs in OpenAPI) but indeed it won't help describe the "RPC" part, with the methods and entry points.

OpenRPC, created in early 2019, seems to be the most promising

The Ethereum Classic Labs Core (ECLC) team recently created the OpenRPC Specification, aiming to improve all blockchain dapp development. The specification emulates OpenAPI, the successful and widely adopted specification for REST APIs.

The OpenRPC Specification defines a standard, programming language-agnostic interface description for JSON-RPC 2.0 APIs.

Other approaches

Drupal JSON-RPC module provides a discovery endpoint and a Postman collection

The available RPC services along with documentation and usage details can be discovered by sending an HTTP GET request to /jsonrpc/methods.

You can use this Postman Collection with examples and tests.

There might also be interesting things to get from AsyncAPI, gRPC, GraphQL.

Dead

Also citing some other options I stumbled upon but which are dead:

JSON-WSP seems outdated, the Wikipedia page is pending deletion (talk page seems to say this was never actually a standard)

JSON-WSP (JavaScript Object Notation Web-Service Protocol) is a web-service protocol that uses JSON for service description, requests and responses. It is inspired from JSON-RPC, but the lack of a service description specification with documentation in JSON-RPC sparked the design of JSON-WSP.

JSON Schema Service Descriptor seems to have remained a draft

A JSON Schema service descriptor is simply a JSON Schema with the additional definition for methods.

Tegument answered 11/4, 2020 at 6:58 Comment(1)
You can take a look at WebRPC github.com/webrpc. It doesnt follow JSON-RPC specification, but its simple to use.Striated
C
-1

A bit late but is this what you are looking for? https://github.com/open-rpc/meta-schema/blob/master/schema.json

Crevice answered 29/12, 2022 at 14:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.