open-rpc / spec

The OpenRPC specification
https://spec.open-rpc.org
Apache License 2.0
166 stars 49 forks source link

Creating constraints between parameters #381

Open BelfordZ opened 1 year ago

BelfordZ commented 1 year ago

We should have a way to support 1 param determining the type of another param.

ie assume I have the following api:

name:  "bar",
params: [
   {
      name: 'foo' , 
      schema: { enum: [1,2 } }
  },
  { 
    name: 'baz',
    schema: {
      oneOf: [
        { type: 'string' },
        { type: 'number' }
      ]
    }
  }
]

If my api is such that when the param foo is 1, I need the param baz to be string, there is no way to represent that constraint at the moment.

This issue is to come up with ideas and discuss ways this can be solved

s1na commented 8 months ago

Supporting these constraints would solve an issue for us. Most Ethereum clients have support a subscription API described here. But we can't add the underlying methods to the specs because of this lack of expressivity: https://github.com/ethereum/execution-apis/issues/496#issuecomment-1831695107