Skip to content

Commit 82f409c

Browse files
author
Alex Vanston
committed
Add bearer auth to typescript-fetch
1 parent e7666b8 commit 82f409c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

  • modules/openapi-generator/src/main/resources/typescript-fetch

modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,18 @@ export class {{classname}} extends runtime.BaseAPI {
107107
{{/headerParams}}
108108
{{#authMethods}}
109109
{{#isBasic}}
110+
{{#isBasicBasic}}
110111
if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) {
111112
headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password);
112113
}
113-
114+
{{/isBasicBasic}}
115+
{{#isBasicBearer}}
116+
// http bearer auth required
117+
if (this.configuration && (this.configuration.accessToken || this.configuration.apiKey)) {
118+
let token = this.configuration.accessToken || this.configuration.apiKey;
119+
headerParameters["Authorization"] = `Bearer ${token}`;
120+
}
121+
{{/isBasicBearer}}
114122
{{/isBasic}}
115123
{{#isApiKey}}
116124
{{#isKeyInHeader}}

0 commit comments

Comments
 (0)