fern icon indicating copy to clipboard operation
fern copied to clipboard

[Feature] typescript: generate path parameters as destructured object

Open shixiao opened this issue 6 months ago • 0 comments

Problem description

Generated typescript client methods currently takes in path parameters individually, which is error prone as they are all string parameters.

E.g.,

...endpoints:
  foo:
    ...
    path-parameters:
      aid: string
      bid: string
      cid: string

currently generates:

foo(aid: string, bid: string, cid: string, request: ..., requestOptions?: ...): Promise<void>

Why would it be useful?

In the above example, it is easy to mix up the order of the calling parameters (foo("aaa", "bbb", "ccc"...)).

Describe the solution (optional)

Ideally, the sdk should generate something like:

foo({aid, bid, cid}: {aid: string, bid: string, cid: string}, request: ..., requestOptions?: ...): Promise<void>

shixiao avatar Aug 15 '24 15:08 shixiao