Skip to content

[typescript-node][BUG] all supported authentication method (not configured) applied to request #4895

@AProts

Description

@AProts

Actual output

{{#authMethods}}
        authenticationPromise = authenticationPromise.then(() => this.authentications.{{name}}.applyToRequest(localVarRequestOptions));

{{/authMethods}}

Expected output

{{#authMethods}}
    {{#isApiKey}}
        if (this.authentications.{{name}}.apiKey) {
            authenticationPromise = authenticationPromise.then(() => this.authentications.{{name}}.applyToRequest(localVarRequestOptions));
        }
    {{/isApiKey}}
    {{#isBasicBasic}}
        if (this.authentications.{{name}}.username && this.authentications.{{name}}.password) {
            authenticationPromise = authenticationPromise.then(() => this.authentications.{{name}}.applyToRequest(localVarRequestOptions));
        }
    {{/isBasicBasic}}
    {{#isBasicBearer}}
        if (this.authentications.{{name}}.accessToken) {
            authenticationPromise = authenticationPromise.then(() => this.authentications.{{name}}.applyToRequest(localVarRequestOptions));
        }
    {{/isBasicBearer}}
    {{#isOAuth}}
        if (this.authentications.{{name}}.accessToken) {
            authenticationPromise = authenticationPromise.then(() => this.authentications.{{name}}.applyToRequest(localVarRequestOptions));
        }
    {{/isOAuth}}
{{/authMethods}}

Bug Report Checklist

  • [+] Have you provided a full/minimal spec to reproduce the issue?
  • [+] Have you validated the input using an OpenAPI validator (example)?
  • [+] What's the version of OpenAPI Generator used?
  • [+] Have you search for related issues/PRs?
  • [+] What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

All supported authentication method (not configured) applied to request in generated api client class

openapi-generator version

Master (4.2.3-SNAPSHOT)

OpenAPI declaration file content or url
Command line used for generation

generate -l typescript-node

Steps to reproduce
  1. generate apiclient for typescript-node with support of several authentication methods (e.g apikey & oauth)
  2. setup accesToken for oauth
  3. use any available method to create request
  4. check request data: oauth heder & empty apikey applied to request
Related issues/PRs
Suggest a fix

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions