Skip to content

[typescript-angular2] baseUrl injectable #3513

@damienpontifex

Description

@damienpontifex
Description

The constructors for the Api classes in typescript-angular2 currently have the definition:

constructor(protected http: Http, @Optional() basePath: string)

To be able to provide a value and have DI use this value, would it be better to set this up as:

constructor(protected http: Http,  @Optional()@Inject(BASE_PATH) basePath: string)

And define a variables file with:

export const BASE_PATH = new OpaqueToken('basePath');

And then this could be utilised on app bootstrap by:

Import { BASE_PATH } from './service/variables';
bootstrap(AppComponent, [
    { provide: BASE_PATH, useValue: 'http://myservice:5000' }
]);
Swagger-codegen version

2.2.0

I'd be happy to make the contribution via a PR, just checking that there is no prior agreed way. And that this would be an appropriate way to handle this case?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions