[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
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/