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
  • #5915
Closed
Open
Issue created Apr 13, 2020 by Administrator@rootContributor

[BUG][csharp-netcore] bearerAuth is interpreted as basicAuth

Created by: FaFre

Description

I added a bearer authentication in my description according to the the swagger docs:

"components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    }
...
"security": [
    {
      "bearerAuth": []
    }
  ]

But for some reasons the generated code contains an basicAuth with username/password instead of the bearer expected as Authorization: Bearer <token>:

DefaultApi.cs:

// authentication (bearerAuth) required
            // http basic authentication required
            if (!String.IsNullOrEmpty(this.Configuration.Username) || !String.IsNullOrEmpty(this.Configuration.Password))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Basic " + Org.OpenAPITools.Client.ClientUtils.Base64Encode(this.Configuration.Username + ":" + this.Configuration.Password));
            }
openapi-generator version

I use the docker image:

$ openapi-generator-cli version
4.3.1-SNAPSHOT
OpenAPI declaration file content or url

Gist

Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i https://gist.githubusercontent.com/FaFre/b15e59572a974a9f453d14e5cdaf3bec/raw/d40a46cb20d70dd41abbf19691745f2ffb5a1f04/test.json -g csharp-netcore -o /local/
Assignee
Assign to
Time tracking