From 51ad775aee4ef3e2bfefaab85f4c734cc376e3da Mon Sep 17 00:00:00 2001 From: Andrew Z Allen Date: Mon, 9 May 2016 22:46:50 -0600 Subject: [PATCH] Update the injector static variable to contain all injected values. In Angular.js, values are injected into service in one of two ways: 1) Inline (by name). 2) By a static injector variable. The TypeScript generator uses the 2nd method. This method requires you to explicitly enumerate all the values you would like to have injected. If you fail to inject a value the Angular DI system will simply pass you `undefined`. The constructor is expecting 3 values to be passed (the final being basePath) but the injector static only defines 2 values. This results in basePath always being undefined no matter what you define it to be. This change updates the injector variable to handle that properly. --- .../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..6a713376146 100644 --- a/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache +++ b/modules/swagger-codegen/src/main/resources/typescript-angular/api.mustache @@ -15,7 +15,7 @@ namespace {{package}} { protected basePath = '{{basePath}}'; public defaultHeaders : any = {}; - static $inject: string[] = ['$http', '$httpParamSerializer']; + static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { if (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..b9567bd6780 100644 --- a/samples/client/petstore/typescript-angular/API/Client/PetApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/PetApi.ts @@ -9,7 +9,7 @@ namespace API.Client { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders : any = {}; - static $inject: string[] = ['$http', '$httpParamSerializer']; + static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { if (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..530a46fe1e6 100644 --- a/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/StoreApi.ts @@ -9,7 +9,7 @@ namespace API.Client { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders : any = {}; - static $inject: string[] = ['$http', '$httpParamSerializer']; + static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { if (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..cd079c32f9d 100644 --- a/samples/client/petstore/typescript-angular/API/Client/UserApi.ts +++ b/samples/client/petstore/typescript-angular/API/Client/UserApi.ts @@ -9,7 +9,7 @@ namespace API.Client { protected basePath = 'http://petstore.swagger.io/v2'; public defaultHeaders : any = {}; - static $inject: string[] = ['$http', '$httpParamSerializer']; + static $inject: string[] = ['$http', '$httpParamSerializer', 'basePath']; constructor(protected $http: ng.IHttpService, protected $httpParamSerializer?: (d: any) => any, basePath?: string) { if (basePath) {