Skip to content

Commit 786abc7

Browse files
authored
Merge pull request #8 from TassoDigital/nestjsUpgrade
Upgraded nestjs from v6.0.0 to v9.2.1
2 parents e407004 + 86d14a0 commit 786abc7

File tree

8 files changed

+231
-158
lines changed

8 files changed

+231
-158
lines changed

docs/generators/typescript-nestjs.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
1717
|modelFileSuffix|The suffix of the file of the generated model (model<suffix>.ts).| |null|
1818
|modelPropertyNaming|Naming convention for the property: 'camelCase', 'PascalCase', 'snake_case' and 'original', which keeps the original name. Only change it if you provide your own run-time code for (de-)serialization of models| |original|
1919
|modelSuffix|The suffix of the generated model.| |null|
20-
|nestVersion|The version of Nestjs.| |6.0.0|
20+
|nestVersion|The version of Nestjs.| |9.2.1|
2121
|npmName|The name under which you want to publish generated npm package. Required to generate a full package| |null|
2222
|npmRepository|Use this property to set an url your private npmRepo in the package.json| |null|
2323
|npmVersion|The version of your npm package. If not provided, using the version from the OpenAPI specification file.| |1.0.0|

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptNestjsClientCodegen.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class TypeScriptNestjsClientCodegen extends AbstractTypeScriptClientCodeg
4949
public static final String STRING_ENUMS = "stringEnums";
5050
public static final String STRING_ENUMS_DESC = "Generate string enums instead of objects for enum values.";
5151

52-
protected String nestVersion = "6.0.0";
52+
protected String nestVersion = "9.2.1";
5353
protected String npmRepository = null;
5454
protected String serviceSuffix = "Service";
5555
protected String serviceFileSuffix = ".service";

modules/openapi-generator/src/main/resources/typescript-nestjs/api.service.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class {{classname}} {
3535
{{/withInterfaces}}
3636

3737
protected basePath = '{{{basePath}}}';
38-
public defaultHeaders: AxiosRequestHeaders = {};
38+
public defaultHeaders: Record<string, string> = {};
3939
public configuration = new Configuration();
4040

4141
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {

samples/client/petstore/typescript-nestjs-v6-provided-in-root/builds/default/api.module.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1-
import { DynamicModule, HttpService, HttpModule, Module, Global } from '@nestjs/common';
1+
import { DynamicModule, Module, Global } from '@nestjs/common';
2+
import { HttpService, HttpModule, HttpModuleOptions } from '@nestjs/axios';
23
import { Configuration } from './configuration';
34

5+
46
import { PetService } from './api/pet.service';
57
import { StoreService } from './api/store.service';
68
import { UserService } from './api/user.service';
79

810
@Global()
911
@Module({
10-
imports: [ HttpModule ],
12+
imports: [ ],
1113
exports: [
1214
PetService,
1315
StoreService,
@@ -23,7 +25,13 @@ export class ApiModule {
2325
public static forRoot(configurationFactory: () => Configuration): DynamicModule {
2426
return {
2527
module: ApiModule,
26-
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
28+
providers: [ { provide: Configuration, useFactory: configurationFactory } ],
29+
imports: [
30+
HttpModule.registerAsync({
31+
useFactory: configurationFactory().httpModuleOptionsFactory
32+
})
33+
],
34+
exports: [HttpModule]
2735
};
2836
}
2937

samples/client/petstore/typescript-nestjs-v6-provided-in-root/builds/default/api/pet.service.ts

Lines changed: 93 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,48 @@
1111
*/
1212
/* tslint:disable:no-unused-variable member-ordering */
1313

14-
import { HttpService, Inject, Injectable, Optional } from '@nestjs/common';
15-
import { AxiosResponse } from 'axios';
14+
import { Inject, Injectable, Optional } from '@nestjs/common';
15+
import { HttpService } from '@nestjs/axios';
16+
import { AxiosResponse, AxiosRequestHeaders } from 'axios';
1617
import { Observable } from 'rxjs';
1718
import { ApiResponse } from '../model/apiResponse';
1819
import { Pet } from '../model/pet';
1920
import { Configuration } from '../configuration';
2021

21-
22+
type addPetParams = {
23+
pet: Pet,
24+
}
25+
type deletePetParams = {
26+
petId: number,
27+
apiKey?: string,
28+
}
29+
type findPetsByStatusParams = {
30+
status: Array<'available' | 'pending' | 'sold'>,
31+
}
32+
type findPetsByTagsParams = {
33+
tags: Array<string>,
34+
}
35+
type getPetByIdParams = {
36+
petId: number,
37+
}
38+
type updatePetParams = {
39+
pet: Pet,
40+
}
41+
type updatePetWithFormParams = {
42+
petId: number,
43+
name?: string,
44+
status?: string,
45+
}
46+
type uploadFileParams = {
47+
petId: number,
48+
additionalMetadata?: string,
49+
file?: Blob,
50+
}
2251
@Injectable()
2352
export class PetService {
2453

2554
protected basePath = 'http://petstore.swagger.io/v2';
26-
public defaultHeaders = new Map()
55+
public defaultHeaders: Record<string, string> = {};
2756
public configuration = new Configuration();
2857

2958
constructor(protected httpClient: HttpService, @Optional() configuration: Configuration) {
@@ -43,15 +72,15 @@ export class PetService {
4372
/**
4473
* Add a new pet to the store
4574
*
46-
* @param pet Pet object that needs to be added to the store
75+
* @param addPetParams
4776
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
4877
* @param reportProgress flag to report request and response progress.
4978
*/
50-
public addPet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
51-
public addPet(pet: Pet, ): Observable<any> {
79+
public addPet(params: addPetParams): Observable<AxiosResponse<Pet>>;
80+
public addPet(params: addPetParams): Observable<any> {
5281

53-
if (pet === null || pet === undefined) {
54-
throw new Error('Required parameter pet was null or undefined when calling addPet.');
82+
if ( params.pet === null || params.pet === undefined) {
83+
throw new Error('Required parameter params.pet was null or undefined when calling addPet.');
5584
}
5685

5786
let headers = this.defaultHeaders;
@@ -84,7 +113,7 @@ export class PetService {
84113
headers['Content-Type'] = httpContentTypeSelected;
85114
}
86115
return this.httpClient.post<Pet>(`${this.basePath}/pet`,
87-
pet,
116+
params.pet,
88117
{
89118
withCredentials: this.configuration.withCredentials,
90119
headers: headers
@@ -94,22 +123,21 @@ export class PetService {
94123
/**
95124
* Deletes a pet
96125
*
97-
* @param petId Pet id to delete
98-
* @param apiKey
126+
* @param deletePetParams
99127
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
100128
* @param reportProgress flag to report request and response progress.
101129
*/
102-
public deletePet(petId: number, apiKey?: string, ): Observable<AxiosResponse<any>>;
103-
public deletePet(petId: number, apiKey?: string, ): Observable<any> {
130+
public deletePet(params: deletePetParams): Observable<AxiosResponse<any>>;
131+
public deletePet(params: deletePetParams): Observable<any> {
104132

105-
if (petId === null || petId === undefined) {
106-
throw new Error('Required parameter petId was null or undefined when calling deletePet.');
133+
if ( params.petId === null || params.petId === undefined) {
134+
throw new Error('Required parameter params.petId was null or undefined when calling deletePet.');
107135
}
108136

109137

110138
let headers = this.defaultHeaders;
111-
if (apiKey !== undefined && apiKey !== null) {
112-
headers['api_key'] = String(apiKey);
139+
if (params.apiKey !== undefined && params.apiKey !== null) {
140+
headers['api_key'] = String(params.apiKey);
113141
}
114142

115143
// authentication (petstore_auth) required
@@ -131,7 +159,7 @@ export class PetService {
131159
// to determine the Content-Type header
132160
const consumes: string[] = [
133161
];
134-
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
162+
return this.httpClient.delete<any>(`${this.basePath}/pet/${encodeURIComponent(String(params.petId))}`,
135163
{
136164
withCredentials: this.configuration.withCredentials,
137165
headers: headers
@@ -141,20 +169,20 @@ export class PetService {
141169
/**
142170
* Finds Pets by status
143171
* Multiple status values can be provided with comma separated strings
144-
* @param status Status values that need to be considered for filter
172+
* @param findPetsByStatusParams
145173
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
146174
* @param reportProgress flag to report request and response progress.
147175
*/
148-
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<AxiosResponse<Array<Pet>>>;
149-
public findPetsByStatus(status: Array<'available' | 'pending' | 'sold'>, ): Observable<any> {
176+
public findPetsByStatus(params: findPetsByStatusParams): Observable<AxiosResponse<Array<Pet>>>;
177+
public findPetsByStatus(params: findPetsByStatusParams): Observable<any> {
150178

151-
if (status === null || status === undefined) {
152-
throw new Error('Required parameter status was null or undefined when calling findPetsByStatus.');
179+
if ( params.status === null || params.status === undefined) {
180+
throw new Error('Required parameter params.status was null or undefined when calling findPetsByStatus.');
153181
}
154182

155183
let queryParameters = {};
156-
if (status !== undefined && status !== null) {
157-
queryParameters['status'] = <any>status;
184+
if (params.status !== undefined && params.status !== null) {
185+
queryParameters['status'] = <any>params.status;
158186
}
159187

160188
let headers = this.defaultHeaders;
@@ -191,20 +219,20 @@ export class PetService {
191219
/**
192220
* Finds Pets by tags
193221
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
194-
* @param tags Tags to filter by
222+
* @param findPetsByTagsParams
195223
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
196224
* @param reportProgress flag to report request and response progress.
197225
*/
198-
public findPetsByTags(tags: Array<string>, ): Observable<AxiosResponse<Array<Pet>>>;
199-
public findPetsByTags(tags: Array<string>, ): Observable<any> {
226+
public findPetsByTags(params: findPetsByTagsParams): Observable<AxiosResponse<Array<Pet>>>;
227+
public findPetsByTags(params: findPetsByTagsParams): Observable<any> {
200228

201-
if (tags === null || tags === undefined) {
202-
throw new Error('Required parameter tags was null or undefined when calling findPetsByTags.');
229+
if ( params.tags === null || params.tags === undefined) {
230+
throw new Error('Required parameter params.tags was null or undefined when calling findPetsByTags.');
203231
}
204232

205233
let queryParameters = {};
206-
if (tags !== undefined && tags !== null) {
207-
queryParameters['tags'] = <any>tags;
234+
if (params.tags !== undefined && params.tags !== null) {
235+
queryParameters['tags'] = <any>params.tags;
208236
}
209237

210238
let headers = this.defaultHeaders;
@@ -241,15 +269,15 @@ export class PetService {
241269
/**
242270
* Find pet by ID
243271
* Returns a single pet
244-
* @param petId ID of pet to return
272+
* @param getPetByIdParams
245273
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
246274
* @param reportProgress flag to report request and response progress.
247275
*/
248-
public getPetById(petId: number, ): Observable<AxiosResponse<Pet>>;
249-
public getPetById(petId: number, ): Observable<any> {
276+
public getPetById(params: getPetByIdParams): Observable<AxiosResponse<Pet>>;
277+
public getPetById(params: getPetByIdParams): Observable<any> {
250278

251-
if (petId === null || petId === undefined) {
252-
throw new Error('Required parameter petId was null or undefined when calling getPetById.');
279+
if ( params.petId === null || params.petId === undefined) {
280+
throw new Error('Required parameter params.petId was null or undefined when calling getPetById.');
253281
}
254282

255283
let headers = this.defaultHeaders;
@@ -272,7 +300,7 @@ export class PetService {
272300
// to determine the Content-Type header
273301
const consumes: string[] = [
274302
];
275-
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
303+
return this.httpClient.get<Pet>(`${this.basePath}/pet/${encodeURIComponent(String(params.petId))}`,
276304
{
277305
withCredentials: this.configuration.withCredentials,
278306
headers: headers
@@ -282,15 +310,15 @@ export class PetService {
282310
/**
283311
* Update an existing pet
284312
*
285-
* @param pet Pet object that needs to be added to the store
313+
* @param updatePetParams
286314
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
287315
* @param reportProgress flag to report request and response progress.
288316
*/
289-
public updatePet(pet: Pet, ): Observable<AxiosResponse<Pet>>;
290-
public updatePet(pet: Pet, ): Observable<any> {
317+
public updatePet(params: updatePetParams): Observable<AxiosResponse<Pet>>;
318+
public updatePet(params: updatePetParams): Observable<any> {
291319

292-
if (pet === null || pet === undefined) {
293-
throw new Error('Required parameter pet was null or undefined when calling updatePet.');
320+
if ( params.pet === null || params.pet === undefined) {
321+
throw new Error('Required parameter params.pet was null or undefined when calling updatePet.');
294322
}
295323

296324
let headers = this.defaultHeaders;
@@ -323,7 +351,7 @@ export class PetService {
323351
headers['Content-Type'] = httpContentTypeSelected;
324352
}
325353
return this.httpClient.put<Pet>(`${this.basePath}/pet`,
326-
pet,
354+
params.pet,
327355
{
328356
withCredentials: this.configuration.withCredentials,
329357
headers: headers
@@ -333,17 +361,15 @@ export class PetService {
333361
/**
334362
* Updates a pet in the store with form data
335363
*
336-
* @param petId ID of pet that needs to be updated
337-
* @param name Updated name of the pet
338-
* @param status Updated status of the pet
364+
* @param updatePetWithFormParams
339365
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
340366
* @param reportProgress flag to report request and response progress.
341367
*/
342-
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<AxiosResponse<any>>;
343-
public updatePetWithForm(petId: number, name?: string, status?: string, ): Observable<any> {
368+
public updatePetWithForm(params: updatePetWithFormParams): Observable<AxiosResponse<any>>;
369+
public updatePetWithForm(params: updatePetWithFormParams): Observable<any> {
344370

345-
if (petId === null || petId === undefined) {
346-
throw new Error('Required parameter petId was null or undefined when calling updatePetWithForm.');
371+
if ( params.petId === null || params.petId === undefined) {
372+
throw new Error('Required parameter params.petId was null or undefined when calling updatePetWithForm.');
347373
}
348374

349375

@@ -382,15 +408,15 @@ export class PetService {
382408
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
383409
}
384410

385-
if (name !== undefined) {
386-
formParams.append('name', <any>name);
411+
if (params.name !== undefined) {
412+
formParams.append('name', <any>params.name);
387413
}
388414

389-
if (status !== undefined) {
390-
formParams.append('status', <any>status);
415+
if (params.status !== undefined) {
416+
formParams.append('status', <any>params.status);
391417
}
392418

393-
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}`,
419+
return this.httpClient.post<any>(`${this.basePath}/pet/${encodeURIComponent(String(params.petId))}`,
394420
convertFormParamsToString ? formParams.toString() : formParams,
395421
{
396422
withCredentials: this.configuration.withCredentials,
@@ -401,17 +427,15 @@ export class PetService {
401427
/**
402428
* uploads an image
403429
*
404-
* @param petId ID of pet to update
405-
* @param additionalMetadata Additional data to pass to server
406-
* @param file file to upload
430+
* @param uploadFileParams
407431
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
408432
* @param reportProgress flag to report request and response progress.
409433
*/
410-
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<AxiosResponse<ApiResponse>>;
411-
public uploadFile(petId: number, additionalMetadata?: string, file?: Blob, ): Observable<any> {
434+
public uploadFile(params: uploadFileParams): Observable<AxiosResponse<ApiResponse>>;
435+
public uploadFile(params: uploadFileParams): Observable<any> {
412436

413-
if (petId === null || petId === undefined) {
414-
throw new Error('Required parameter petId was null or undefined when calling uploadFile.');
437+
if ( params.petId === null || params.petId === undefined) {
438+
throw new Error('Required parameter params.petId was null or undefined when calling uploadFile.');
415439
}
416440

417441

@@ -455,15 +479,15 @@ export class PetService {
455479
// formParams = new HttpParams({encoder: new CustomHttpUrlEncodingCodec()});
456480
}
457481

458-
if (additionalMetadata !== undefined) {
459-
formParams.append('additionalMetadata', <any>additionalMetadata);
482+
if (params.additionalMetadata !== undefined) {
483+
formParams.append('additionalMetadata', <any>params.additionalMetadata);
460484
}
461485

462-
if (file !== undefined) {
463-
formParams.append('file', <any>file);
486+
if (params.file !== undefined) {
487+
formParams.append('file', <any>params.file);
464488
}
465489

466-
return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(petId))}/uploadImage`,
490+
return this.httpClient.post<ApiResponse>(`${this.basePath}/pet/${encodeURIComponent(String(params.petId))}/uploadImage`,
467491
convertFormParamsToString ? formParams.toString() : formParams,
468492
{
469493
withCredentials: this.configuration.withCredentials,

0 commit comments

Comments
 (0)