From 0b8c936972e70ace60e985a2e3ec6504c1efa28e Mon Sep 17 00:00:00 2001 From: Andrew Z Allen Date: Mon, 9 May 2016 22:59:25 -0600 Subject: [PATCH] Update TypeScript to do a better check for empty on basePath. In Angular if a value is not defined for injection it is passed as undefined. That means that most of the time `if (value) {` is a reasonable test. Unfortunately since `""` (empty string) is also falsey by nature, an empty string will not trigger the if properly. Instead you should check `if (value !== undefined) {`. --- .../src/main/resources/typescript-angular/api.mustache | 2 +- samples/client/petstore/typescript-angular/API/Client/PetApi.ts | 2 +- .../client/petstore/typescript-angular/API/Client/StoreApi.ts | 2 +- .../client/petstore/typescript-angular/API/Client/UserApi.ts | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache index 427479cf675..4d2660e82dc 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache @@ -18,7 +18,7 @@ namespace {{package}} { static $inject: string[] = ['$http', '$httpParamSerializer']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { - if (basePath) { + if (basePath !== undefined) { this.basePath = basePath; } } diff --git a/samples/client/petstore/typescript-angular/API/Client/PetApi.ts b/samples/client/petstore/typescript-angular/API/Client/PetApi.ts index 62492c17d80..c68ffcad88d 100644 --- a/samples/client/petstore/typescript-angular/API/Client/PetApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/PetApi.ts @@ -12,7 +12,7 @@ namespace API.Client { static $inject: string[] = ['$http', '$httpParamSerializer']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { - if (basePath) { + if (basePath !== undefined) { this.basePath = basePath; } } diff --git a/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts b/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts index 976ee7acd48..0b775139936 100644 --- a/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts @@ -12,7 +12,7 @@ namespace API.Client { static $inject: string[] = ['$http', '$httpParamSerializer']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { - if (basePath) { + if (basePath !== undefined) { this.basePath = basePath; } } diff --git a/samples/client/petstore/typescript-angular/API/Client/UserApi.ts b/samples/client/petstore/typescript-angular/API/Client/UserApi.ts index 79f6326b99c..a593f28b0e1 100644 --- a/samples/client/petstore/typescript-angular/API/Client/UserApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/UserApi.ts @@ -12,7 +12,7 @@ namespace API.Client { static $inject: string[] = ['$http', '$httpParamSerializer']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { - if (basePath) { + if (basePath !== undefined) { this.basePath = basePath; } }