-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing Types and Incorrect Typings in openrpc.json
#3182
Comments
While I agree that certain types are wrong or missing, specifically the subscribe method is actually correct. It is an RPC call that returns a number, which is the subscription ID. This ID can be used to unsubscribe, and the actual subscription events are sent outside this call as "server-sent events", which contain the subscription ID in their body and are not documented anywhere unfortunately. |
The call used: |
I noticed an issue with the JSON-RPC documentation ( Additionally, the return types in the documentation seem incorrect in all cases. The correct return type should align with the following definition, but the documentation often only mentions pub type RPCResult<T, S, E> = Result<RPCData<T, S>, E>;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct RPCData<T, S> {
pub data: T,
pub metadata: S,
} It would be great to have the documentation and the autogenerated code updated to reflect the accurate return type and ensure the JavaScript code works correctly when copied and pasted. |
While working on creating TypeScript typings from the generated
openrpc.json
file, I noticed some issues:1. Missing Types
Certain types that are defined in the source code are missing from the
openrpc.json
. For example, the following type is not included:Type Definition
There may be other missing types as well.
2. Incorrect Typings for Subscribe Methods
The typings for all
subscribe
methods in theopenrpc.json
appear to be incorrect. For example:The result states it returns a number, but that is not what the stream actually sends.
Impact
These issues make it difficult to rely on the openrpc.json as a source of truth for interacting with the RPC server. Developers are forced to figure out the actual behavior themselves, which leads to a poor developer experience.
Proposed Improvements
Ensure all relevant types from the source code are included in the openrpc.json.
Correct the typings for the subscribe methods to accurately represent the structure and type of the data they return.
Thank you for addressing this issue!
The text was updated successfully, but these errors were encountered: