Skip to content

Commit 7424582

Browse files
[TypeScript-Angular] Add AuthService example to README.md (#6087)
* Add AuthService example to TypeScript Angular README.md * Update generated Angular libs
1 parent a2b613c commit 7424582

File tree

17 files changed

+425
-0
lines changed

17 files changed

+425
-0
lines changed

modules/openapi-generator/src/main/resources/typescript-angular/README.mustache

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,31 @@ export function apiConfigFactory (): Configuration => {
107107
export class AppModule {}
108108
```
109109

110+
```
111+
// configuring providers with an authentication service that manages your access tokens
112+
import { ApiModule, Configuration } from '{{npmName}}';
113+
114+
@NgModule({
115+
imports: [ ApiModule ],
116+
declarations: [ AppComponent ],
117+
providers: [
118+
{
119+
provide: Configuration,
120+
useFactory: (authService: AuthService) => new Configuration(
121+
{
122+
basePath: environment.apiUrl,
123+
accessToken: authService.getAccessToken.bind(authService)
124+
}
125+
),
126+
deps: [AuthService],
127+
multi: false
128+
}
129+
],
130+
bootstrap: [ AppComponent ]
131+
})
132+
export class AppModule {}
133+
```
134+
110135
```
111136
import { DefaultApi } from '{{npmName}}';
112137

samples/client/petstore/typescript-angular-v2/default/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@ export function apiConfigFactory (): Configuration => {
9090
export class AppModule {}
9191
```
9292

93+
```
94+
// configuring providers with an authentication service that manages your access tokens
95+
import { ApiModule, Configuration } from '';
96+
97+
@NgModule({
98+
imports: [ ApiModule ],
99+
declarations: [ AppComponent ],
100+
providers: [
101+
{
102+
provide: Configuration,
103+
useFactory: (authService: AuthService) => new Configuration(
104+
{
105+
basePath: environment.apiUrl,
106+
accessToken: authService.getAccessToken.bind(authService)
107+
}
108+
),
109+
deps: [AuthService],
110+
multi: false
111+
}
112+
],
113+
bootstrap: [ AppComponent ]
114+
})
115+
export class AppModule {}
116+
```
117+
93118
```
94119
import { DefaultApi } from '';
95120

samples/client/petstore/typescript-angular-v2/npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@ export function apiConfigFactory (): Configuration => {
9090
export class AppModule {}
9191
```
9292

93+
```
94+
// configuring providers with an authentication service that manages your access tokens
95+
import { ApiModule, Configuration } from '@openapitools/angular2-typescript-petstore';
96+
97+
@NgModule({
98+
imports: [ ApiModule ],
99+
declarations: [ AppComponent ],
100+
providers: [
101+
{
102+
provide: Configuration,
103+
useFactory: (authService: AuthService) => new Configuration(
104+
{
105+
basePath: environment.apiUrl,
106+
accessToken: authService.getAccessToken.bind(authService)
107+
}
108+
),
109+
deps: [AuthService],
110+
multi: false
111+
}
112+
],
113+
bootstrap: [ AppComponent ]
114+
})
115+
export class AppModule {}
116+
```
117+
93118
```
94119
import { DefaultApi } from '@openapitools/angular2-typescript-petstore';
95120

samples/client/petstore/typescript-angular-v2/with-interfaces/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@ export function apiConfigFactory (): Configuration => {
9090
export class AppModule {}
9191
```
9292

93+
```
94+
// configuring providers with an authentication service that manages your access tokens
95+
import { ApiModule, Configuration } from '';
96+
97+
@NgModule({
98+
imports: [ ApiModule ],
99+
declarations: [ AppComponent ],
100+
providers: [
101+
{
102+
provide: Configuration,
103+
useFactory: (authService: AuthService) => new Configuration(
104+
{
105+
basePath: environment.apiUrl,
106+
accessToken: authService.getAccessToken.bind(authService)
107+
}
108+
),
109+
deps: [AuthService],
110+
multi: false
111+
}
112+
],
113+
bootstrap: [ AppComponent ]
114+
})
115+
export class AppModule {}
116+
```
117+
93118
```
94119
import { DefaultApi } from '';
95120

samples/client/petstore/typescript-angular-v4.3/npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '@openapitools/angular2-typescript-petstore';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '@openapitools/angular2-typescript-petstore';
97122

samples/client/petstore/typescript-angular-v4/npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,31 @@ export function apiConfigFactory (): Configuration => {
9090
export class AppModule {}
9191
```
9292

93+
```
94+
// configuring providers with an authentication service that manages your access tokens
95+
import { ApiModule, Configuration } from '@openapitools/angular2-typescript-petstore';
96+
97+
@NgModule({
98+
imports: [ ApiModule ],
99+
declarations: [ AppComponent ],
100+
providers: [
101+
{
102+
provide: Configuration,
103+
useFactory: (authService: AuthService) => new Configuration(
104+
{
105+
basePath: environment.apiUrl,
106+
accessToken: authService.getAccessToken.bind(authService)
107+
}
108+
),
109+
deps: [AuthService],
110+
multi: false
111+
}
112+
],
113+
bootstrap: [ AppComponent ]
114+
})
115+
export class AppModule {}
116+
```
117+
93118
```
94119
import { DefaultApi } from '@openapitools/angular2-typescript-petstore';
95120

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/default/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '';
97122

samples/client/petstore/typescript-angular-v6-not-provided-in-root/builds/with-npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '@openapitools/typescript-angular-petstore';
97122

samples/client/petstore/typescript-angular-v6-provided-in-root/builds/default/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '';
97122

samples/client/petstore/typescript-angular-v6-provided-in-root/builds/with-npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '@openapitools/typescript-angular-petstore';
97122

samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/default/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '';
97122

samples/client/petstore/typescript-angular-v7-not-provided-in-root/builds/with-npm/README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
9292
export class AppModule {}
9393
```
9494

95+
```
96+
// configuring providers with an authentication service that manages your access tokens
97+
import { ApiModule, Configuration } from '@openapitools/typescript-angular-petstore';
98+
99+
@NgModule({
100+
imports: [ ApiModule ],
101+
declarations: [ AppComponent ],
102+
providers: [
103+
{
104+
provide: Configuration,
105+
useFactory: (authService: AuthService) => new Configuration(
106+
{
107+
basePath: environment.apiUrl,
108+
accessToken: authService.getAccessToken.bind(authService)
109+
}
110+
),
111+
deps: [AuthService],
112+
multi: false
113+
}
114+
],
115+
bootstrap: [ AppComponent ]
116+
})
117+
export class AppModule {}
118+
```
119+
95120
```
96121
import { DefaultApi } from '@openapitools/typescript-angular-petstore';
97122

0 commit comments

Comments
 (0)