swagger-api / swagger-api/swagger-codegen

[typescript-fetch] 2.3.0 changes how parameters are passed to methods

Open
#7,595 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

In 2.2.3 and below, the typescript-fetch generator accepted method parameters in an object, but 2.3.0 has regressed/made a very breaking change so that all parameters have to be passed individually:

e.g.,

# 2.2.3
public getFoo(params: {  "id": string; }, options?: any) { ... }

# 2.3.0
public getFoo(id: string, options?: any) { ... }

I couldn't find any reference to this as a deliberate change in any of the release notes

Swagger-codegen version

2.3.0 (regressed since 2.2.3)

Steps to reproduce

Generate any operation with parameters using typescript-fetch.

Related issues/PRs

I eventually managed to track the regression down to #6130, as api.mustache was completely rewritten when it was "copied" from here to here. Here is a diff of the changes which were made in #6130 to api.mustache, as Git/GitHub didn't detect a rename and show a useful diff (due to the number of changes).

The 2.2.3 behaviour for typescript-fetch was inconsistent with the behaviour for typescript-angular, so there is an existing issue saying that typescript-angular should accept params in an object

Suggest a fix/enhancement

Restore method signature to 2.2.3 form.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the typescript-fetch generator's api.mustache template and compare its generated method signatures with the 2.2.3 behavior described here. Generate an operation with parameters and verify whether parameters are accepted as an object; done means the generated signature and calls restore that behavior without breaking the existing typescript-fetch tests.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.