Skip to content
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

Mocking on different parameters is not working #533

Open
stefanalfbo opened this issue Jan 16, 2023 · 0 comments
Open

Mocking on different parameters is not working #533

stefanalfbo opened this issue Jan 16, 2023 · 0 comments

Comments

@stefanalfbo
Copy link

Describe the bug
Trying to mock a unique result for each parameter on a RPC method, however the mocking is only working for the first parameter that is defined in the params section of the json document.

I'm probably misunderstanding something on how to create these examples correct. This issue 511 looks similar to mine but it hasn't helped to solve my issue.

To Reproduce
This is a simplified version of the schema:

{
  "openrpc": "1.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Mock Server"
  },
  "methods": [
    {
      "name": "Test.Method",
      "params": [
        {
          "name": "param1",
          "required": true,
          "schema": {
            "type": "string"
          }
        },
        {
          "name": "param2",
          "required": true,
          "schema": {
            "type": "integer"
          }
        }
      ],
      "result": {
        "name": "Test.Result",
        "description": "The result",
        "schema": {
          "type": "string"
        }
      },
      "examples": [
        {
          "name": "Test.Method.Example.Param1",
          "params": [
            {
              "name": "param1",
              "value": "1337 as text"
            }
          ],
          "result": {
            "name": "Test.Method.Example.Param1.Result",
            "value": "Expected.Result.Param1"
          }
        },
        {
          "name": "Test.Method.Example.Param2",
          "params": [
            {
              "name": "param2",
              "value": 1337
            }
          ],
          "result": {
            "name": "Test.Method.Example.Param2.Result",
            "value": "Expected.Result.Param2"
          }
        }
      ]
    }
  ]
}

A request that looks like this,

{"jsonrpc":"2.0","method":"Test.Method","params":{"param1":"1337 as text","param2":42},"id":0}

will give me this result,

{"id":0,"jsonrpc":"2.0","result":"Expected.Result.Param1"}

However, when I try to trigger the second result by using the defined value for param2 like this,

{"jsonrpc":"2.0","method":"Test.Method","params":{"param1":"Some text","param2":1337},"id":0}

then I receive this response.

{"id":0,"jsonrpc":"2.0","result":"Ut Excepteur incididunt"}

Expected behavior
In the last example above I would expect to get the result value: Expected.Result.Param2

Desktop (please complete the following information):

  • OS: Ubuntu 22.04.1 LTS
  • open-rpc-mock-server: 1.7.5
  • node: 18.12.1
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

No branches or pull requests

1 participant