OpenAPITools / OpenAPITools/openapi-generator
[BUG] setApiKeyToObject & setBearerAuthToObject functions set header to undefined
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in modules/openapi-generator/src/main/resources/typescript-axios/common.mustache, at setApiKeyToObject, setBearerAuthToObject, and the related authentication helpers. Check how localVarApiKeyValue and accessToken are handled when configuration functions return undefined or an empty string. Done means those values no longer add corresponding headers to the request object.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100