openapi-generator
openapi-generator copied to clipboard
[BUG] setApiKeyToObject & setBearerAuthToObject functions set header to undefined
Bug Report Checklist
- [X] Have you provided a full/minimal spec to reproduce the issue?
- [ ] Have you validated the input using an OpenAPI validator (example)?
- [X] Have you tested with the latest master to confirm the issue still exists?
- [X] Have you searched for related issues/PRs?
- [X] What's the actual output vs expected output?
- [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
When the apiKey
and accessToken
config settings are functions, setApiKeyToObject
, setBearerAuthToObject
, etc... will set the header values to undefined or empty string if the config function returns either.
openapi-generator version
6.0.1
Suggest a fix
The setApiKeyToObject, setBearerAuthToObject, etc... functions need to check if the localVarApiKeyValue
, accessToken
, etc... local variable is undefined; if so, then do not add the key to the object. When the apiKey
and accessToken
config settings are a function and there is multiple possible authentication schemes for a rest api(api key, bearer, etc...), we need to be able to tell the setApiKeyToObject
, setBearerAuthToObject
, etc... functions that we do not want to add the header to the request object.
can you please file a PR with the suggested fix? thanks
Authentication/authorization is in general broken and should be really looked into , at least when generating aspnetcore , messy code is generated that does not register a defaultScheme ect pp I am so far that I dont doc apikeys in the spec file and write some own simple check , its a workaround but not a solution
We have asp.net core APIs that it generates perfectly for. One of out API servers even has 3 different authentication schemes. One oauth bearer and the other two api key based.