From 580da9978ae7b22b561a3a0166188a390c68c818 Mon Sep 17 00:00:00 2001 From: Simon Hanna <33220646+simhnna@users.noreply.github.com> Date: Fri, 2 Feb 2024 15:23:20 +0100 Subject: [PATCH] Allow using bearer auth in typescript-nestjs (#17711) Closes: #10114 --- .../main/resources/typescript-nestjs/api.service.mustache | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache index 5c17513f994..4d2f116daf0 100644 --- a/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache @@ -142,6 +142,13 @@ export class {{classname}} { } {{/isBasicBasic}} +{{#isBasicBearer}} + if (typeof this.configuration.accessToken === 'function') { + headers['Authorization'] = `Bearer ${this.configuration.accessToken()}`; + } else if (this.configuration.accessToken) { + headers['Authorization'] = `Bearer ${this.configuration.accessToken}`; + } +{{/isBasicBearer}} {{#isOAuth}} if (this.configuration.accessToken) { const accessToken = typeof this.configuration.accessToken === 'function'