swagger-api / swagger-api/swagger-codegen

Typescript-node - TS2300: Duplicate identifier 'default`

Open
#9,219 0 comments 0 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

I installed swagger-codegen@2 on a mac to make sure that typescript-node was included as a language. When generating a typescript-node client I get the following errors:

    protected authentications = {
        'default': <Authentication>new VoidAuth(),
        'default': new OAuth(),
    }

error TS2300: Duplicate identifier ''default''

Which I think in turn causes

    public setDefaultAuthentication(auth: Authentication) {
	this.authentications.default = auth;
    }

error TS2322: Type 'Authentication' is not assignable to type 'OAuth'.
Property 'accessToken' is missing in type 'Authentication'.

Swagger-codegen version

V2.4.1

Swagger declaration file content or url

I cannot provide the complete JSON as it is private but I could provide a snippet if I can get a pointer as to where there might be an issue.

Command line used for generation
swagger-codegen generate -i swagger.json -l typescript-node
Steps to reproduce

As above

Related issues/PRs
Suggest a fix/enhancement

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

Reproduce the issue with the swagger-codegen generate -i swagger.json -l typescript-node command and inspect the generated authentications block. Use a Swagger declaration that produces both default entries, then verify the generated client has no duplicate identifier and that setDefaultAuthentication type-checks.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.