[REQ] TypeScript Angular README.md add example with authentication service
Created by: dennisameling
Is your feature request related to a problem? Please describe.
Many Angular applications will have an authentication service that manages the API access tokens. Consider the following example, where the ApiModule's forRoot()
method is used to set the API configuration (basePath, accessToken, etc.) for the application:
// configuring providers
import { ApiModule, Configuration, ConfigurationParameters } from 'YOUR_API';
export function apiConfigFactory (): Configuration => {
const params: ConfigurationParameters = {
// set configuration parameters here.
}
return new Configuration(params);
}
@NgModule({
imports: [ ApiModule.forRoot(apiConfigFactory) ],
declarations: [ AppComponent ],
providers: [],
bootstrap: [ AppComponent ]
})
export class AppModule {}
However, in this example, it's not possible to access the AuthService
already in Angular's AppModule and update the accessToken as soon as the AuthService
updates it. Similar to what is mentioned in https://github.com/swagger-api/swagger-codegen/issues/5996#issue-240845000.
Describe the solution you'd like
We should add an example based on kewur's answer to the README.md of generated API libraries for Angular/TypeScript.
Describe alternatives you've considered
n/a
Additional context
I have a PR ready that adds this example to README.md
, will link it to this issue.