Skip to content

Commit fd2f5e3

Browse files
committed
feat(angular): add support for README_beforeV17 and update provideApi return type
1 parent d0e5248 commit fd2f5e3

13 files changed

Lines changed: 715 additions & 715 deletions

File tree

  • modules/openapi-generator/src/main/resources/typescript-angular
  • samples/client/petstore
    • typescript-angular-v12-oneOf/builds/default
    • typescript-angular-v12-provided-in-any/builds/default
    • typescript-angular-v12-provided-in-root/builds
    • typescript-angular-v13-oneOf/builds/default
    • typescript-angular-v13-provided-in-any/builds/default
    • typescript-angular-v13-provided-in-root/builds
    • typescript-angular-v14-provided-in-root/builds/default
    • typescript-angular-v14-query-param-object-format
    • typescript-angular-v15-provided-in-root/builds/default
    • typescript-angular-v16-provided-in-root/builds/default

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

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ import { {{apiModuleClassName}} } from '{{npmName}}';
6363
import { HttpClientModule } from '@angular/common/http';
6464

6565
@NgModule({
66-
imports: [
67-
{{apiModuleClassName}},
68-
// make sure to import the HttpClientModule in the AppModule only,
69-
// see https://github.com/angular/angular/issues/20575
70-
HttpClientModule
71-
],
72-
declarations: [ AppComponent ],
73-
providers: [],
74-
bootstrap: [ AppComponent ]
66+
imports: [
67+
{{apiModuleClassName}},
68+
// make sure to import the HttpClientModule in the AppModule only,
69+
// see https://github.com/angular/angular/issues/20575
70+
HttpClientModule
71+
],
72+
declarations: [ AppComponent ],
73+
providers: [],
74+
bootstrap: [ AppComponent ]
7575
})
7676
export class AppModule {}
7777
```
@@ -81,17 +81,17 @@ export class AppModule {}
8181
import { {{apiModuleClassName}}, {{configurationClassName}}, {{configurationParametersInterfaceName}} } from '{{npmName}}';
8282

8383
export function apiConfigFactory (): {{configurationClassName}} {
84-
const params: {{configurationParametersInterfaceName}} = {
85-
// set configuration parameters here.
86-
}
87-
return new {{configurationClassName}}(params);
84+
const params: {{configurationParametersInterfaceName}} = {
85+
// set configuration parameters here.
86+
}
87+
return new {{configurationClassName}}(params);
8888
}
8989

9090
@NgModule({
91-
imports: [ {{apiModuleClassName}}.forRoot(apiConfigFactory) ],
92-
declarations: [ AppComponent ],
93-
providers: [],
94-
bootstrap: [ AppComponent ]
91+
imports: [ {{apiModuleClassName}}.forRoot(apiConfigFactory) ],
92+
declarations: [ AppComponent ],
93+
providers: [],
94+
bootstrap: [ AppComponent ]
9595
})
9696
export class AppModule {}
9797
```
@@ -101,22 +101,22 @@ export class AppModule {}
101101
import { {{apiModuleClassName}}, {{configurationClassName}} } from '{{npmName}}';
102102

103103
@NgModule({
104-
imports: [ {{apiModuleClassName}} ],
105-
declarations: [ AppComponent ],
106-
providers: [
107-
{
108-
provide: {{configurationClassName}},
109-
useFactory: (authService: AuthService) => new {{configurationClassName}}(
110-
{
111-
basePath: environment.apiUrl,
112-
accessToken: authService.getAccessToken.bind(authService)
113-
}
114-
),
115-
deps: [AuthService],
116-
multi: false
117-
}
118-
],
119-
bootstrap: [ AppComponent ]
104+
imports: [ {{apiModuleClassName}} ],
105+
declarations: [ AppComponent ],
106+
providers: [
107+
{
108+
provide: {{configurationClassName}},
109+
useFactory: (authService: AuthService) => new {{configurationClassName}}(
110+
{
111+
basePath: environment.apiUrl,
112+
accessToken: authService.getAccessToken.bind(authService)
113+
}
114+
),
115+
deps: [AuthService],
116+
multi: false
117+
}
118+
],
119+
bootstrap: [ AppComponent ]
120120
})
121121
export class AppModule {}
122122
```
@@ -125,7 +125,7 @@ export class AppModule {}
125125
import { DefaultApi } from '{{npmName}}';
126126

127127
export class AppComponent {
128-
constructor(private apiGateway: DefaultApi) { }
128+
constructor(private apiGateway: DefaultApi) { }
129129
}
130130
```
131131

@@ -144,13 +144,13 @@ import { {{apiModuleClassName}} as OtherApiModule } from 'my-other-api-path';
144144
import { HttpClientModule } from '@angular/common/http';
145145

146146
@NgModule({
147-
imports: [
148-
{{apiModuleClassName}},
149-
OtherApiModule,
150-
// make sure to import the HttpClientModule in the AppModule only,
151-
// see https://github.com/angular/angular/issues/20575
152-
HttpClientModule
153-
]
147+
imports: [
148+
{{apiModuleClassName}},
149+
OtherApiModule,
150+
// make sure to import the HttpClientModule in the AppModule only,
151+
// see https://github.com/angular/angular/issues/20575
152+
HttpClientModule
153+
]
154154
})
155155
export class AppModule {
156156
@@ -165,7 +165,7 @@ If different than the generated base path, during app bootstrap, you can provide
165165
import { BASE_PATH } from '{{npmName}}';
166166

167167
bootstrap(AppComponent, [
168-
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
168+
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
169169
]);
170170
```
171171

@@ -175,10 +175,10 @@ or
175175
import { BASE_PATH } from '{{npmName}}';
176176

177177
@NgModule({
178-
imports: [],
179-
declarations: [ AppComponent ],
180-
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
181-
bootstrap: [ AppComponent ]
178+
imports: [],
179+
declarations: [ AppComponent ],
180+
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
181+
bootstrap: [ AppComponent ]
182182
})
183183
export class AppModule {}
184184
```
@@ -189,8 +189,8 @@ First extend your `src/environments/*.ts` files by adding the corresponding base
189189

190190
```typescript
191191
export const environment = {
192-
production: false,
193-
API_BASE_PATH: 'http://127.0.0.1:8080'
192+
production: false,
193+
API_BASE_PATH: 'http://127.0.0.1:8080'
194194
};
195195
```
196196

@@ -201,12 +201,12 @@ import { BASE_PATH } from '{{npmName}}';
201201
import { environment } from '../environments/environment';
202202

203203
@NgModule({
204-
declarations: [
205-
AppComponent
206-
],
207-
imports: [ ],
208-
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
209-
bootstrap: [ AppComponent ]
204+
declarations: [
205+
AppComponent
206+
],
207+
imports: [ ],
208+
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
209+
bootstrap: [ AppComponent ]
210210
})
211211
export class AppModule { }
212212
```
@@ -227,7 +227,7 @@ Example value for use in your Configuration-Provider:
227227

228228
```typescript
229229
new Configuration({
230-
encodeParam: (param: Param) => myFancyParamEncoder(param),
230+
encodeParam: (param: Param) => myFancyParamEncoder(param),
231231
})
232232
```
233233

samples/client/petstore/typescript-angular-v12-oneOf/builds/default/README.md

Lines changed: 55 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ import { ApiModule } from '';
6363
import { HttpClientModule } from '@angular/common/http';
6464

6565
@NgModule({
66-
imports: [
67-
ApiModule,
68-
// make sure to import the HttpClientModule in the AppModule only,
69-
// see https://github.com/angular/angular/issues/20575
70-
HttpClientModule
71-
],
72-
declarations: [ AppComponent ],
73-
providers: [],
74-
bootstrap: [ AppComponent ]
66+
imports: [
67+
ApiModule,
68+
// make sure to import the HttpClientModule in the AppModule only,
69+
// see https://github.com/angular/angular/issues/20575
70+
HttpClientModule
71+
],
72+
declarations: [ AppComponent ],
73+
providers: [],
74+
bootstrap: [ AppComponent ]
7575
})
7676
export class AppModule {}
7777
```
@@ -81,17 +81,17 @@ export class AppModule {}
8181
import { ApiModule, Configuration, ConfigurationParameters } from '';
8282

8383
export function apiConfigFactory (): Configuration {
84-
const params: ConfigurationParameters = {
85-
// set configuration parameters here.
86-
}
87-
return new Configuration(params);
84+
const params: ConfigurationParameters = {
85+
// set configuration parameters here.
86+
}
87+
return new Configuration(params);
8888
}
8989

9090
@NgModule({
91-
imports: [ ApiModule.forRoot(apiConfigFactory) ],
92-
declarations: [ AppComponent ],
93-
providers: [],
94-
bootstrap: [ AppComponent ]
91+
imports: [ ApiModule.forRoot(apiConfigFactory) ],
92+
declarations: [ AppComponent ],
93+
providers: [],
94+
bootstrap: [ AppComponent ]
9595
})
9696
export class AppModule {}
9797
```
@@ -101,22 +101,22 @@ export class AppModule {}
101101
import { ApiModule, Configuration } from '';
102102

103103
@NgModule({
104-
imports: [ ApiModule ],
105-
declarations: [ AppComponent ],
106-
providers: [
107-
{
108-
provide: Configuration,
109-
useFactory: (authService: AuthService) => new Configuration(
110-
{
111-
basePath: environment.apiUrl,
112-
accessToken: authService.getAccessToken.bind(authService)
113-
}
114-
),
115-
deps: [AuthService],
116-
multi: false
117-
}
118-
],
119-
bootstrap: [ AppComponent ]
104+
imports: [ ApiModule ],
105+
declarations: [ AppComponent ],
106+
providers: [
107+
{
108+
provide: Configuration,
109+
useFactory: (authService: AuthService) => new Configuration(
110+
{
111+
basePath: environment.apiUrl,
112+
accessToken: authService.getAccessToken.bind(authService)
113+
}
114+
),
115+
deps: [AuthService],
116+
multi: false
117+
}
118+
],
119+
bootstrap: [ AppComponent ]
120120
})
121121
export class AppModule {}
122122
```
@@ -125,7 +125,7 @@ export class AppModule {}
125125
import { DefaultApi } from '';
126126

127127
export class AppComponent {
128-
constructor(private apiGateway: DefaultApi) { }
128+
constructor(private apiGateway: DefaultApi) { }
129129
}
130130
```
131131

@@ -144,13 +144,13 @@ import { ApiModule as OtherApiModule } from 'my-other-api-path';
144144
import { HttpClientModule } from '@angular/common/http';
145145

146146
@NgModule({
147-
imports: [
148-
ApiModule,
149-
OtherApiModule,
150-
// make sure to import the HttpClientModule in the AppModule only,
151-
// see https://github.com/angular/angular/issues/20575
152-
HttpClientModule
153-
]
147+
imports: [
148+
ApiModule,
149+
OtherApiModule,
150+
// make sure to import the HttpClientModule in the AppModule only,
151+
// see https://github.com/angular/angular/issues/20575
152+
HttpClientModule
153+
]
154154
})
155155
export class AppModule {
156156

@@ -165,7 +165,7 @@ If different than the generated base path, during app bootstrap, you can provide
165165
import { BASE_PATH } from '';
166166

167167
bootstrap(AppComponent, [
168-
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
168+
{ provide: BASE_PATH, useValue: 'https://your-web-service.com' },
169169
]);
170170
```
171171

@@ -175,10 +175,10 @@ or
175175
import { BASE_PATH } from '';
176176

177177
@NgModule({
178-
imports: [],
179-
declarations: [ AppComponent ],
180-
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
181-
bootstrap: [ AppComponent ]
178+
imports: [],
179+
declarations: [ AppComponent ],
180+
providers: [ provide: BASE_PATH, useValue: 'https://your-web-service.com' ],
181+
bootstrap: [ AppComponent ]
182182
})
183183
export class AppModule {}
184184
```
@@ -189,8 +189,8 @@ First extend your `src/environments/*.ts` files by adding the corresponding base
189189

190190
```typescript
191191
export const environment = {
192-
production: false,
193-
API_BASE_PATH: 'http://127.0.0.1:8080'
192+
production: false,
193+
API_BASE_PATH: 'http://127.0.0.1:8080'
194194
};
195195
```
196196

@@ -201,12 +201,12 @@ import { BASE_PATH } from '';
201201
import { environment } from '../environments/environment';
202202

203203
@NgModule({
204-
declarations: [
205-
AppComponent
206-
],
207-
imports: [ ],
208-
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
209-
bootstrap: [ AppComponent ]
204+
declarations: [
205+
AppComponent
206+
],
207+
imports: [ ],
208+
providers: [{ provide: BASE_PATH, useValue: environment.API_BASE_PATH }],
209+
bootstrap: [ AppComponent ]
210210
})
211211
export class AppModule { }
212212
```
@@ -227,7 +227,7 @@ Example value for use in your Configuration-Provider:
227227

228228
```typescript
229229
new Configuration({
230-
encodeParam: (param: Param) => myFancyParamEncoder(param),
230+
encodeParam: (param: Param) => myFancyParamEncoder(param),
231231
})
232232
```
233233

0 commit comments

Comments
 (0)