From fc03a0ad7d308bec8ac87a927a23fdd98dab33dc Mon Sep 17 00:00:00 2001 From: coffeemakr <5737978+coffeemakr@users.noreply.github.com> Date: Thu, 29 Oct 2026 12:14:10 +0100 Subject: [PATCH 1/3] [typescript]: Fix basic auth without username or password --- .../src/main/resources/Javascript-Flowtyped/api.mustache | 2 +- .../main/resources/typescript-angular/configuration.mustache | 2 +- .../src/main/resources/typescript-fetch/apis.mustache | 2 +- .../main/resources/typescript-inversify/api.service.mustache | 2 +- .../src/main/resources/typescript-jquery/api.mustache | 2 +- .../src/main/resources/typescript-nestjs/api.service.mustache | 2 +- .../typescript-fetch/builds/default-v3.0/apis/FakeApi.ts | 2 +- .../typescript-fetch/builds/kebab-case/apis/fake-api.ts | 2 +- .../builds/snakecase-discriminator/apis/FakeApi.ts | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache index 71664631260e..c123bd57b502 100644 --- a/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript-Flowtyped/api.mustache @@ -121,7 +121,7 @@ export const {{classname}}FetchParamCreator = function (configuration?: Configur {{#isBasicBasic}} // http basic authentication required if (configuration && (configuration.username || configuration.password)) { - localVarHeaderParameter["Authorization"] = "Basic " + btoa(configuration.username + ":" + configuration.password); + localVarHeaderParameter["Authorization"] = "Basic " + btoa((configuration.username || "") + ":" + (configuration.password || "")); } {{/isBasicBasic}} {{#isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache index c3d644d01f9d..ccff4606c903 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/configuration.mustache @@ -109,7 +109,7 @@ constructor({ accessToken, apiKeys, basePath, credentials, encodeParam, encoder, {{#isBasicBasic}} this.credentials['{{name}}'] = () => { return (this.username || this.password) - ? btoa(this.username + ':' + this.password) + ? btoa((this.username || '') + ':' + (this.password || '')) : undefined; }; {{/isBasicBasic}} diff --git a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache index 268f01408986..19af494e8253 100644 --- a/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-fetch/apis.mustache @@ -282,7 +282,7 @@ export class {{classname}} extends runtime.BaseAPI { {{#isBasic}} {{#isBasicBasic}} if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || "")); } {{/isBasicBasic}} {{#isBasicBearer}} diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index 3bbcbf2b13d4..c7584f9e2374 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -123,7 +123,7 @@ export class {{classname}} { {{/isApiKey}} {{#isBasicBasic}} if (this.APIConfiguration.username || this.APIConfiguration.password) { - headers['Authorization'] = btoa(this.APIConfiguration.username + ':' + this.APIConfiguration.password); + headers['Authorization'] = btoa((this.APIConfiguration.username || '') + ':' + (this.APIConfiguration.password || '')); } {{/isBasicBasic}} {{#isOAuth}} diff --git a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache index f1bb6f27d48f..2f65e30fe5df 100644 --- a/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-jquery/api.mustache @@ -179,7 +179,7 @@ export class {{classname}} { {{#isBasicBasic}} // http basic authentication required if (this.configuration.username || this.configuration.password) { - headerParams['Authorization'] = 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password); + headerParams['Authorization'] = 'Basic ' + btoa((this.configuration.username || '') + ':' + (this.configuration.password || '')); } {{/isBasicBasic}} 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 88081decc4d5..32b4984bdc68 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 @@ -191,7 +191,7 @@ export class {{classname}} { {{/isApiKey}} {{#isBasicBasic}} if (this.configuration.username || this.configuration.password) { - headers['Authorization'] = 'Basic ' + btoa(this.configuration.username + ':' + this.configuration.password); + headers['Authorization'] = 'Basic ' + btoa((this.configuration.username || '') + ':' + (this.configuration.password || '')); } {{/isBasicBasic}} diff --git a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts index 824be8eef113..21560c3727d0 100644 --- a/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/default-v3.0/apis/FakeApi.ts @@ -986,7 +986,7 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || "")); } const consumes: runtime.Consume[] = [ { contentType: 'application/x-www-form-urlencoded' }, diff --git a/samples/client/petstore/typescript-fetch/builds/kebab-case/apis/fake-api.ts b/samples/client/petstore/typescript-fetch/builds/kebab-case/apis/fake-api.ts index fda7529f8dfd..76a300c9af6b 100644 --- a/samples/client/petstore/typescript-fetch/builds/kebab-case/apis/fake-api.ts +++ b/samples/client/petstore/typescript-fetch/builds/kebab-case/apis/fake-api.ts @@ -986,7 +986,7 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || "")); } const consumes: runtime.Consume[] = [ { contentType: 'application/x-www-form-urlencoded' }, diff --git a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts index 57d0e86a9a03..0b997a3309e4 100644 --- a/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/apis/FakeApi.ts @@ -900,7 +900,7 @@ export class FakeApi extends runtime.BaseAPI { const headerParameters: runtime.HTTPHeaders = {}; if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || "")); } const consumes: runtime.Consume[] = [ { contentType: 'application/x-www-form-urlencoded' }, From e0b0f574aac0b15d243501384163d8bf8690ab2b Mon Sep 17 00:00:00 2001 From: coffeemakr <5737978+coffeemakr@users.noreply.github.com> Date: Thu, 29 Oct 2026 12:22:46 +0100 Subject: [PATCH 2/3] [typescript-inversify]: Add 'Basic ' prefix to authorization header Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com> --- .../main/resources/typescript-inversify/api.service.mustache | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache index c7584f9e2374..639e8baead35 100644 --- a/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-inversify/api.service.mustache @@ -123,7 +123,7 @@ export class {{classname}} { {{/isApiKey}} {{#isBasicBasic}} if (this.APIConfiguration.username || this.APIConfiguration.password) { - headers['Authorization'] = btoa((this.APIConfiguration.username || '') + ':' + (this.APIConfiguration.password || '')); + headers['Authorization'] = 'Basic ' + btoa((this.APIConfiguration.username || '') + ':' + (this.APIConfiguration.password || '')); } {{/isBasicBasic}} {{#isOAuth}} From bd78791baacc8e046df9aae3f3804c55543b980e Mon Sep 17 00:00:00 2001 From: coffeemakr <5737978+coffeemakr@users.noreply.github.com> Date: Thu, 29 Oct 2026 12:26:04 +0100 Subject: [PATCH 3/3] [javascript]: Add more fixes --- .../src/main/resources/Javascript-Apollo/ApiClient.mustache | 2 +- .../resources/Javascript/libraries/apollo/ApiClient.mustache | 2 +- .../src/main/resources/typescript-playwright/apis.mustache | 2 +- samples/client/petstore/javascript-apollo/src/ApiClient.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/Javascript-Apollo/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript-Apollo/ApiClient.mustache index 44d7eb3ded0a..4273a44d3887 100644 --- a/modules/openapi-generator/src/main/resources/Javascript-Apollo/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript-Apollo/ApiClient.mustache @@ -147,7 +147,7 @@ export default class ApiClient extends RESTDataSource { switch (auth.type) { case 'basic': if (auth.username || auth.password) { - fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode(auth.username + ":" + auth.password); + fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode((auth.username || "") + ":" + (auth.password || "")); } break; diff --git a/modules/openapi-generator/src/main/resources/Javascript/libraries/apollo/ApiClient.mustache b/modules/openapi-generator/src/main/resources/Javascript/libraries/apollo/ApiClient.mustache index 4f84ef57bdcd..af35baddc76e 100644 --- a/modules/openapi-generator/src/main/resources/Javascript/libraries/apollo/ApiClient.mustache +++ b/modules/openapi-generator/src/main/resources/Javascript/libraries/apollo/ApiClient.mustache @@ -147,7 +147,7 @@ export default class ApiClient extends RESTDataSource { switch (auth.type) { case 'basic': if (auth.username || auth.password) { - fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode(auth.username + ":" + auth.password); + fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode((auth.username || "") + ":" + (auth.password || "")); } break; diff --git a/modules/openapi-generator/src/main/resources/typescript-playwright/apis.mustache b/modules/openapi-generator/src/main/resources/typescript-playwright/apis.mustache index f11c4739aca6..6f554ef8a7b5 100644 --- a/modules/openapi-generator/src/main/resources/typescript-playwright/apis.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-playwright/apis.mustache @@ -177,7 +177,7 @@ export class {{classname}} extends runtime.BaseAPI { {{#isBasic}} {{#isBasicBasic}} if (this.configuration && (this.configuration.username !== undefined || this.configuration.password !== undefined)) { - headerParameters["Authorization"] = "Basic " + btoa(this.configuration.username + ":" + this.configuration.password); + headerParameters["Authorization"] = "Basic " + btoa((this.configuration.username || "") + ":" + (this.configuration.password || "")); } {{/isBasicBasic}} {{#isBasicBearer}} diff --git a/samples/client/petstore/javascript-apollo/src/ApiClient.js b/samples/client/petstore/javascript-apollo/src/ApiClient.js index b900791248f8..f6a6926d3c23 100644 --- a/samples/client/petstore/javascript-apollo/src/ApiClient.js +++ b/samples/client/petstore/javascript-apollo/src/ApiClient.js @@ -148,7 +148,7 @@ export default class ApiClient extends RESTDataSource { switch (auth.type) { case 'basic': if (auth.username || auth.password) { - fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode(auth.username + ":" + auth.password); + fetchOptions.headers['Authorization'] = 'Basic ' + base64.encode((auth.username || "") + ":" + (auth.password || "")); } break;