From bd9aa9d8bf5b3cbfb713dedb4b9faf91e2582d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Nova=CC=81k?= Date: Mon, 29 Jul 2019 11:04:12 +0200 Subject: [PATCH 1/3] [typescript-angular] Fixing #2731 - empty string basePath --- .../main/resources/typescript-angular/api.service.mustache | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache index 85573aa8b13d..05cdbc17d68c 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache @@ -69,10 +69,10 @@ export class {{classname}} { if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; + this.configuration.basePath = (typeof configuration.basePath === 'string') ? configuration.basePath : ((typeof basePath === 'string') ? basePath : this.basePath); } else { - this.configuration.basePath = basePath || this.basePath; + this.configuration.basePath = (typeof basePath === 'string') ? basePath : this.basePath } {{#useHttpClient}} this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); From 6a95a6b4dd1e63d6d6012e854e29a1e79df79d7f Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Mon, 9 Sep 2019 10:22:45 +0200 Subject: [PATCH 2/3] typescript-angular: refactor base path configuration --- .../resources/typescript-angular/api.service.mustache | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache index 05cdbc17d68c..5bd425e451d3 100644 --- a/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-angular/api.service.mustache @@ -66,13 +66,14 @@ export class {{classname}} { {{/useHttpClient}} constructor(protected {{#useHttpClient}}httpClient: HttpClient{{/useHttpClient}}{{^useHttpClient}}http: Http{{/useHttpClient}}, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = (typeof configuration.basePath === 'string') ? configuration.basePath : ((typeof basePath === 'string') ? basePath : this.basePath); - - } else { - this.configuration.basePath = (typeof basePath === 'string') ? basePath : this.basePath + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } {{#useHttpClient}} this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); From 4df8b873fbd969320e266ade2733105383f51716 Mon Sep 17 00:00:00 2001 From: Esteban Marin Date: Mon, 9 Sep 2019 12:17:17 +0200 Subject: [PATCH 3/3] typescript-angular: refactor base path configuration --- .../default/api/pet.service.ts | 11 ++-- .../default/api/store.service.ts | 11 ++-- .../default/api/user.service.ts | 11 ++-- .../npm/api/pet.service.ts | 11 ++-- .../npm/api/store.service.ts | 11 ++-- .../npm/api/user.service.ts | 11 ++-- .../with-interfaces/api/pet.service.ts | 11 ++-- .../with-interfaces/api/store.service.ts | 11 ++-- .../with-interfaces/api/user.service.ts | 11 ++-- .../npm/api/pet.service.ts | 11 ++-- .../npm/api/store.service.ts | 11 ++-- .../npm/api/user.service.ts | 11 ++-- .../npm/api/pet.service.ts | 11 ++-- .../npm/api/store.service.ts | 11 ++-- .../npm/api/user.service.ts | 11 ++-- .../builds/default/api/pet.service.ts | 11 ++-- .../builds/default/api/store.service.ts | 11 ++-- .../builds/default/api/user.service.ts | 11 ++-- .../builds/with-npm/api/pet.service.ts | 11 ++-- .../builds/with-npm/api/store.service.ts | 11 ++-- .../builds/with-npm/api/user.service.ts | 11 ++-- .../builds/default/api/pet.service.ts | 11 ++-- .../builds/default/api/store.service.ts | 11 ++-- .../builds/default/api/user.service.ts | 11 ++-- .../builds/with-npm/api/pet.service.ts | 11 ++-- .../builds/with-npm/api/store.service.ts | 11 ++-- .../builds/with-npm/api/user.service.ts | 11 ++-- .../builds/default/api/pet.service.ts | 11 ++-- .../builds/default/api/store.service.ts | 11 ++-- .../builds/default/api/user.service.ts | 11 ++-- .../builds/with-npm/api/pet.service.ts | 11 ++-- .../builds/with-npm/api/store.service.ts | 11 ++-- .../builds/with-npm/api/user.service.ts | 11 ++-- .../builds/default/api/pet.service.ts | 11 ++-- .../builds/default/api/store.service.ts | 11 ++-- .../builds/default/api/user.service.ts | 11 ++-- .../builds/with-npm/api/pet.service.ts | 11 ++-- .../builds/with-npm/api/store.service.ts | 11 ++-- .../builds/with-npm/api/user.service.ts | 11 ++-- .../default/src/test/configuration.spec.ts | 65 +++++++++++++++++++ .../builds/with-npm/api/pet.service.ts | 11 ++-- .../builds/with-npm/api/store.service.ts | 11 ++-- .../builds/with-npm/api/user.service.ts | 11 ++-- 43 files changed, 317 insertions(+), 210 deletions(-) diff --git a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts index 62bfcb0f6892..9c9ee52b1e56 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts index 31b3c7046918..2c7456394027 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts index 42bac67fac3b..9ce463aa8299 100644 --- a/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/default/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts index 62bfcb0f6892..9c9ee52b1e56 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts index 31b3c7046918..2c7456394027 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts index 42bac67fac3b..9ce463aa8299 100644 --- a/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/npm/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts index 7aebfe5fef43..c75e5e46dddd 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/pet.service.ts @@ -36,13 +36,14 @@ export class PetService implements PetServiceInterface { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts index 7fdd6d038832..147e0c8dfd57 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/store.service.ts @@ -35,13 +35,14 @@ export class StoreService implements StoreServiceInterface { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts index d852fae20a1c..d9acd360ef3a 100644 --- a/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v2/with-interfaces/api/user.service.ts @@ -35,13 +35,14 @@ export class UserService implements UserServiceInterface { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts index 52f9e5ee8d91..1d5843d4042c 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/pet.service.ts @@ -33,13 +33,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts index d853a0f4c88d..eb7539d0d529 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/store.service.ts @@ -32,13 +32,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts index b8f2a9f32d9a..0f0a22e8234d 100644 --- a/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4.3/npm/api/user.service.ts @@ -32,13 +32,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts index 62bfcb0f6892..9c9ee52b1e56 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts index 31b3c7046918..2c7456394027 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts index 42bac67fac3b..9ce463aa8299 100644 --- a/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v4/npm/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: QueryEncoder; constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomQueryEncoderHelper(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts index 989d91b5c028..380838570e9d 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/pet.service.ts @@ -33,13 +33,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts index 97392be5f22a..f1fc543ad0c2 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/store.service.ts @@ -32,13 +32,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/user.service.ts index 5357ddadaa8f..89ca23713a24 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/api/user.service.ts @@ -32,13 +32,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts index 989d91b5c028..380838570e9d 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/pet.service.ts @@ -33,13 +33,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts index 97392be5f22a..f1fc543ad0c2 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/store.service.ts @@ -32,13 +32,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/user.service.ts index 5357ddadaa8f..89ca23713a24 100644 --- a/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/api/user.service.ts @@ -32,13 +32,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts index a0df069e6a4a..25f4cdfc7f4a 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts index 6264d975e002..8fba3b49de87 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/user.service.ts index a85d85649952..a9fc0b74c1a6 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts index a0df069e6a4a..25f4cdfc7f4a 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts index 6264d975e002..8fba3b49de87 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/user.service.ts index a85d85649952..a9fc0b74c1a6 100644 --- a/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts index 989d91b5c028..380838570e9d 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/pet.service.ts @@ -33,13 +33,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/store.service.ts index 97392be5f22a..f1fc543ad0c2 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/store.service.ts @@ -32,13 +32,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/user.service.ts index 5357ddadaa8f..89ca23713a24 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/api/user.service.ts @@ -32,13 +32,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts index 989d91b5c028..380838570e9d 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/pet.service.ts @@ -33,13 +33,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/store.service.ts index 97392be5f22a..f1fc543ad0c2 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/store.service.ts @@ -32,13 +32,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/user.service.ts index 5357ddadaa8f..89ca23713a24 100644 --- a/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/api/user.service.ts @@ -32,13 +32,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts index a0df069e6a4a..25f4cdfc7f4a 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/store.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/store.service.ts index 6264d975e002..8fba3b49de87 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/user.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/user.service.ts index a85d85649952..a9fc0b74c1a6 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/default/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts index a0df069e6a4a..25f4cdfc7f4a 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/store.service.ts index 6264d975e002..8fba3b49de87 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/user.service.ts index a85d85649952..a9fc0b74c1a6 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/builds/with-npm/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/configuration.spec.ts b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/configuration.spec.ts index 0b8ec658ac1d..120c9d284cb0 100644 --- a/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/configuration.spec.ts +++ b/samples/client/petstore/typescript-angular-v7-provided-in-root/tests/default/src/test/configuration.spec.ts @@ -91,3 +91,68 @@ describe(`API (with ConfigurationFactory)`, () => { }); }); + +describe(`API (with ConfigurationFactory and empty basePath)`, () => { + let httpClient: HttpClient; + let httpTestingController: HttpTestingController; + + const pet: Pet = { + name: `pet`, + photoUrls: [] + }; + + let apiConfigurationParams: ConfigurationParameters = { + // add configuration params here + basePath: '' + }; + + let apiConfig: Configuration = new Configuration(apiConfigurationParams); + + const getApiConfig = () => { + return apiConfig; + }; + + beforeEach(() => { + TestBed.configureTestingModule({ + imports: [ + HttpClientTestingModule , + ApiModule.forRoot(getApiConfig) + ], + providers: [ + PetService, + ] + }); + + // Inject the http service and test controller for each test + httpClient = TestBed.get(HttpClient); + httpTestingController = TestBed.get(HttpTestingController); + }); + + afterEach(() => { + // After every test, assert that there are no more pending requests. + httpTestingController.verify(); + }); + + describe(`PetService`, () => { + it(`should be provided`, () => { + const petService = TestBed.get(PetService); + expect(petService).toBeTruthy(); + }); + + it(`should call initially configured empty basePath /pet`, async(() => { + const petService = TestBed.get(PetService); + + petService.addPet(pet).subscribe( + result => expect(result).toEqual(pet), + error => fail(`expected a result, not the error: ${error.message}`), + ); + + const req = httpTestingController.expectOne('/pet'); + + expect(req.request.method).toEqual('POST'); + + req.flush(pet); + })); + }); + +}); diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/pet.service.ts b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/pet.service.ts index a0df069e6a4a..25f4cdfc7f4a 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/pet.service.ts +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/pet.service.ts @@ -35,13 +35,14 @@ export class PetService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/store.service.ts b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/store.service.ts index 6264d975e002..8fba3b49de87 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/store.service.ts +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/store.service.ts @@ -34,13 +34,14 @@ export class StoreService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); } diff --git a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/user.service.ts b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/user.service.ts index a85d85649952..a9fc0b74c1a6 100644 --- a/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/user.service.ts +++ b/samples/client/petstore/typescript-angular-v8-provided-in-root/builds/with-npm/api/user.service.ts @@ -34,13 +34,14 @@ export class UserService { public encoder: HttpParameterCodec; constructor(protected httpClient: HttpClient, @Optional()@Inject(BASE_PATH) basePath: string, @Optional() configuration: Configuration) { - if (configuration) { this.configuration = configuration; - this.configuration.basePath = configuration.basePath || basePath || this.basePath; - - } else { - this.configuration.basePath = basePath || this.basePath; + } + if (typeof this.configuration.basePath !== 'string') { + if (typeof basePath !== 'string') { + basePath = this.basePath; + } + this.configuration.basePath = basePath; } this.encoder = this.configuration.encoder || new CustomHttpParameterCodec(); }