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
  • #2396
Closed
Open
Issue created Mar 14, 2019 by Administrator@rootContributor

[BUG][dart] Dart generated code for authentication only supports OAuth2

Created by: dalewking

Description

When you have a spec that uses apiKey authentication the dart generator dutifully generates an ApiKeyAuth class and puts an instance of it into the list of authentications for the ApiClient. The problem is that there is no way to actually use this class in that you cannot actually set the access token on it.

The problem is that the setAccessTokens method generated on ApiClient does not actually do anything for ApiKeyAuth. Here is the code it generates:

  void setAccessToken(String accessToken) {
    _authentications.forEach((key, auth) {
      if (auth is OAuth) {
        auth.setAccessToken(accessToken);
      }
    });
  }
openapi-generator version

3.3.4 and 4.0.0 behave the same

Suggest a fix

Change the template for setAccessTokens to include:

  else if (auth is ApiKeyAuth) {
    auth.apiKey = accessToken;
  }

Would be nice if it also supported apiKeyPrefix, but I'm not holding my breath.

The generated documentation contains examples saying you can do it like this:

// TODO Configure API key authorization: jwt
//my_service.api.Configuration.apiKey{'Authorization'} = 'YOUR_API_KEY';
// uncomment below to setup prefix (e.g. Bearer) for API key, if needed
//my_service.api.Configuration.apiKeyPrefix{'Authorization'} = "Bearer";

But there is no such Configuration class

Assignee
Assign to
Time tracking