[BUG][typescript-angular] Unable to use multiple access tokens
Created by: djnalluri
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
All security schemes that use the HTTP Bearer and OAuth2 schemes rely on the single accessToken
field of the configuration object. Using API's that use multiple of this scheme become tricky to use as you must swap out the access token to the correct one prior to each request.
openapi-generator version
<= 5.0.0-beta
OpenAPI declaration file content or url
https://gist.github.com/djnalluri/1a6ae2ad99f8f198620cb262432d4615
Command line used for generation
openapi-generator generate -g typescript-angular -i openapi.yml
Steps to reproduce
Use the spec file and command provided above to generate a client.
Related issues/PRs
None for typescript-angular
Suggest a fix
I suggest unifying the configuration for API Key, Basic, Bearer, and OAuth2 schemes into a single map for lookup just like the apiKeys
property currently in the configuration object. The type of the map can be adjusted to also accept functions returning strings like accessToken
currently does; OAuth2 scheme behaviour can be kept mostly the same in this way. Basic authentication can be adjusted to first check for an already prepared base64 string in the map and fall back to existing behaviour.