Skip to content

Commit d627de6

Browse files
committed
Update ApiCreateDecorator to include operationOptions in IdentitiesController
1 parent c89ba5e commit d627de6

File tree

6 files changed

+34
-18
lines changed

6 files changed

+34
-18
lines changed

src/_common/decorators/api-create.decorator.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { applyDecorators, Type } from '@nestjs/common';
2-
import { ApiBodyOptions } from '@nestjs/swagger';
2+
import { ApiBodyOptions, ApiOperationOptions } from '@nestjs/swagger';
33
import { ApiResponseOptions } from '@nestjs/swagger/dist/decorators/api-response.decorator';
44
import { ApiBodyDecorator } from '~/_common/decorators/api-body.decorator';
55
import { ApiCreatedResponseDecorator } from '~/_common/decorators/api-created-response.decorator';
@@ -10,10 +10,14 @@ export const ApiCreateDecorator = <TModel extends Type<NonNullable<unknown>>>(
1010
options?: {
1111
bodyOptions?: ApiBodyOptions | null | undefined,
1212
responseOptions?: ApiResponseOptions | null | undefined,
13+
operationOptions?: ApiOperationOptions | null | undefined,
1314
},
1415
) => {
1516
return applyDecorators(
1617
ApiBodyDecorator(bodyModel, options?.bodyOptions),
17-
ApiCreatedResponseDecorator(responseModel, { responseOptions: options?.responseOptions }),
18+
ApiCreatedResponseDecorator(responseModel, {
19+
responseOptions: options?.responseOptions,
20+
operationOptions: options?.operationOptions,
21+
}),
1822
);
1923
};

src/core/backends/backends.controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Sse,
1212
UnauthorizedException,
1313
} from '@nestjs/common';
14-
import { ApiTags } from '@nestjs/swagger';
14+
import { ApiOperation, ApiTags } from '@nestjs/swagger';
1515
import { Response } from 'express';
1616
import Redis from 'ioredis';
1717
import { Observable, Subscriber } from 'rxjs';
@@ -43,6 +43,7 @@ export class BackendsController {
4343
) { }
4444

4545
@Post('sync')
46+
@ApiOperation({ summary: 'Synchronise une liste d\'identitées' })
4647
public async syncIdentities(
4748
@Res() res: Response,
4849
@Body() body: SyncIdentitiesDto,
@@ -57,6 +58,7 @@ export class BackendsController {
5758
}
5859

5960
@Post('syncall')
61+
@ApiOperation({ summary: 'Synchronise toutes les identitées à synchroniser' })
6062
public async syncAllIdentities(@Res() res: Response, @Query('async') asyncQuery: string) {
6163
const async = /true|on|yes|1/i.test(asyncQuery);
6264
const data = await this.backendsService.syncAllIdentities({
@@ -66,6 +68,7 @@ export class BackendsController {
6668
}
6769

6870
@Post('execute')
71+
@ApiOperation({ summary: 'Execute un backend manuellement' })
6972
public async executeJob(
7073
@Res() res: Response,
7174
@Body() body: ExecuteJobDto,
@@ -100,6 +103,7 @@ export class BackendsController {
100103

101104
@Public()
102105
@Sse('sse')
106+
@ApiOperation({ summary: 'Server Sent Event - Récupère en temps réel les Jobs et affiche leurs état' })
103107
public async sse(@Res() res: Response, @Query('key') key: string): Promise<Observable<MessageEvent>> {
104108
if (key !== 'hZcdVqHScVDsDFdHOdcjmufEKFJVKaS8') throw new UnauthorizedException();
105109

src/management/identities/identities.controller.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
Query,
1212
Res
1313
} from '@nestjs/common';
14-
import { ApiParam, ApiTags } from '@nestjs/swagger';
14+
import { ApiOperation, ApiParam, ApiTags } from '@nestjs/swagger';
1515
import { FilterOptions, FilterSchema, SearchFilterOptions, SearchFilterSchema } from '@streamkits/nestjs_module_scrud';
1616
import { Response } from 'express';
1717
import { Document, Types, isValidObjectId } from 'mongoose';
@@ -83,7 +83,11 @@ export class IdentitiesController extends AbstractController {
8383
}
8484

8585
@Post('upsert')
86-
@ApiCreateDecorator(IdentitiesUpsertDto, IdentitiesDto)
86+
@ApiCreateDecorator(IdentitiesUpsertDto, IdentitiesDto, {
87+
operationOptions: {
88+
summary: 'Importe ou met à jour une <Identitée> en fonction des filtres fournis',
89+
},
90+
})
8791
public async upsert(
8892
@Res()
8993
res: Response,
@@ -189,6 +193,7 @@ export class IdentitiesController extends AbstractController {
189193
}
190194

191195
@Get('count')
196+
@ApiOperation({ summary: 'Compte le nombre d\'identitées en fonctions des filtres fournis' })
192197
public async count(
193198
@Res() res: Response,
194199
@SearchFilterSchema() searchFilterSchema: FilterSchema,
@@ -239,6 +244,7 @@ export class IdentitiesController extends AbstractController {
239244
}
240245

241246
@Patch('state')
247+
@ApiOperation({ summary: 'Met à jour l\'état d\'une ou plusieurs <Identitées> en masse' })
242248
public async updateStateMany(
243249
@Res() res: Response,
244250
@Body()

src/management/identities/jsonforms/identities.jsonforms.controller.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Body, Controller, Get, HttpStatus, Param, Post, Res } from '@nestjs/com
22
import { AbstractController } from '~/_common/abstracts/abstract.controller';
33
import { IdentitiesJsonformsService } from './identities.jsonforms.service';
44
import { Response } from 'express';
5-
import { ApiTags } from '@nestjs/swagger'
5+
import { ApiOperation, ApiTags } from '@nestjs/swagger'
66

77
@ApiTags('management/identities/jsonforms')
88
@Controller('management/identities/jsonforms')
@@ -12,6 +12,7 @@ export class IdentitiesJsonFormsController extends AbstractController {
1212
}
1313

1414
@Post('generateAll')
15+
@ApiOperation({ summary: 'Génère tous les JSON Forms liés aux schémas personnalisés' })
1516
async generateAll(@Res() res: Response): Promise<any> {
1617
const result = await this._service.generateAll();
1718
return res.status(HttpStatus.OK).json({
@@ -21,6 +22,7 @@ export class IdentitiesJsonFormsController extends AbstractController {
2122
}
2223

2324
@Post('generate')
25+
@ApiOperation({ summary: 'Génère un JSON Forms d\'un schéma personnalisé' })
2426
async generate(@Res() res: Response, @Body('schema') schema: string | null = null): Promise<any> {
2527
const result = await this._service.generate({ schema, path: './configs/identities/jsonforms' });
2628
return res.status(HttpStatus.OK).json({
@@ -30,6 +32,7 @@ export class IdentitiesJsonFormsController extends AbstractController {
3032
}
3133

3234
@Get()
35+
@ApiOperation({ summary: 'Liste les JSON Forms de schémas personnalisés' })
3336
async searchAll(@Res() res: Response): Promise<any> {
3437
const result = await this._service.findAll();
3538
return res.status(HttpStatus.OK).json({
@@ -39,6 +42,7 @@ export class IdentitiesJsonFormsController extends AbstractController {
3942
}
4043

4144
@Get(':schema')
45+
@ApiOperation({ summary: 'Récupère un JSON Forms d\'un schéma personnalisé' })
4246
async search(@Res() res: Response, @Param('schema') schema): Promise<any> {
4347
const result = await this._service.findOne(schema);
4448
return res.status(HttpStatus.OK).json({

src/management/identities/validations/identities.validation.controller.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Body, Controller, Get, HttpStatus, Param, Post, Res } from '@nestjs/common';
22
import { AbstractController } from '~/_common/abstracts/abstract.controller';
3-
import { ApiTags } from '@nestjs/swagger';
3+
import { ApiOperation, ApiTags } from '@nestjs/swagger';
44
import { Response } from 'express';
55
import { MixedValue } from '~/_common/types/mixed-value.type';
66
import { AdditionalFieldsPart } from '../_schemas/_parts/additionalFields.part.schema';
@@ -14,6 +14,7 @@ export class IdentitiesValidationController extends AbstractController {
1414
}
1515

1616
@Post()
17+
@ApiOperation({ summary: 'Effectue la validation des schémas personnalisés d\'identités' })
1718
public async validate(
1819
@Res()
1920
res: Response,
@@ -45,6 +46,7 @@ export class IdentitiesValidationController extends AbstractController {
4546
}
4647

4748
@Get()
49+
@ApiOperation({ summary: 'Liste les schémas personnalisés d\'identités' })
4850
async searchAll(@Res() res: Response): Promise<any> {
4951
const result = await this._service.findAll();
5052
return res.status(HttpStatus.OK).json({
@@ -54,6 +56,7 @@ export class IdentitiesValidationController extends AbstractController {
5456
}
5557

5658
@Get(':schema')
59+
@ApiOperation({ summary: 'Récupère un schéma personnalisé d\'identités' })
5760
async search(@Res() res: Response, @Param('schema') schema): Promise<any> {
5861
const result = await this._service.findOne(schema);
5962
return res.status(HttpStatus.OK).json({

src/management/passwd/passwd.controller.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,18 @@ export class PasswdController {
1515
public constructor(private passwdService: PasswdService) { }
1616

1717
@Post('change')
18-
@ApiOperation({ summary: 'Change password' })
19-
@ApiResponse({ status: HttpStatus.OK, description: 'Password has been successfully changed.' })
20-
@ApiResponse({ status: HttpStatus.BAD_REQUEST, description: 'Old password wrong' })
18+
@ApiOperation({ summary: 'Execute un job de changement de mot de passe sur le/les backends' })
19+
@ApiResponse({ status: HttpStatus.OK, description: 'Mot de passe synchronisé sur le/les backends' })
2120
public async change(@Body() body: ChangePasswordDto, @Res() res: Response): Promise<Response> {
22-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
2321
const [_, data] = await this.passwdService.change(body);
2422
this.logger.log(`Call passwd change for : ${body.uid}`);
2523

2624
return res.status(HttpStatus.OK).json(data);
2725
}
2826

2927
@Post('gettoken')
30-
@ApiOperation({ summary: 'Ask token for reseting password' })
31-
@ApiResponse({ status: HttpStatus.OK, description: 'Token' })
32-
@ApiResponse({ status: HttpStatus.BAD_REQUEST })
28+
@ApiOperation({ summary: 'Récupère un jeton de réinitialisation de mot de passe' })
29+
@ApiResponse({ status: HttpStatus.OK, description: 'Retourne un jeton de réinitialisation de mot de passe' })
3330
public async gettoken(@Body() asktoken: AskTokenDto, @Res() res: Response): Promise<Response> {
3431
this.logger.log('GetToken for : ' + asktoken.uid);
3532
const token = await this.passwdService.askToken(asktoken);
@@ -38,9 +35,8 @@ export class PasswdController {
3835
}
3936

4037
@Post('verifytoken')
41-
@ApiOperation({ summary: 'Ask token for reseting password' })
38+
@ApiOperation({ summary: 'Vérifie un jeton de réinitilisation de mot de passe' })
4239
@ApiResponse({ status: HttpStatus.OK })
43-
@ApiResponse({ status: HttpStatus.BAD_REQUEST })
4440
public async verifyToken(@Body() body: VerifyTokenDto, @Res() res: Response): Promise<Response> {
4541
this.logger.log('Verify token : ' + body.token);
4642
const data = await this.passwdService.decryptToken(body.token);
@@ -49,9 +45,8 @@ export class PasswdController {
4945
}
5046

5147
@Post('reset')
52-
@ApiOperation({ summary: 'Reset password' })
48+
@ApiOperation({ summary: 'Execute un job de réinitialisation de mot de passe sur le/les backends' })
5349
@ApiResponse({ status: HttpStatus.OK })
54-
@ApiResponse({ status: HttpStatus.BAD_REQUEST })
5550
public async reset(@Body() body: ResetPasswordDto, @Res() res: Response): Promise<Response> {
5651
// eslint-disable-next-line @typescript-eslint/no-unused-vars
5752
const [_, data] = await this.passwdService.reset(body);

0 commit comments

Comments
 (0)