Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Issues
  • #2956
Closed
Open
Issue created May 21, 2019 by Administrator@rootContributor2 of 6 checklist items completed2/6 checklist items

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

Created by: 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
Assignee
Assign to
Time tracking