Skip to content
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 @@ -167,7 +167,7 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isBasicBearer}}
if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = typeof token === 'function' ? token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]) : token;
const tokenString = await token("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
Expand All @@ -192,11 +192,7 @@ export class {{classname}} extends runtime.BaseAPI {
{{#isOAuth}}
if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("{{name}}", [{{#scopes}}"{{{scope}}}"{{^-last}}, {{/-last}}{{/scopes}}]);
}

{{/isOAuth}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 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 @@ -164,10 +164,10 @@ export class Configuration {
return undefined;
}

get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === 'function' ? accessToken : () => accessToken;
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
}
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ export class FakeApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
const token = this.configuration.accessToken;
const tokenString = typeof token === 'function' ? token("bearer_test", []) : token;
const tokenString = await token("bearer_test", []);

if (tokenString) {
headerParameters["Authorization"] = `Bearer ${tokenString}`;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -130,11 +126,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -173,11 +165,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -218,11 +206,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -296,11 +280,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -335,11 +315,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const consumes: runtime.Consume[] = [
Expand Down Expand Up @@ -396,11 +372,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const consumes: runtime.Consume[] = [
Expand Down Expand Up @@ -464,11 +436,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const consumes: runtime.Consume[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 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 @@ -175,10 +175,10 @@ export class Configuration {
return undefined;
}

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

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -124,11 +120,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -167,11 +159,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -212,11 +200,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -290,11 +274,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const response = await this.request({
Expand Down Expand Up @@ -329,11 +309,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const consumes: runtime.Consume[] = [
Expand Down Expand Up @@ -390,11 +366,7 @@ export class PetApi extends runtime.BaseAPI {

if (this.configuration && this.configuration.accessToken) {
// oauth required
if (typeof this.configuration.accessToken === 'function') {
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
} else {
headerParameters["Authorization"] = this.configuration.accessToken;
}
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
}

const consumes: runtime.Consume[] = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 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 @@ -175,10 +175,10 @@ export class Configuration {
return undefined;
}

get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === 'function' ? accessToken : () => accessToken;
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
}
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ export interface ConfigurationParameters {
username?: string; // parameter for basic security
password?: string; // parameter for basic security
apiKey?: string | ((name: string) => string); // parameter for apiKey security
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 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 @@ -175,10 +175,10 @@ export class Configuration {
return undefined;
}

get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
const accessToken = this.configuration.accessToken;
if (accessToken) {
return typeof accessToken === 'function' ? accessToken : () => accessToken;
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
}
return undefined;
}
Expand Down
Loading