Skip to content

Broken typescript generated, when using dots in method names #619

@ivankhm

Description

@ivankhm

Describe the bug
Incorrect methods names when using typescript client generator on a schema that has dots in method names.

To Reproduce
Steps to reproduce the behavior:

  1. run npm install -g @open-rpc/generator
  2. Create file openrpc.json with the following content using dots in method names:
{
  "openrpc": "1.0.0-rc1",
  "info": {
    "title": "test",
    "version": "1.0.0"
  },
  "methods": [
    {
      "name": "foo.bar",
      "summary": "test",
      "params": [],
      "result": {
        "name": "fooBarResult",
        "schema": {
          "type": "object"
        }
      }
    }
  ]
}
  1. run open-rpc-generator generate -t client -l typescript -n test-d ./openrpc.json -o ./generated
  2. go to ./generated/client/typescript/src/index.ts
  3. See typescript error on line 153 due to incorrect syntax.
  public foo.bar: FooBar = (...params) => {
    return this.request("foo.bar", params);
  }

Expected behavior
Dot replaced with '_' (or somehow removed, like fooBar) for typescript method name:

  public foo_bar: FooBar = (...params) => {
    return this.request("foo.bar", params);
  }

Desktop

  • OS: Windows 10
  • @open-rpc/generator version ^1.18.11

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions