Skip to content

[BUG][Typescript axios] Generated call to accessToken doesn't match type definition #2956

@bebsworthy

Description

@bebsworthy

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? 4.0.1#master
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?

The code generated for accessToken is :

// http bearer authentication required
            if (configuration && configuration.accessToken) {
                const accessToken = typeof configuration.accessToken === 'function'
                    ? configuration.accessToken()
                    : configuration.accessToken;
                localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
            }

(As per https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/typescript-axios/apiInner.mustache)

configuration.accessToken() is called without parameters

Type definition for accessToken is

accessToken?: string | ((name: string, scopes?: string[]) => string);

name is a mandatory parameter
Typescript outputs the following error semantic error TS2554 Expected 1-2 arguments, but got 0.

Type definition for accessToken should probably be:

accessToken?: string | ((name?: string, scopes?: string[]) => string);

or, if the parameters are never used:

accessToken?: string | (() => string);
  • [Optional] Bounty to sponsor the fix (example)
Description
openapi-generator version
OpenAPI declaration file content or url
Command line used for generation
Steps to reproduce
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