Skip to content

Commit

Permalink
Accept Promises for the apiKey configuration in the typescript-fetch …
Browse files Browse the repository at this point in the history
…generator. (#17758)
  • Loading branch information
jyasskin committed Feb 2, 2024
1 parent 7c7634d commit 8ff230e
Show file tree
Hide file tree
Showing 38 changed files with 54 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,13 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isApiKey}}
{{#isKeyInHeader}}
if (this.configuration && this.configuration.apiKey) {
headerParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
headerParameters["{{keyParamName}}"] = await this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
}
{{/isKeyInHeader}}
{{#isKeyInQuery}}
if (this.configuration && this.configuration.apiKey) {
queryParameters["{{keyParamName}}"] = this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
queryParameters["{{keyParamName}}"] = await this.configuration.apiKey("{{keyParamName}}"); // {{name}} authentication
}
{{/isKeyInQuery}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI {
headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.apiKey) {
queryParameters["api_key_query"] = this.configuration.apiKey("api_key_query"); // api_key_query authentication
queryParameters["api_key_query"] = await this.configuration.apiKey("api_key_query"); // api_key_query authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export interface ConfigurationParameters {
queryParamsStringify?: (params: HTTPQuery) => string; // stringify function for query strings
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
apiKey?: string | Promise<string> | ((name: string) => string | Promise<string>); // parameter for apiKey security
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
headers?: HTTPHeaders; //header params we want to use on every request
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
Expand Down Expand Up @@ -59,7 +59,7 @@ export class Configuration {
return this.configuration.password;
}

get apiKey(): ((name: string) => string) | undefined {
get apiKey(): ((name: string) => string | Promise<string>) | undefined {
const apiKey = this.configuration.apiKey;
if (apiKey) {
return typeof apiKey === 'function' ? apiKey : () => apiKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class FakeClassnameTags123Api extends runtime.BaseAPI {
headerParameters['Content-Type'] = 'application/json';

if (this.configuration && this.configuration.apiKey) {
queryParameters["api_key_query"] = this.configuration.apiKey("api_key_query"); // api_key_query authentication
queryParameters["api_key_query"] = await this.configuration.apiKey("api_key_query"); // api_key_query authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export class PetApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class StoreApi extends runtime.BaseAPI {
const headerParameters: runtime.HTTPHeaders = {};

if (this.configuration && this.configuration.apiKey) {
headerParameters["api_key"] = this.configuration.apiKey("api_key"); // api_key authentication
headerParameters["api_key"] = await this.configuration.apiKey("api_key"); // api_key authentication
}

const response = await this.request({
Expand Down

0 comments on commit 8ff230e

Please sign in to comment.