I am working on a Meteor web application using Angular 2 and TypeScript. To use the REST API, I created client code using Swagger Codegen. Unfortunately, there is no GitHub sample how to use the rest of the client.
I have an Angular 2 view component that introduces the Angular 2 service (ProductTreeService) and the generated API (both marked as "@Injectable"):
@Component({
selector: 'panel-product-selection',
template,
providers: [ProductTreeService, UserApi],
directives: [ProductTreeComponent]
})
export class PanelProductSelectionComponent
{
private categoriesProductsTree: Collections.LinkedList<CategoryTreeElement>;
private productTreeService: ProductTreeService;
private userApi: UserApi;
constructor(productTreeService: ProductTreeService, userApi: UserApi)
{
this.productTreeService = productTreeService;
this.userApi = userApi;
}
ngOnInit(): void
{
}
}
While the Angular service is accessible only, and everything is working fine, the application crashes when you type UserApi. The only difference between UserApi and ProductTreeService is the constructor: the service has no constructor parameters, the Api class generated :
constructor(protected http: Http, @Optional()@Inject(BASE_PATH) basePath: string) {
if (basePath) {
this.basePath = basePath;
}
}
So how can I insert the generated API?