OpenAPITools / OpenAPITools/openapi-generator

[BUG] Multiple oauth2 flows cause typescript-node generation syntax errors

Open
#13,118 1 comment 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
Description

When generating SDK code using the generate command, typescript-node implementation has syntax errors in the API code when there are two or more oauth2 flows defined in the securitySchema

openapi-generator version
java -jar openapi-generator-cli.jar version
6.0.1
OpenAPI declaration file content or url
components:
  securitySchemes:
    oauth2:
      type: oauth2
      description: simple authentication
      flows:
        clientCredentials:
          tokenUrl: https://oauth/token
          scopes: 
            all: 'access to all scopes'
        authorizationCode:
          authorizationUrl: https://oauth/authorize
          tokenUrl: https://oauth/token
          scopes: 
            all: 'access to all scopes'

full file can be found here: example-api.yaml

Generation Details

java -jar openapi-generator-cli.jar generate -i example-api.yaml -g typescript-node -o sdk

Steps to reproduce

after generating the source files, you will see the following in the defaultApi.ts:

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

which prevents tsc from being able to build the file.

Related issues/PRs

I have not found a related issue

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

Use example-api.yaml with the documented typescript-node generation command, then inspect the generated defaultApi.ts. Start by tracing how the two OAuth2 flows become entries in the authentications object. Done means the generated TypeScript no longer contains duplicate oauth2 keys and can build successfully with tsc.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.