open-rpc / server-js

JSON-RPC 2.0 Server implementation that supports multiple transport protocols.
Apache License 2.0
43 stars 11 forks source link

Wrong params mapping #746

Closed vh closed 2 years ago

vh commented 3 years ago

There is the following document:

{
  "openrpc": "1.2.4",
  "info": {
    "version": "1.0.0"
  },
  "methods": [
    {
      "name": "test",
      "paramStructure": "by-name",
      "params": [
        {
          "name": "param1",
          "required": false,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "param2",
          "required": false,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "param3",
          "required": false,
          "schema": {
            "type": "string"
          }
        }
      ],
      "result": {
        "name": "result",
        "schema": {
          "type": "string"
        }
      }
    }
  ]
}

Generated typing for such method is:

export type Test = (param1?: StringDoaGddGA, param2?: StringDoaGddGA, param3?: StringDoaGddGA) => Promise<StringDoaGddGA>;

All params are optional.

Trying to make a call like that:

{
    "jsonrpc": "2.0",
    "method": "test",
    "params": { "param2": "test" }
}

param1 is set instead of param2.

Params mapping will always be wrong in similar cases

openrpc-bastion commented 2 years ago

:tada: This issue has been resolved in version 1.9.2 :tada:

The release is available on:

Your semantic-release bot :package::rocket: