Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[typescript-axios] add promise to bearer and oauth tokens #7132

Merged
merged 2 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,17 @@ export const {{classname}}AxiosParamCreator = function (configuration?: Configur
// http bearer authentication required
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? configuration.accessToken()
: configuration.accessToken;
? await configuration.accessToken()
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + accessToken;
}
{{/isBasicBearer}}
{{#isOAuth}}
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
: configuration.accessToken;
? await configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
{{/isOAuth}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
}
Expand All @@ -20,14 +20,14 @@ export class Configuration {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
Expand All @@ -38,10 +38,10 @@ export class Configuration {
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
*
* @type {string}
* @memberof Configuration
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
}
Expand All @@ -31,14 +31,14 @@ export class Configuration {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
Expand All @@ -49,10 +49,10 @@ export class Configuration {
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
*
* @type {string}
* @memberof Configuration
*/
Expand Down
28 changes: 14 additions & 14 deletions samples/client/petstore/typescript-axios/builds/default/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -335,8 +335,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -389,8 +389,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -443,8 +443,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -547,8 +547,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -605,8 +605,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -670,8 +670,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
}
Expand All @@ -31,14 +31,14 @@ export class Configuration {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
Expand All @@ -49,10 +49,10 @@ export class Configuration {
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
*
* @type {string}
* @memberof Configuration
*/
Expand Down
28 changes: 14 additions & 14 deletions samples/client/petstore/typescript-axios/builds/es6-target/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -335,8 +335,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -389,8 +389,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -443,8 +443,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -547,8 +547,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -605,8 +605,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down Expand Up @@ -670,8 +670,8 @@ export const PetApiAxiosParamCreator = function (configuration?: Configuration)
// oauth required
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: configuration.accessToken;
? await configuration.accessToken("petstore_auth", ["write:pets", "read:pets"])
: await configuration.accessToken;
localVarHeaderParameter["Authorization"] = "Bearer " + localVarAccessTokenValue;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
baseOptions?: any;
}
Expand All @@ -31,14 +31,14 @@ export class Configuration {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
*
* @type {string}
* @memberof Configuration
*/
Expand All @@ -49,10 +49,10 @@ export class Configuration {
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | ((name?: string, scopes?: string[]) => string);
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
*
* @type {string}
* @memberof Configuration
*/
Expand Down
Loading