Skip to content

Commit

Permalink
[typescript-axios] add promise to bearer and oauth tokens (#7132)
Browse files Browse the repository at this point in the history
  • Loading branch information
asterikx authored Aug 5, 2020
1 parent f5775f4 commit f752f29
Show file tree
Hide file tree
Showing 17 changed files with 147 additions and 147 deletions.
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

0 comments on commit f752f29

Please sign in to comment.