OpenAPITools / OpenAPITools/openapi-generator

[BUG] setApiKeyToObject & setBearerAuthToObject functions set header to undefined

Open
#13,281 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.